
// --------------------------------------------------------------- // ------------------------------------------------
//for cuteeditor
//array to hold all the editor ids as the page loads
var editors = new Array();

 
 // --------------------------------------------------------------- // ------------------------------------------------
/* formatting 
20090901
*/
var selectedEditor;
var selectedHdn;
var objID1;
var objID2;
var isArray1;
//set onload of cntrUserNav2
var NavViewRows = -1;

function fmtSetColor(xxxx,txtBx,oId1,oId2,hdnFld,forBk,isArr)
{
    var nvArr;
    if(isArr)
    {
        nvArr = MakeArray(oId1,oId2);
     }
     else
     {
        nvArr = oId1;
     }
     //function showColorGrid3(OBjElem,Sam,obj2,obj2Hdn,forBk, isArr)
    showColorGrid3('xxxx',txtBx,nvArr,hdnFld,forBk,isArr);
}
function fmtSetColorHdFr(xxxx,txtBx,tblId,td2,td4,hdnFld,clearCr)
{ 
    var Arr = new Array();
      Arr[0] = td2;   //line in header background - top
      Arr[1] = td4;  //line in header background - bottom
      Arr[2] = tblId; //border around Section Name table
    
    //set for SectionTable border only
    showColorGrid3('xxxx',txtBx,Arr,hdnFld,'Hd',true);
}
function fmtSetColorPgNm(xxxx,txtBx,tblId,cellId,hdnFld,isArr)
{ 
    var Arr = new Array();
      Arr[0] = cellId;   //line under page name
      Arr[1] = tblId; //border around Page table
    
    //Page table and , cell(line) under page name
    showColorGrid3('xxxx',txtBx,Arr,hdnFld,'PgNm',true);
}

function MakeArray(oId1,oId2)
{
       var Arr = new Array();
        //alert(NavViewRows);
        
        for(i=0; i < NavViewRows+2; i++) 
        { // this is on the nav control
            if(i<10){
                Arr[i] = oId1 + '0' + i + oId2;
             }
             else{
                Arr[i] = oId1 + i + oId2;
             }
           //alert(nvArr[i]); 
        } 
    return Arr;
}

function fmtInsertImage(edId,hdnId,oId1,oId2,isArr)  
{  
    selectedEditor = edId;
    selectedHdn = hdnId;
    objID1 = oId1;
    objID2 = oId2;
    isArray1 = isArr;
    
		var editor1 = document.getElementById(edId);
        editor1.FocusDocument();  
        var editdoc = editor1.GetDocument();  
        editor1.ExecCommand('new');
        editor1.ExecCommand('ImageGalleryByBrowsing');
        InputURL();
}    

function InputURL()
{ 
		var editor1 = document.getElementById(selectedEditor);
        var editdoc = editor1.GetDocument();  
        var imgs = editdoc.images;
         
        if(imgs.length>0)  
        {
            var url = imgs[imgs.length-1].src;
            document.getElementById(selectedHdn).value = url;
            
            editor1.ExecCommand('new');
           //alert('hidden field ' + selectedHdn + ' = ' + document.getElementById(selectedHdn).value);
            
            if(objID1 =='pnlMain1'){
                SetRepeat('pnlMain1');
            }
            else if(isArray1)
            {
                var Arr = MakeArray(objID1,objID2);
                 for(i=0; i < Arr.length+2; i++)
                {
                    if(document.getElementById(Arr[i])){document.getElementById(Arr[i]).style.backgroundImage = 'url(' + url + ')';} //no repeat
                }
            }
            else{
                document.getElementById(objID1).style.backgroundImage = 'url(' + url + ')'; //no repeat
            }
        }  
        else{
			setTimeout(InputURL,500); 
        }  
}       

function SetRepeat(obId)
{
   var ddl = document.getElementById('CntrFrmtBkgd1_1_ddlRep');
    var sValue = ddl.value;

    //set container vars
    var hdnContImgVal;
    var hdnContClrVal;
    if(document.getElementById('CntrFrmtBkgd1_1_hdnBkgdCntImg')){ 
        hdnContImgVal = document.getElementById('CntrFrmtBkgd1_1_hdnBkgdCntImg').value;
    
        if(document.getElementById('CntrFrmtBkgd1_1_hdnBkgdCntClr')){ 
            hdnContClrVal = document.getElementById('CntrFrmtBkgd1_1_hdnBkgdCntClr').value;
            
            if(document.getElementById(obId)){
                var ob1 = document.getElementById(obId);
                ob1.style.backgroundImage = 'url(' + hdnContImgVal + ')';
                ob1.style.backgroundColor = hdnContClrVal;
                ob1.style.backgroundRepeat = sValue;
            }
        }
    } 
}

function fmtClearColor(xxxx,txtBx,oId1,oId2,hdnFld,forBk,isArr)
{
    selectedHdn = hdnFld;
    document.getElementById(selectedHdn).value = 'none';
    document.getElementById(txtBx).style.backgroundColor = 'transparent';
    
    var Arr = new Array();
    if (isArr)
    {
       var Arr = MakeArray(oId1,oId2);
    }

    if(forBk == 'back')
    {
        if (isArr)
        {
            for(i=0; i < Arr.length+2; i++)
            {
                if(document.getElementById(Arr[i])){document.getElementById(Arr[i]).style.backgroundColor = 'transparent';}
            }
        }
        else
        {
            if(document.getElementById(oId1)){document.getElementById(oId1).style.backgroundColor = 'transparent';}
        }        
    }
    else if(foreBack == 'border')
    {
        if(document.getElementById(oId1)){document.getElementById(oId1).style.borderColor = 'transparent';}
    }
    else 
    {
        if(isArr)
        {
            for(i=0; i < Arr.length+2; i++)
            {
                if(document.getElementById(Arr[i])){document.getElementById(Arr[i]).style.color = 'transparent';}
            }
        }
        else
        {
            if(document.getElementById(oId1)){document.getElementById(oId1).style.color = 'transparent';}
        }
    }
}      

function fmtClearImage(hdnFld,oId1,oId2,isArr)
{
//alert(hdnFld);
    document.getElementById(hdnFld).value = 'Bkgd/Clear_Background.gif';

    var Arr = new Array();
     if (isArr)
    {
       var Arr = MakeArray(oId1,oId2);
       for(i=0; i < Arr.length+2; i++)
            {
                if(document.getElementById(Arr[i])){document.getElementById(Arr[i]).style.backgroundImage = 'url(Bkgd/Clear_Background.gif)';}
            }         
    }
    else
    {
        if(document.getElementById(oId1)){document.getElementById(oId1).style.backgroundImage = 'url(Bkgd/Clear_Background.gif)';}
    } 
}      
 
function fmtSetFont(ddl,hdnFld,oId1,oId2,isArr,fnObjIn,FnSzInId)
{
    var ddl1 = document.getElementById(ddl)
    var sFont = ddl1.value;
    //for the size
    var FnSzIn = '';
    if(document.getElementById(FnSzInId)) {FnSzIn = document.getElementById(FnSzInId).value;} //ddl size
    
    var Arr = new Array();
    if (isArr)
    {
       var Arr = MakeArray(oId1,oId2);
    }
    
    if (isArr)  //nav only 
    {
        for(i=0; i < Arr.length+2; i++)
        {
            if(document.getElementById(Arr[i])){document.getElementById(Arr[i]).style.fontFamily = sFont;}
        }
    }
    else
    {
        if(document.getElementById(oId1)){
            document.getElementById(oId1).style.fontFamily = sFont;
            document.getElementById(oId1).style.fontSize = GetFnSz(fnObjIn, document.getElementById(oId1).style.fontFamily, FnSzIn);
         }
    }
    
    //nav only 
    if(oId1 == 'NavHead' || oId1 == 'Nav2c1_dgridNav_ctl')
    {
        fmtSetFontSzNv();
    }
}
function fmtSetFontSzNv()
{
   var ddl1 = document.getElementById('CntrFrmtNav1_1_ddlSize')
    var sFontSzIn = ddl1.value;
    
    var Arr = new Array();
    Arr = MakeArray('Nav2c1_dgridNav_ctl','_hlinkNav');
    
        for(i=0; i < Arr.length+2; i++)
        {
            if(document.getElementById(Arr[i])){document.getElementById(Arr[i]).style.fontSize = GetFnSz('grBd',document.getElementById(Arr[i]).style.fontFamily,sFontSzIn);}
        }

        if(document.getElementById('NavHead')){document.getElementById('NavHead').style.fontSize = GetFnSz('grHd',document.getElementById('NavHead').style.fontFamily,sFontSzIn);}
      
}
function fmtSetFontSz(ddl1,objId,hdnId,objIndicator)
{
    var ddl = ddl1;
    var hdn = document.getElementById(hdnId);
    var obj = document.getElementById(objId);
    var sFontSzIn = ddl.value;
   // alert(sFontSzIn);
    
    if(hdn){hdn.value = sFontSzIn;}
    var FnSz = GetFnSz(objIndicator, obj.style.fontFamily, sFontSzIn);

    if(obj){obj.style.fontSize = FnSz;}
      
}

function GetFnSz(objIndicator, family, FnSzIn)
{
/*         	upTxHdFnSz = 14;  //default
            upPgNmFnSz = 13; //default
			upTxBdFnSz = 10;  //default
			upTxFnSz = 9;  //default
			upGdHdFnSz = 9;  //default
*/
var retVal = '';
    switch(objIndicator)
    {
    case 'PgNm':
        var upPgNmFnSz = 13;
    
        if (family == "Verdana")
        {
            upPgNmFnSz += 1;
        }
        if(family=="Times New Roman"  || family=="Comic Sans MS" ||  family=="Poor Richard")
        {		
            upPgNmFnSz += 1;
        }
        else if(family=="Brush Script MT" || family=="Andy" || family=="Ransom" || family=="Bauhaus 93")
        {
            upPgNmFnSz += 2;
        }
        //Adjust for selected size
        if(FnSzIn == "larger")
        {
             upPgNmFnSz += 1;   
        }
        else if(FnSzIn == "largest")
        {
             upPgNmFnSz += 2;  
        }
        
    retVal = upPgNmFnSz + 'pt'; 
	break;
	
    case 'grHd':
        var upGdHdFnSz = 9;
    
        if(family=="Times New Roman"  || family=="Comic Sans MS" ||  family=="Poor Richard")
        {		
            upGdHdFnSz += 1;
        }
        else if(family=="Brush Script MT" || family=="Andy" || family=="Ransom" || family=="Bauhaus 93")
        {
            upGdHdFnSz += 2;
        }
        //Adjust for selected size
        if(FnSzIn == "larger")
        {
             upGdHdFnSz += 1;   
        }
        else if(FnSzIn == "largest")
        {
             upGdHdFnSz += 2;  
        }
        
    retVal = upGdHdFnSz + 'pt'; 
	break;
	
	case 'grBd':
	    var upTxFnSz = 9;
	    
	    if(family=="Verdana" )
        {		
            upTxFnSz -= 1;
        }
        if(family=="Times New Roman" || family=="Comic Sans MS" ||  family=="Poor Richard" )
        {		
            upTxFnSz += 1;
        }
        else if(family=="Brush Script MT" || family=="Andy" || family=="Ransom" || family=="Bauhaus 93")
        {
            upTxFnSz += 3;
        }
        //Adjust for selected size
        if(FnSzIn == "larger")
        {
           upTxFnSz += 1; 
        }
        else if(FnSzIn == "largest")
        {
            upTxFnSz += 2; 
        }
    retVal = upTxFnSz + 'pt'; 
	break;
	}	
	 return retVal;	
}

function DDlApply(ddl)
{
    var ddlv;
    if(document.getElementById(ddl.id))
    {
        ddlv = document.getElementById(ddl.id)
       // alert(ddl.value);
        if(ddlv.value == 'site' )
        {
         alert('NOTE! Style changes will affect ALL PAGES on Your Site when you click the Save Button.');
         }
    }
}




                 
// ------------------------------------------------------------- // --------------------------------------------------
//Picture Pop-up window
var myWind2 = null  
function newWindow(theURL)
	{
		var features = "scrollbars=yes,menubar=yes,resize=yes,width=660px,height=500px";
		var winName = "picWindow";
		
		// if window not open then open
		CloseMyWind2();
		
		//new window
		 myWind2 = window.open(theURL,winName,features);
	}
	function CloseMyWind2()
	{
		if(myWind2 != null)
		{
			if(!myWind2.closed) {
			//close existing, then open new
			myWind2.close();
			}
		}
	}
	
// --------------------------------------------------------------- // ------------------------------------------------
//Pop-up window
var myWind2a = null;
function newWind2a(theURL, features)
	{
		var winName = "picWindowa";
		
		// if window not open then open
		CloseMyWind2a();

		//new window
		 myWind2a = window.open(theURL,winName,features);
		 myWind2a.focus();
	}

	function CloseMyWind2a()
	{
		if(myWind2a != null)
		{
			if(!myWind2a.closed) {
			//close existing, then open new
			myWind2a.close();
			}
		}
	}

// --------------------------------------------------------------- // ------------------------------------------------
//check delete
		function CheckDelete(index,cntrId)
		{
			var a = window.confirm("Are you sure you want to delete this item?");
			if(a == true)
			{
				//form1.submit;
				var theform = document.frmPg;
				theform.deleteItem.value = index;
				theform.cntrId.value = cntrId;				
				theform.submit();
			}			
		}

// --------------------------------------------------------------- // ------------------------------------------------
//help guides
var myWind4 = null;
function HelpHtm(theURL)
	{
		var features = "scrollbars=yes,menubar=yes,resize=yes,width=650px,height=500px";
		var winName = "hlpWindow";
		
		// if window not open then open
		CloseMyWind4();
		
		//new window
		 myWind4 = window.open(theURL,winName,features);
	}
	
	function CloseMyWind4()
	{
		if(myWind4 != null)
		{
			if(!myWind4.closed) {
			//close existing, then open new
			myWind4.close();
			}
		}
	}

