


/**
 * Library of Javascript functions used throughout the site. All
 * functions prefixed by "MM" are MacroMedia functions generated
 * by UltraDev and were not authored by New Atlanta Communications, 
 * personnel.
 *
 * @author Robert Taylor
 * @author last modified by $Author: rtaylor $ 
 * @version $Revision: 1.1 $  $Date: 2004/07/30 21:25:49 $
 */


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 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_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}

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_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

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_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
// -->
function openReceiptWindow(orderId) {
	var url = "/c/store/showStoreOrderReceipt?orderId=" + orderId;
	var w = window.open(url, "smallwin", "width=700,height=600,resizable=yes,scrollbars=yes,menubar=yes,status=yes");
	
	return;
}

function openIISManageWindow() {
	var w = window.open("/partners/esri/IISManage.jsp", "iisManage", "width=800,height=450,resizable=yes,scrollbars=yes,menubar=yes,status=yes");
	
	return;
}

function openVerisignWindow() {
	var w = window.open("https://digitalid.verisign.com/as2/5a6b7de3898b119bc3a9c833d69e4375", "iisManage", "width=700,height=800,resizable=yes,scrollbars=yes,menubar=yes,status=yes");
	return;
}

function openCVVInfo() {
	var w = window.open("/c/store/cvvInfo", "cvv", "width=520,height=720,resizable=yes,scrollbars=yes,menubar=no,status=yes");

}

function printPage() {

  if (window.print) {
  
    window.print();
	
  } else {
  
	alert("Sorry, your browser doesn't support this feature.");
	
  }
  
}

/**
 * This method assumes that the specified parameter
 * is an select options array.
 *
 * It also assumes that the first selection is the
 * default selection which means no selection.
 *
 * It therefore checks values 1 through n to 
 * see if a selection has been made.
 *
 * @param options the select options array
 * @return true if a selection other than the default
 * selection has been made, else return false.
 */
function isSelected(options, defaultFlag) {
	
	var found = false;
	
	if (options != null && options.length != null) {
		
		for (var i = 1; i < options.length && !found; i++) {
			
			found = options[i].selected == true;
			//alert("option[" + i + "]=" + options[i].selected);
			
		}
	
	}
	
	return found;
}
/**
 * Validation for the ServletExec feature request
 * form.
 */
function verifySEFRForm (f)
{

   var name          = f.elements[0].value;
   var email         = f.elements[1].value;
   var organization  = f.elements[2].value;
   var productConfig = f.elements[3].options;
   var os            = f.elements[6].options;
   var otherOS       = f.elements[7].value;
   var desc          = f.elements[8].value;
   var intention     = f.elements[9].value;
   var webServer     = f.elements[4].options;
   var webServerVer  = f.elements[5].value;
   var osSelected  = "false";
  
   if (name == null || name == "" || name == "1")
   {
      alert ("Please enter your name.");
      return false;

   }
   if (email == null || email == "")
   {

      alert ("Please enter your email address.");
      return false;
   }
   else 
   {
      var pos = email.indexOf (".");
      if (pos == -1)
      {
          alert ("Please enter the proper email address.");
          return false;
      }
   }
   
   if (organization == null || organization == "") {
   
   	alert("Please enter organization.");
	return false;
   
   }
      
   if (!isSelected(productConfig)) {
   
   		alert("Please select a ServletExec version.");
		return false;
   
   }
   
   if (!isSelected(webServer)) {
   
   	alert("Please select a web server.");
	return false;
   
   }
   
   //if (webServerVer == null || webServerVer == "") {
   //
   //	alert("Please enter web server version.");
   //	return false;
   // 
   //}
   
   if ((!isSelected(os)) && (otherOS == null || otherOS == "")) {
   
   	alert("Please select or enter an operating system.");
	return false;
   
   } 
      

   if (desc == null || desc  == "")
   {
       alert ("Please enter the description field.");
       return false;
   }
   
   if (intention == null || intention  == "")
   {
       alert ("Please enter your intentions for this feature.");
       return false;
   }

}


/**
 * Validation for the JTurbo feature request
 * form.
 */
function verifyJTFRForm (f)
{

   var name          = f.elements[0].value;
   var email         = f.elements[1].value;
   var organization  = f.elements[2].value;
   var productConfig = f.elements[3].options;
   var os            = f.elements[5].options;
   var otherOS       = f.elements[6].value;
   var desc          = f.elements[7].value;
   var intention     = f.elements[8].value;
   var dbVersion     = f.elements[4].options;
  
   var osSelected  = "false";
 
 
  
  

   if (name == null || name == "" || name == "1")
   {
      alert ("Please enter your name.");
      return false;

   }
   if (email == null || email == "")
   {

      alert ("Please enter your email address.");
      return false;
   }
   else 
   {
      var pos = email.indexOf (".");
      if (pos == -1)
      {
          alert ("Please enter the proper email address.");
          return false;
      }
   }
   
   if (organization == null || organization == "") {
   
   	alert("Please enter organization.");
	return false;
   
   }
       
   if (!isSelected(productConfig)) {
   
   	alert("Please select JTurbo version.");
	return false;
   
   }
   
   
   if (!isSelected(dbVersion)) {
   
   	alert("Please select SQLServer version.");
	return false;
   
   }
     
   if ((!isSelected(os)) && (otherOS == null || otherOS == "")) {
   
   	alert("Please select or enter an operating system.");
	return false;
   
   } 
      

   if (desc == null || desc  == "")
   {
       alert ("Please enter the description field.");
       return false;
   }
   
   if (intention == null || intention  == "")
   {
       alert ("Please enter your intentions for this feature.");
       return false;
   }

}

/**
 * Validation for the BlueDragon feature request
 * form.
 */
function verifyBDFRForm (f)
{
	
   var name          = f.elements[0].value;
   var email         = f.elements[1].value;
   var organization  = f.elements[2].value;
   var productConfig = f.elements[3].options;
   var os            = f.elements[4].options;
   var otherOS       = f.elements[5].value;
   var desc          = f.elements[6].value;
   var intention     = f.elements[7].value;
  // var webServer     = f.elements[4].options;
   //var webServerVer  = f.elements[5].value;
   var osSelected  = "false";

   if (name == null || name == "" || name == "1")
   {
      alert ("Please enter your name.");
      return false;

   }
   if (email == null || email == "")
   {

      alert ("Please enter your email address.");
      return false;
   }
   else 
   {
      var pos = email.indexOf (".");
      if (pos == -1)
      {
          alert ("Please enter the proper email address.");
          return false;
      }
   }
   
   if (organization == null || organization == "") {
   
   	alert("Please enter organization.");
	return false;
   
   }
      
   //if (!isSelected(productConfig)) {
   //
   //		alert("Please select a BlueDragon version.");
   //	return false;
   //
   //}
   
  // if (!isSelected(webServer)) {
  // 
  // 	alert("Please select a web server.");
  // return false;
  // 
  // }
   
   //if (webServerVer == null || webServerVer == "") {
   //
   //	alert("Please enter web server version.");
   //	return false;
   // 
   //}
   
   if ((!isSelected(os)) && (otherOS == null || otherOS == "")) {
   
   	alert("Please select or enter an operating system.");
	return false;
   
   } 
      

   if (desc == null || desc  == "")
   {
       alert ("Please enter the description field.");
       return false;
   }
   
   if (intention == null || intention  == "")
   {
       alert ("Please enter your intentions for this feature.");
       return false;
   }
}

 	/**
	 * The parameter to this function should be a checkbox element
	 * from a form.
	 *
	 * A JavaScript checkbox may or may not be represented as an array.
	 * If there are multiple checkboxes with the same name,
	 * then JavaScript puts them into an array.
	 * If there is only one checkbox then an array is not used.
	 * This function can tell us how JavaScript is currently representing
	 * any given checkbox.
	 */
	function isCheckboxAnArray(checkboxElement)
	{
		return ! isNaN(parseInt(checkboxElement.length));
	}
	
 	function allSelected(checkboxElement)
	{
		var allChecked = true;
		
		if(isCheckboxAnArray(checkboxElement))
		{
			var foundOneUnchecked = false;
			for(var i=0; i<checkboxElement.length; i++)
			{
				if(checkboxElement[i].checked)
					continue;
				else
				{
					allChecked = false;
					break;
				}
			}
		}
		else
			allChecked = checkboxElement.checked;
			
		return allChecked;
	}
	
	/**
	 * The parameter to this function should be a checkbox element
	 * from a form.
	 */
	function anySelected(checkboxElement)
	{
		var foundOneChecked;
	
		if(isCheckboxAnArray(checkboxElement))
		{
			foundOneChecked = false;
			for(var i=0; i<checkboxElement.length; i++)
			{
				if(checkboxElement[i].checked)
				{
					foundOneChecked = true;
					break
				}
				else
					continue;
			}
		}
		else
			foundOneChecked = checkboxElement.checked
				
		return foundOneChecked;
	}
	
	/**
	 * The parameters to this function should be checkbox elements
	 * from a form.
	 */
	function setOthers(others, pivot)
	{
		if(isCheckboxAnArray(others))
		{
			for(var i=0; i<others.length; i++)
			{
				others[i].checked = pivot.checked;
			}
		}
		else
			others.checked = pivot.checked
	}
	
	function setPivot()
	{
		document.forms[0].switchAll.checked = allSelected(document.forms[0].faqCategoryIds);
	}
	
	/**
	* returns true if textElement contains any data, else false.
	*/
	function containsData(textElement)
	{
		return textElement.value.length > 0;
	}
	
	/**
	* Used when listing faq categories
	*/
	function validateForm(checkboxElement, textElement)
	{
		var doSubmit = containsData(textElement) || anySelected(checkboxElement);
		if(! doSubmit)
			alert("You must choose a category and/or enter a Search String.");
			
		return doSubmit;
	}
	
	/**
	* Used when listing faq product families (on the 1st page of the FAQ wizard)
	*/
	function validateCheckbox(checkboxElement)
	{
		var populated = anySelected(checkboxElement);
		if(!populated)
			alert("You must select at least one product family.");
		
		return populated;
	}

	/**
	 * Issue a javacript confirmation message regarding
	 * the cancel order command
	 */
	function confirmCancelOrder() {
	
		return confirm(
				"Cancelling your order will remove all order " +
				"information from your current session. \nAny " +
				"information which you have entered regarding " +
				"your current order will be lost. \n\n Are you " +
				"sure you want to cancel your order?");
	
	}

/** 
 * Pre load images before screen is displayed.
 */
MM_preloadImages('/images/nav/button_nav_home_f2.gif','/images/nav/button_nav_home_f3.gif','/images/nav/button_nav_store_f2.gif','/images/nav/button_nav_store_f3.gif',
'/images/nav/button_nav_products_f2.gif','/images/nav/button_nav_products_f3.gif','/images/nav/button_nav_support_f2.gif','/images/nav/button_nav_support_f3.gif',
'/images/nav/button_nav_corporate_f2.gif','/images/nav/button_nav_corporate_f3.gif','/images/nav/button_nav_partners_f2.gif','/images/nav/button_nav_partners_f3.gif');

/**
 * Javascript function used to prevent email harvesting.
 * Allows emails to be viewable and clickable in web browsers
 * but does not allow web bots to harvest them.
 *
 * Usage:
 *
 * <script>document.write(MailTo('myname','mydomain', 'true', 'mysubject'))</script>
 *
 *
 * @param ename the name preceding the '@'.
 * @param edomain the name following the '@'
 * @param clickable determines if the link will be text-only or clickable
 * @param esubject the subject of the email
 */
function MailTo( ename , edomain , esubject , clickable )  {
	thislink = "mailto:" + ename + "@" + edomain;
    esubject.length != 0 ? thislink += "?subject=" + esubject : thislink =  thislink;
 	thistext = ename + "@" + edomain;
 	if (clickable == 'true') {
 		return thistext.link(thislink)
 	} else {
 		return thistext;
 	}
 }
 
 /**
 * <code>goToUrl</code> utilizes the underlying
 * javascript method "window.location" to redirect
 * the user to the specified url.
 * 
 * @param url the destination url
 * @param pause the time in milliseconds to pause
 * before redirecting
 */
function goToUrl(url, pause) {

	if (pause == null || pause == '') {
	
		pause = 0;
	
	}
	var temp = "window.location = '" + url + "'";
	window.setTimeout(temp, pause);
	
}
