//					ContentPAL .Net
//					----------------
//
//					Version 1.0.0.1
//
//
//					©2006 Nextgen Web Services (India) Pvt. Ltd.
//
//

//Added by Vasanth on 18July2008 - code moved from display page to here

    var Reg = 0;
        function onDelete(svlPublicId,svlPrivateId,svlCurrentPageId,svlCanDelete)
        {
            if(svlCurrentPageId==svlPublicId )
            {
                alert('This Page cannot be deleted since it is linked as Public Page');
                return false;
            }
            else if(svlCurrentPageId==svlPrivateId)
            {
                alert('This Page cannot be deleted since it is linked as Private Page');
                return false;
            }
            else if(svlCanDelete=="NO")
            {
                alert('This Data cannnot be delete as it has been linked to ToolBar');
                return false;
            }
            else
            {
                return confirm('Do you want to Delete this Page?');
            }
            return true;
        }
    //code end
    
//Prodcuts related functions
    function Sorting(id)
    {
        var surl = window.location.href.replace(/&sort=([a-zA-Z0-9]+)/,"")
        window.location.href= surl + "&sort=" + id;
    }
    function SortingImages(sortingId)
    {
        if(sortingId  == 'pa')        
        {
            if(document.getElementById('sortasc'))
            document.getElementById('sortasc').src ="../assets/sort_asc_s.gif";                       
        }
        else if(sortingId  == 'pd')
        {        
            if(document.getElementById('sortdec'))
            document.getElementById('sortdec').src ="../assets/sort_des_s.gif";
        } 
        else
        {
            if(document.getElementById('sortasc'))
                document.getElementById('sortasc').src ="../assets/sort_asc.gif";                       
            if(document.getElementById('sortdec'))
                document.getElementById('sortdec').src ="../assets/sort_des.gif";
        }
        
    }

  	var bvlClicked = false
	function ChangeImage(BigImgsrc,Id,hdnId)
	{
	    var len = document.forms[0].length; 
        var cnt=0;        
        for(i=1;i<len;i++)
        {
            if(document.forms[0].elements[i].id.indexOf('hdnFlag') > -1)
                cnt =cnt+2;
        }
	    for(i=0;i<=cnt;i++)
	    {
	        var temphdn = "hdnFlag" + i;
	        var tempthumbs = "thumbs" + i;
	        if (hdnId == temphdn) 
	        {
	         
	            document.getElementById(hdnId).value = true;	            
	            TumbBorder(Id,hdnId);
	        }
	        else
	        {
	            
	            if(document.getElementById(temphdn))
	            {
	                document.getElementById(temphdn).value = "";	                	                
	                TumbBorder(tempthumbs,temphdn);
	            }
	        }
	    }	    
	    document.getElementById('BigImg').src = BigImgsrc;
	}
	function TumbBorder(Id,hdnId)
	{
	    if(document.getElementById(hdnId).value == "true")
	        document.getElementById(Id).style.border='1px solid #C858D5';   
	    else
	        document.getElementById(Id).style.border='1px solid #dddddd';	//grey colour
	}
	
	function DesChangeImage(BigImgsrc,Id,hdnId,PrdId,PrdDes,PrdDet,Price,WidthHeight,UniqId)
	{
	
	    var divobj=document.getElementById('codelab');
	    if (PrdId !=null && PrdId != "")
	    {
	        if (PrdId.indexOf("_")>-1)
	        {
	            var tmpval=PrdId.substring(PrdId.indexOf("_") +1);
//	            if (tmpval.toUpperCase() == "S")
//	                tmpval = "Silver";
                switch (tmpval.toUpperCase())
                {
                    case 'S':
                        tmpval = "Silver";
                        break;
                    case "10K":
                        tmpval = "10 Karat Gold";
                        break;
                    case "14K":
                        tmpval = "14 Karat Gold";
                        break;
                    case "14KW":
                        tmpval = "14 Karat White Gold";
                        break;
                    case "18K":
                        tmpval = "18 Karat Gold";
                        break;
                    case "18KW":
                        tmpval = "18 Karat White Gold";
                        break;
                }
	            divobj.innerHTML=tmpval;
	        }
	    }
	    var uniqhidden = document.getElementById('UniqHid');
	    uniqhidden.value=UniqId;
	    var len = document.forms[0].length; 
        var cnt=0;        
        for(i=1;i<len;i++)
        {
            if(document.forms[0].elements[i].id.indexOf('hdnFlag') > -1)
                cnt =cnt+2;
        }
	    for(i=0;i<=cnt;i++)
	    {
	        var temphdn = "hdnFlag" + i;
	        var tempthumbs = "tcol" + i;
	        if (hdnId == temphdn) 
	        {
	         
	            document.getElementById(hdnId).value = true;	            
	            TumbBorder(Id,hdnId);
	        }
	        else
	        {
	            if(document.getElementById(temphdn))
	            {
	                document.getElementById(temphdn).value = "";	                	                
	                TumbBorder(tempthumbs,temphdn);
	            }
	        }
	    }	    
	    var table = "<table cellspacing='3' cellpadding='3' border='0' style='color:#850c85;font-size:8pt;'>";
        table = table + "<tr><td>" + PrdId + "<\/td><\/tr>";
        table = table + "<tr><td>" + PrdDes + "<\/td><\/tr>";        
        table = table + "<tr><td>" + PrdDet + "<\/td><\/tr>";
        
        var combhid=document.getElementById('combihidden');
        if (combhid != null)
        {
            table = table + "<tr><td><input type='hidden' id='combihidden' runat='server' value='" + combhid.value + "' />Size : " + combhid.value + "<\/td><\/tr>";        
        }
        if (WidthHeight != "")
           table = table + "<tr><td><span style='font-weight:bold;font-size:9pt;'>Dimensions<\/span><\/td><\/tr><tr><td>" + WidthHeight + "<\/td><\/tr>";
        table = table + "<tr><td><span style='font-weight:bold;font-size:9pt;'>" + Price + "<\/span><\/td><\/tr>";	
        table = table + "<\/table>    ";
	    document.getElementById('BigImg').src = BigImgsrc;
	    var dislabel;
	    if (document.getElementById)
	    {
	        dislabel = document.getElementById('deslabel');    
	    }
	    else if (document.all)
	    {
            dislabel = document.all['deslabel'];                	    
	    }
	    if (dislabel)
	    {
	        dislabel.innerHTML = table;
	    }
	}
	function Checkzero(Id)
	{	
	    if (document.getElementById(Id).value == '' || parseFloat(document.getElementById(Id).value)<=0)
	    {
	        alert("Quantity can't be less than 0.");
			document.getElementById(Id).focus();
			return false;
	    }
	    return true;
	}
	    
	
	// Numeric validator
    function onKeyPress(e) 
    {  
        var key;
	    var keychar;
	    var valid; 
	    valid = "0123456789";							
    	
	    if(window.event) 
	    {
		    // for IE, e.keyCode or window.event.keyCode can be used
		    key = e.keyCode; 
	    }
	    else if(e.which) 
	    {
		    // netscape
		    key = e.which; 
	    }
	    else 
	    {
		    // no event, so pass through
		    return true;
	    }

	    keychar = String.fromCharCode(key);
	    if (valid.indexOf(keychar) == "-1") 
	    {
		    return false;
	    }
	    else 
	    {
		    return true;
	    }
    }
    
    var url = window.parent.location.href;    
    
	var pos
	pos = url.indexOf("BtnRights=");	
	
	if (pos > 0)	
	{
	    // Get Display page URL
	    url = url.substring(0,pos+14);	
	}
	else 
	{
	   // Get Preview Page URL 
	   pos = url.indexOf("DataId=");	
	   url = url.substring(0,pos+15);	
	}
	
	function trim(stringToTrim) 
    {
	     return stringToTrim.replace(/^\s+|\s+$/g,"");
    }
	function ProductSearch(svlSearchpageId, svlFromDataId)
	{
		if (document.forms[0] != null) 
		{
		     if(document.getElementById('txtproductsearch').value.replace(/^\s*|\s*$/g,"") == "") 
            {
                alert('Please Enter the Search Criteria');
                document.getElementById('txtproductsearch').focus();
                return false;
            }
            else
            {
            	var svlSearchvalue = trim(document.getElementById('txtproductsearch').value);	
//            	var tempurl = '';
//            	if (url.indexOf("DataId=") > -1)
//            	{	        
//		            tempurl  = url.substring(0,url.indexOf("DataId="));
//		        }
//		        else
//		        {
//		            //tempurl = '../ContentBuilder/Displaypage.aspx';
//		            tempurl  = url.substring(0,url.indexOf("DataId=")) + 'ContentBuilder/Displaypage.aspx?';
//		        }
                var strMatch = 'ContentBuilder/DisplayPage/';
                var strUrl = window.location.href;
                strUrl = strUrl.substring(0, strUrl.indexOf(strMatch));
                strUrl = strUrl + svlSearchpageId + "/search/" + svlSearchvalue +"/"+ svlFromDataId;		        
                document.forms[0].action = strUrl;
		        document.forms[0].submit();
		    }
		    
		}
	    
	}
	
	function ProductPage_onChange(svlPID,svlCurPage,svlStart) 
	{
		if (document.forms[0] != null) 
		{
		    var svlCID="";
		    //alert('values : ' + svlPID + svlCurPage + svlStart );
		    if (document.getElementById('categoriescombo'))
		    {
		        svlCID =  document.getElementById('categoriescombo').options[document.getElementById('categoriescombo').selectedIndex].value;		    		    
			    document.forms[0].action = url + "&view=combo&ProdCategoryID=" + svlCID +"&PID=" + svlPID + "&CurPage=" + svlCurPage + "&Start=" + svlStart;
			}
			else
			{
			    document.forms[0].action = url + "&view=&ProdCategoryID=" + svlCID +"&PID=" + svlPID + "&CurPage=" + svlCurPage + "&Start=" + svlStart;
			}
			document.forms[0].submit();
		} 
		else
		{
			//location.href = "./DisMidFrame.asp?Module=DATA&DATAID=DA000035&ParentID=SU000009&DisplayMenu=True&CID=" + svlCID + "&PID=" + svlPID + "&ViewType=&CurPage=" + svlCurPage + "&Start=" + svlStart
		}
	}   
	
	function cboProductReport_onChange() 
	{
		if (document.forms[0] != null) 
		{
		    var svlCID =  document.getElementById('categoriescombo').options[document.getElementById('categoriescombo').selectedIndex].value;		    
			document.forms[0].action = url + "&view=combo&ProdCategoryID=" + svlCID +"&PID=&CurPage=1&Start=0";
			document.forms[0].submit();
		} 
		else
		{
			//location.href = "./DisMidFrame.asp?Module=DATA&DATAID=DA000035&ParentID=SU000009&DisplayMenu=True&CID=" + svlCID + "&PID=" + svlPID + "&ViewType=&CurPage=" + svlCurPage + "&Start=" + svlStart
		}
	}

    function ShowSubProduct(svlCatID,svlProductID, svlUniqueID) 
    {
         var strMatch = 'DisplayPage/';
         var strUrl = window.location.href;
         strUrl = strUrl.substring(0, strUrl.indexOf(strMatch) + strMatch.length);
         
        if (svlProductID != "" && bvlClicked == false) {
			if (document.forms[0] != null) {
				document.forms[0].action = strUrl + "/Cat/sub/"+ svlCatID+"/" + svlProductID + "/" + svlUniqueID
				document.forms[0].submit();
			} 
			else {
				location.href = strUrl + "/Cat/sub/"+ svlCatID+"/" + svlProductID + "/" + svlUniqueID;
			}
		}
    
    }
	function ShowDetailedProduct(svlMultiDataID, svlProductID, svlUniqueID,svlPreview) 
	{
//	    alert(svlMultiDataID);
//	    alert(svlProductID);
//	    alert(svlPreview);

        if (svlMultiDataID !="" && svlPreview != 'true')
        {
            var strMatch = 'ContentBuilder/DisplayPage/';
            var strUrl = window.location.href;
            strUrl = strUrl.substring(0, strUrl.indexOf(strMatch));
            deturl = strUrl + svlMultiDataID;
        }
        else
        {
            var strMatch = '.html';
            strUrl = window.parent.location.href;
            strUrl = strUrl.substring(0, strUrl.indexOf(strMatch) + strMatch.length);
            
            strMatch = 'ContentBuilder/DisplayPage/';
            var strPage = strUrl.substring(strUrl.indexOf(strMatch) + strMatch.length);
            var strDomain = strUrl.substring(0, strUrl.indexOf(strMatch));
            strUrl = strDomain + strPage;
            deturl = strUrl
        }
        if (svlProductID != "" && bvlClicked == false) 
	    {	    
	        if (parent.document.forms[0] != null) 
			{
//			    alert(deturl);
			    parent.document.forms[0].action = deturl + "/Prod/detail/" + svlProductID + "/" + svlUniqueID
				parent.document.forms[0].submit();
			} 
			else 
			{
			    //window.parent.location.href = deturl + "/detail/" + svlProductID + "/" + svlUniqueID +"&PID=&CurPage=&Start=";
			    window.parent.location.href = deturl + "/Prod/detail/" + svlProductID + "/" + svlUniqueID;
			}
		}
	}
	
	function AddToShopping(svlProductID, svlProductUniqueID,svltxtQty) 
	{     	    
     	if (svlProductID != "") 
		{
		    var txtQuantity = 1;
		    var txtqty=document.getElementById('txtShoppingQuantity'+ svlProductUniqueID);
			//if (eval("document.all.txtShoppingQuantity" + svlProductUniqueID).value != "undefined") 
			if (txtqty.value != "")
			{
				//txtQuantity = eval("document.all.txtShoppingQuantity" + svlProductUniqueID + ".value");
				txtQuantity = txtqty.value;
			}			
			if (txtqty.value == '' || parseFloat(txtqty.value) <= 0)
			{
			    alert("Quantity can't be less than 0");
			    return false;
			}
			
			 var strMatch = '.html';
            strUrl = window.parent.location.href;
            strUrl = strUrl.substring(0, strUrl.indexOf(strMatch) + strMatch.length);
            
            strMatch = 'ContentBuilder/DisplayPage/';
            var strPage = strUrl.substring(strUrl.indexOf(strMatch) + strMatch.length);
            var strDomain = strUrl.substring(0, strUrl.indexOf(strMatch));
            strUrl = strDomain + strPage;
            
			//location.href = url + "&view=shopping&ProductID=" + svlProductID + "&UniqueID=" + svlProductUniqueID +"&qty=" + txtQuantity +"&PID=&CurPage=&Start=";
            if (parent.document.forms[0] != null)
            {
                parent.document.forms[0].action = strUrl + "/Shopping/shopping/" + svlProductID + "/" + svlProductUniqueID +"/" + txtQuantity;
				parent.document.forms[0].submit();
            }
            else
            {
    			window.parent.location.href = strUrl + "/Shopping/shopping/" + svlProductID + "/" + svlProductUniqueID +"/" + txtQuantity;
            }			
			bvlClicked = true
		}
	}
	
	function AddToShoppingDetail(svlTableId) 
	{     	    
	    var uniqhidden = document.getElementById('UniqHid');
	    
     	if (uniqhidden.value != "") 
		{
		    var txtQuantity = 1;
			if (eval("document.all.txtShoppingQuantity.value" != "undefined")) 
			{
				txtQuantity = eval("document.all.txtShoppingQuantity.value")
			}	
			var sizcomb=document.getElementById('SizeComb');
			var sizcombval="";
			if (sizcomb!=null)
			{
			    sizcombval=sizcomb.value;
			}		
			
			var strMatch = '.html';
            strUrl = window.parent.location.href;
            strUrl = strUrl.substring(0, strUrl.indexOf(strMatch) + strMatch.length);
            
            strMatch = 'ContentBuilder/DisplayPage/';
            var strPage = strUrl.substring(strUrl.indexOf(strMatch) + strMatch.length);
            var strDomain = strUrl.substring(0, strUrl.indexOf(strMatch));
            strUrl = strDomain + strPage;
            
			if (parent.document.forms[0] != null)
            {
                if(sizcombval != "")
                {
                    parent.document.forms[0].action = strUrl + "/Shopping/shopping/" + svlTableId + "/" + uniqhidden.value +"/" + txtQuantity +"/" + sizcombval;
                }
                else
                {
                    parent.document.forms[0].action = strUrl + "/Shopping/shopping/" + svlTableId + "/" + uniqhidden.value +"/" + txtQuantity;
                }
				parent.document.forms[0].submit();
            }
            else
            {
                if(sizcombval != "")
                {
    			    window.parent.location.href = strUrl + "/Shopping/shopping/" + svlTableId + "/" + uniqhidden.value +"/" + txtQuantity +"/" + sizcombval;
    			}
    			else
    			{
    			    window.parent.location.href = strUrl + "/Shopping/shopping/" + svlTableId + "/" + uniqhidden.value +"/" + txtQuantity; 
    			}    
            }			
			bvlClicked = true
		}
		if (uniqhidden.value == '' || parseFloat(uniqhidden.value) <= 0)
		{
		    alert("Quantity can't be less than 0");
		    return false;
		}
	}
	//End Prodcuts

//Contentbuilder Login Template Javascripts
	 function EnterKeyLogin()
	    {
		 var btnName = "Submit";
		 if (Reg == 4)
		 {
		     document.onkeypress = function KeypressHandler()
		     {
			if (window.event.keyCode==13)
			    {
					 document.getElementById("RegImage").click();
				    }
			    }
		 }
		 else if (Reg == 3)
		 {
		     document.onkeypress = function KeypressHandler()
		      {
				   if (window.event.keyCode==13)
				    {
				       document.getElementById("SubmitImage").click();
				    }
				}
			}
			else
			{
			  for(var i=0;i<=document.all.length-1;i++)
		  {
		     if (document.all.item(i).id.substring(0,6)==btnName)
		     {
		      document.onkeypress = function KeypressHandler()
		       {
				    if (window.event.keyCode==13)
				    {
				       document.getElementById("SubmitImage").click();
				    }
				  }
			    }
			  }
		    }
	     }
	     function Pass(i)
	     {
	       Reg = i;
	    }
	    function Focus()
	    {
		var btnName = "txtUserName";
		for(var i=0;i<=document.all.length-1;i++)
		    {
		    if (document.all.item(i).id.substring(0,12)==btnName)
		    {
			document.getElementById('txtUserName').focus();
		    }
		}
	    }   

//End


//Adjust aspx page screen width and height
        var iframeids=["myframe"]

        //Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
        var iframehide="yes"

        var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
        var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

        function resizeCaller()
        {
        var dyniframe=new Array()
        for (i=0; i<iframeids.length; i++){
        if (document.getElementById)
        resizeIframe(iframeids[i])
        //reveal iframe for lower end browsers? (see var above):
        if ((document.all || document.getElementById) && iframehide=="no"){
        var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
        tempobj.style.display="block"
        }
        }
        }

        function resizeIframe(frameid)
        {
        var currentfr=document.getElementById(frameid)
        if (currentfr && !window.opera){
        currentfr.style.display="block"
        if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
        currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
        else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
        currentfr.height = currentfr.Document.body.scrollHeight;
        if (currentfr.addEventListener)
        currentfr.addEventListener("load", readjustIframe, false)
        else if (currentfr.attachEvent){
        currentfr.detachEvent("onload", readjustIframe) // Bug fix line
        currentfr.attachEvent("onload", readjustIframe)
        }
        }
        }

        function readjustIframe(loadevt) {
        var crossevt=(window.event)? event : loadevt
        var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
        if (iframeroot)
        resizeIframe(iframeroot.id);
        }

        function loadintoIframe(iframeid, url){
        if (document.getElementById)
        document.getElementById(iframeid).src=url
        }

        if (window.addEventListener)
        window.addEventListener("load", resizeCaller, false)
        else if (window.attachEvent)
        window.attachEvent("onload", resizeCaller)
        else
        window.onload=resizeCaller

//End

//Add BookMark
	function addBookmark(title,url)

	{if (window.sidebar) { window.sidebar.addPanel(title, url,"");
	 } 

	else if( document.all ) 
	{window.external.AddFavorite( url, title);
	}

	 else if( window.opera && window.print )
	 {return true;}
	}
//End

//Script for View images in New popup window        
    function MM_openBrWindow(theURL,winName,features) 
    { 
        window.open(theURL,winName,features);
    }
//end
    
//Script for Swap images
    <!--
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }

    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }

    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    
function Loginclear()
{
    document.frmpaylogin.txtEmpname.value="";
	document.frmpaylogin.txtEmpname.focus();
	return false;
}	
function Loginvalid()
{
    if(document.frmpaylogin.txtEmpname.value.replace(/^\s*|\s*$/g,"") == "")
    {
        alert('Please Enter the PPS Number');
        document.frmpaylogin.txtEmpname.focus();
        return false;
    }
    else
    {
        return true;
    }
    
}
function onMouseChange(id,file)
     {
      var v = document.getElementById(id);
      v.src =file;
      }

function Validate()
		{
			
			if (document.frmSave.txtTemplateName.value == "")
			{	
				alert("Please enter the Template Name");		
				return false;
			}
					
			if(document.frmSave.txtTemplateLocation.value == "")
			{
				alert("Please select Template Location");		
				return false;
			}
			if(document.frmSave.txtBulletImgLocation.value == "")
			{
			   alert("Please select Bullet Image Location");		
				return false;
			}			
			else
			    return true;
			
			
		}	
		function val()
		{
		    if(document.frmadd.txtTemplateName.value=="")
		    {
		        alert("Please enter the Template Name");
		        return false;
		    }
		    else
		        return true;    
		     
		}
function ShowPopupWindow(URL,Title)
{
	var ivlWidth = screen.width - 500
	var ivlHeight = screen.height - 110
	var ivlTop=(screen.height-ivlHeight)/2 - 25;
	var ivlLeft=(screen.width-ivlWidth)/2;
	var sFeatures ="height=" + ivlHeight + ", width=" + ivlWidth + ", left=" + ivlLeft + ", top=" + ivlTop + ",scrollbars=0, status=0,resizable=yes" ;
	window.open(URL,Title,sFeatures);
}

function ConverDateUStoUK(strDate)
{
	var arrDate;
	var stDate=strDate;
		
	if(strDate.indexOf("/")!=-1)
	{
		arrDate=strDate.split("/");		
	}
	else if(stDate.indexOf("-")!=-1)
	{
		arrDate=strDate.split("-");
	}
	else
	{
		alert("Check date format");
	}
	return (arrDate[1]+ "-" + arrDate[0] + "-" + arrDate[2]);
}

function ShowEditor(urlValue) {
var ivlWidth = 755;
	var ivlHeight =550;
	var ivlTop=(screen.height-ivlHeight)/2 - 25;
	var ivlLeft=(screen.width-ivlWidth)/2;
	var sFeatures ="height=" + ivlHeight + ", width=" + ivlWidth + ", left=" + ivlLeft + ", top=" + ivlTop + ",scrollbars=0, status=0,resizable=yes" ;
	window.open(urlValue,"Editor",sFeatures);
}
function Validate()
		{
			
			if (document.frmSave.txtTemplateName.value == "")
			{	
				alert("Please enter the Template Name");		
				return false;
			}
			else if(document.frmSave.txtTemplateLocation.value == "")
			{
				alert("Please select Template Location");		
				return false;
			}
			else if(document.frmSave.txtBulletImgLocation.value=="")
			{
			   alert("Please select Bullet Image Location");		
				return false;
			}
			else
			    return true;
			
			
		}	

function filldata()
	{
		
		
		if(document.frmFileUpload.hideEventId.value=="TempLoc")
	    { 
			
			window.opener.document.all.txtTemplateLocation.value=document.frmFileUpload.hideFileName.value;
			
			window.open("ShowAttachments.aspx?IMGURL="+document.frmFileUpload.hideImgLoc.value,null,'top=300, left=300, height=250, width=500,status= no, resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no');
			window.close();
		}
		else
		{
		    
			window.opener.document.all.txtBulletImgLocation.value =document.frmFileUpload.hideFileName.value;
			
			window.close();
		}
	}

function open_markers(type)
{
    
    var ivlWidth = 755;
	var ivlHeight =550;
	var ivlTop=(screen.height-ivlHeight)/2 - 25;
	var ivlLeft=(screen.width-ivlWidth)/2;
	var sFeatures ="height=" + ivlHeight + ", width=" + ivlWidth + ", left=" + ivlLeft + ", top=" + ivlTop + ",scrollbars=0, status=0,resizable=yes" ;
	
    if((type=="Page")||(type=="Ebook"))
        window.open("./PageMarkers.aspx","Markers",sFeatures);
       else if(type=="Shopping")
            window,open("./ShoppingMarkers.aspx","Markers",sFeatures);
       else if(type=="Business")
            window,open("BusinessMarkers.aspx","Markers",sFeatures);
       else if(type=="Product")
            window,open("ProductMarkers.aspx","Markers",sFeatures);
       else if(type=="Form")
            window,open("FormMarkers.aspx","Markers",sFeatures);
       else 
            window,open("EmailMarkers.aspx","Markers",sFeatures);
}

function del()
{
	if(confirm("Do you want to remove the template?"))
	    return false;
	else 
		return true;
}	

function expand() 
{
	window.moveTo(0,0);
	window.resizeTo(screen.availWidth, screen.availHeight);
}

function hide()
{
   for(var i=0;i<=document.all.length-1;i++)
	{
		if (document.all.item(i).id.substring(0,3)=="fly")
    		document.all.item(i).style.display='none';
					
		if (document.all.item(i).id.substring(0,3)=="img")
			document.all.item(i).src='../Images/plus.gif';
					
					
	}
			
}


function BrValidate()
{
    if (document.getElementById('txtTempname').value == "")
	{	
		alert("Please select the Template Name.");	
		document.getElementById('txtTempname').focus();	
		return false;
	}
	else if (document.getElementById('txtPageName').value == "")
	{
	   alert("Please enter the Page Name.");	
	   document.getElementById('txtPageName').focus();	
	   return false;
	}
	else if (document.getElementById('txtRangefrom').value != "" && document.getElementById('txtRangeto').value != "")
	{
	    if(parseInt(document.getElementById('txtRangefrom').value) > parseInt(document.getElementById('txtRangeto').value))
	    {
	        alert("Please enter the correct range.");	
	        document.getElementById('txtRangefrom').focus();	
	        return false;
	    }
	}
	if (document.getElementById('hdnSave'))
	    document.getElementById('hdnSave').value ='yes';
	
	return true;
}	

function FoValidate()
{
    if(document.getElementById('txtname').value == "")
    {
        alert("Please enter the Folder Name.");
        return false;
    }
    else
    {
        return true;
    }
}

function AddValidate()
{
    if(document.getElementById('Fid').value == "")
    {
        alert("Cannot add under this node,select its parent to add");
        return false;
    }
    else
    {
        return true;
    }
}

function ModifyValidate()
{
    if(document.getElementById('txtModifyname').value == "")
    {
        alert("Please enter the Folder Name.");
        return false;
    }
    else
    {
        return true;
    }
}

function delet()
{
	if(confirm("Do you want to remove the template?"))
	    return false;
	else 
		return true;
}	
function ToolBarLocationChange()
{
    var pval = document.getElementById('DropToolLocation').options[document.getElementById('DropToolLocation').selectedIndex].value ;
    var svlToolBarContent = ""
    pval="txt" + pval;
    document.getElementById('DropSelectTool').selectedIndex = 0;
    for(i=0;i<document.getElementById('DropSelectTool').length;i++) 
    {
	    svlToolBarContent=document.getElementById(pval).value;
	    var ddlObj=document.getElementById('DropSelectTool');
	    if(ddlObj[i].value==svlToolBarContent)
	    {
	        document.getElementById('DropSelectTool').selectedIndex=i;
	    }
    }
}

function ToolBarchange()
{
	var id;
	id=document.getElementById('DropToolLocation').selectedIndex+1;
	//alert(document.getElementById('DropSelectTool').options[document.getElementById('DropSelectTool').selectedIndex].value);
	document.getElementById('txtToolBar'+ id).value=document.getElementById('DropSelectTool').options[document.getElementById('DropSelectTool').selectedIndex].value;
	
}

function ShowPreviewScreen(svlMode,svlDataId,svlTempId,svlMod,svlTool1,svlTool2,svlTool3,svlTool4,svlList1,svlList2,svlList3,svlList4,svlList5,svlList6)
{
    if(BrValidate())
    {
        var svlTooll1=document.getElementById('txtToolBar1').value;
        var svlTooll2=document.getElementById('txtToolBar2').value;
        var svlTooll3=document.getElementById('txtToolBar3').value;
        var svlTooll4=document.getElementById('txtToolBar4').value;
        
        var svlList1=document.getElementById('txtList1').value;
        var svlList2=document.getElementById('txtList2').value;
        var svlList3=document.getElementById('txtList3').value;
        var svlList4=document.getElementById('txtList4').value;
        var svlList5=document.getElementById('txtList5').value;
        var svlList6=document.getElementById('txtList6').value;        
        var aspxpage = document.getElementById('txtFilename').value;        
        
        var svlProducts;
        svlProducts = document.getElementById('hdnProduct1').value + "$" +  document.getElementById('hdnCategory1').value + "$" + document.getElementById('hdnViewtype1').value +",";        
        svlProducts += document.getElementById('hdnProduct2').value + "$" +  document.getElementById('hdnCategory2').value + "$" + document.getElementById('hdnViewtype2').value +",";        
        svlProducts += document.getElementById('hdnProduct3').value + "$" +  document.getElementById('hdnCategory3').value + "$" + document.getElementById('hdnViewtype3').value +",";        
        svlProducts += document.getElementById('hdnProduct4').value + "$" +  document.getElementById('hdnCategory4').value + "$" + document.getElementById('hdnViewtype4').value +",";        
        svlProducts += document.getElementById('hdnProduct5').value + "$" +  document.getElementById('hdnCategory4').value + "$" + document.getElementById('hdnViewtype5').value +",";        
        svlProducts += document.getElementById('hdnProduct6').value + "$" +  document.getElementById('hdnCategory6').value + "$" + document.getElementById('hdnViewtype6').value +",";        
        
        var svlProductBrand = document.getElementById('ddlBrand').value; 
        var bvlOffer = document.getElementById('chkOffers').checked;
        var rangeFrom = document.getElementById('txtRangefrom').value; 
        var rangeTo = document.getElementById('txtRangeto').value;
        var bvlNew = document.getElementById('chkNewProducts').checked;        
        
        window.open("PreviewPage.aspx?Mode=" + svlMode + "&Tempid=" + svlTempId + "&Mod1 = " + svlMod  + "&Tool1=" + svlTooll1 + "&Tool2=" + svlTooll2 + "&Tool3=" + svlTooll3 + "&Tool4=" + svlTooll4 +"&List1=" + svlList1 + "&List2=" + svlList2 + "&List3=" + svlList3 + "&List4=" + svlList4 +"&List5=" + svlList5 + "&List6=" + svlList6 +"&aspxpage="+ aspxpage +"&Products="+ svlProducts +"&ProductBrand="+ svlProductBrand +"&ProductOffer="+ bvlOffer +"&RangeFrom="+ rangeFrom +"&RangeTo="+ rangeTo +"&NewProduct="+ bvlNew +"&DataId=" + svlDataId + "&view=&CurPage=1&Start=0",'','scrollbars=1,resizable=1,status=0,center=1,left=0, top=0;');        
        return false;
    }
   
}

function Listchange()
{
    var id;
   
	var ddlvalue=document.getElementById("DropSelectList").value;
	var len;
	len = ddlvalue.substring(4,5);
	document.getElementById('txtList'+ len).value=document.getElementById('DropListName').options[document.getElementById('DropListName').selectedIndex].value;
}

function ListLocationChange()
{
    //alert("List");
    var pval = document.getElementById('DropSelectList').options[document.getElementById('DropSelectList').selectedIndex].value ;
    var svlListContent = ""
    
    pval="txt" + pval;
    //alert (pval);
    document.getElementById('DropListName').selectedIndex = 0;
    for(i=0;i<document.getElementById('DropListName').length;i++) 
    {
	    svlListContent=document.getElementById(pval).value;
	    var ddlObj=document.getElementById('DropListName');
//	    alert(svlListContent);
//	    alert(ddlObj[i].value);
	    if(ddlObj[i].value==svlListContent)
	    {
	        document.getElementById('DropListName').selectedIndex=i;
	    }
    }
}

// Menu Bar Display Coding
function expand(idval)
{
var mnu=0;
for(mnu=0;mnu<10;mnu++)
{
if(document.getElementById("sub"+mnu)!=null && document.getElementById("sub"+mnu).id==idval)
{
if(document.getElementById(idval).style.display == "inline")
    document.getElementById(idval).style.display = "none";
else
    document.getElementById(idval).style.display="inline";

}
else if(document.getElementById("sub"+mnu)!=null)
document.getElementById("sub"+mnu).style.display="none";
}
}
		
function collapse(idval)
{
    var mnu=0;
    for(mnu=0;mnu<10;mnu++)
    {
   if(document.getElementById("sub"+mnu)!=null && document.getElementById("sub"+mnu)!=idval)
	document.getElementById("sub"+mnu).style.display="none";
   }
}
// skin window
function ShowNewJob(url)
{
	var windowW=400; // wide
	var windowH=200; // high
	var windowX = (screen.width/2)-(windowW/2);
	var windowY = (screen.height/2)-(windowH/2);
	var sFeatures = "height=" + windowH + ", width=" + windowW + ", left=" + windowX + ", top=" + windowY + "; status=no; toolbar=no; menubar=no; scrollbars=0" 	
	window.open(url,"Menu",sFeatures);
}

function scrollMsg(myMsg) 
{
			window.status = myMsg.substring(i,myMsg.length) + myMsg.substring(0,i-1)
			if (i < myMsg.length) 
			{
				i++
			}
			else
			{
				i = 0
			}
			setTimeout("scrollMsg()",100)
}
