 
function SetUrl(link) 
{ 
eval('document.' + getcookie('ffbform') + '.' + getcookie('ffbfield') + '.value = link');
//txtBox = document.getElementById('file1'); 
//txtBox.value=link; 
} 
 
function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function getcookie(cookiename) {
 var cookiestring=""+document.cookie;
 var index1=cookiestring.indexOf(cookiename);
 if (index1==-1 || cookiename=="") return ""; 
 var index2=cookiestring.indexOf(';',index1);
 if (index2==-1) index2=cookiestring.length; 
 return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}

function fileBrowser(xformname, xfieldname) { 
SetCookie('ffbform', xformname);
SetCookie('ffbfield', xfieldname);
URL ='/fckeditor/editor/filemanager/browser/default/browser.html?Connector=/globalscripts/FCKeditor/editor/filemanager/connectors/asp/connector.asp&Command=GetFolders&Type=Images&CurrentFolder=/images&basepath=/globalscripts/FCKeditor/&xformname=/'+ xformname +'&xfieldname=/'+ xfieldname; 
//URL ='/fckeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/asp/connector.asp&Command=GetFolders&Type=Images&CurrentFolder=/images&xformname=/'+ xformname +'&xfieldname=/'+ xfieldname; 
Mypopup = open(URL, 'browserpopup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=300');
} 

function SetSwatch(xsource, xtarget) { 
    var xcolor = document.getElementById(xsource).value;
    document.getElementById(xtarget).style.background = xcolor; 
//	alert('Color of '+ xtarget + ' set to '+ xcolor);
} 

function setButton(buttonValue) 
{ 
    document.EditNLForm.buttonChoice.value = buttonValue; 
    document.EditNLForm.submit();
} 

function setAdButton(buttonValue) 
{ 
    document.EditAdForm.buttonChoice.value = buttonValue; 
    document.EditAdForm.submit();
} 

function ConfirmCustomize(pagearea, buttonValue) 
{ 
	//alert('Pagearea: '+ pagearea + ' buttonValue: '+ buttonValue);

var agree=confirm('This page currently uses the website default '+ pagearea +'. Do you want to customize the '+ pagearea +' for this page?');
if (agree)
	{
    document.EditNLForm.buttonChoice.value = buttonValue;
    document.EditNLForm.submit();
	}
else
	return false ;
} 

function ConfirmCustomizeContent(pagearea, buttonValue) 
{ 
	//alert('Pagearea: '+ pagearea + ' buttonValue: '+ buttonValue);

var agree=confirm('This page currently uses the website default design for the Main Content area. Do you want to customize the Main Content area design for this page?');
if (agree)
	{
    document.EditNLForm.buttonChoice.value = buttonValue;
    document.EditNLForm.submit();
	}
else
	return false ;
} 

function ConfirmCustomizeLayout(pagearea, buttonValue) 
{ 
	//alert('Pagearea: '+ pagearea + ' buttonValue: '+ buttonValue);

var agree=confirm('This page currently uses the website default design for the page layout. Do you want to customize the page layout design for this page?');
if (agree)
	{
    document.EditNLForm.buttonChoice.value = buttonValue;
    document.EditNLForm.submit();
	}
else
	return false ;
} 

function toggleChecked(oElement) 
{ 
  oForm = oElement.form; 
  oElement = oForm.elements[oElement.name]; 
  if(oElement.length) 
  { 
    bChecked = oElement[0].checked; 
    for(i = 1; i < oElement.length; i++) 
      oElement[i].checked = bChecked; 
  } 
} 

function toggleIndeterminate(oElement) 
{ 
  oForm = oElement.form; 
  oElement = oForm.elements[oElement.name]; 
  if(oElement.length) 
  { 
    bIndeterminate = false; 
    bChecked = true; 
    nChecked = 0; 
    for(i = 1; i < oElement.length; i++) 
      if(oElement[i].checked) 
        nChecked++; 
    if(nChecked < oElement.length - 1) 
    { 
      if(nChecked) 
        bIndeterminate = true; 
      else 
      { 
        bIndeterminate = false; 
        bChecked = false; 
      } 
    } 
    else 
    { 
      bIndeterminate = false; 
    } 
    oElement[0].indeterminate = bIndeterminate; 
    oElement[0].checked = bChecked; 
  } 
}

function AlertDeleteEmail(AlertDeleteEmailCount) 
{ 

if (AlertDeleteEmailCount == 0)
	{
	alert('Deleted email accounts will be disabled and all associated email message will be deleted from the server');
	AlertDeleteEmailCount = 1
	};
} 


function dopopup(url, windowname, properties)
{
    mywindow = window.open(url,windowname,properties);
}




function validateFormOnSubmit(theForm) {
var reasonEmpty = "";
var reasonEmail = "";
var reason = "";


 for (var i=0;i< eval(theForm).length;i++){
  if (eval(theForm).elements[i].name.indexOf('_valfilled_') != -1 ){
	reasonEmpty += validateEmpty(eval(theForm).elements[i]);
   }
  if (eval(theForm).elements[i].name.indexOf('_valemail_') != -1 ){
	reasonEmail += validateEmail(eval(theForm).elements[i]);
  }
 }
      
  if (reasonEmpty != "") {
    reason = "One or more required fields was left blank" + "\n";
  }
  if (reasonEmail != "") {
    reason += "The email address that you entered is not valid";
  }
  if (reason != "") {
    alert("The highlighted fields need to be corrected:"+ "\n" + reason + "\n" );
    return false;
  }


  return true;
}

function validateEmpty(fld) {
    var error = "";
  
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "The required field has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;   
}

function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
} 

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
    
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = 'Yellow';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = 'Yellow';
        error = "The email address contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}

function hidediv(sectiondiv) { 
  document.getElementById(sectiondiv).style.display = 'none'; 
  document.getElementById(sectiondiv).style.visibility='hidden'; 
}

function showdiv(sectiondiv) { 
  document.getElementById(sectiondiv).style.display = 'block'; 
  document.getElementById(sectiondiv).style.visibility='visible'; 
}

// This is the function that will open the
// new window when the mouse is moved over the link
function open_popup_window(windowsource) 
{
  new_window = open("","hoverwindow","width=300,height=200,left=10,top=10");
  
  // open new document 
  new_window.document.open();
  
  // Text of the new document
  // Replace your " with ' or \" or your document.write statements will fail
  new_window.document.write(windowsource);
  
  // close the document
  new_window.document.close(); 
}

// This is the function that will close the
// new window when the mouse is moved off the link
function close_popup_window() 
{
  new_window.close();
}
