//  Application:   SQPS_v02_02_03 - portal implementation
//	common.jsp - common javascript functions 


// JavaScript Document
		function openWindow(url) {
			var strFeatures = "resizable,width=500,height=570,location=off,menubar=off,scrollbars,toolbar=off,";
			
			if (document.all) {
				strFeatures += "left=100,top=50";
			} else {
				strFeatures += "screenX=100,screenY=50";
			}
			dwin=window.open(url,"help",strFeatures);
			dwin.focus();
		}

		function openFeedback(url) {
			var strFeatures = "resizable,width=500,height=570,location=off,menubar=off,scrollbars,toolbar=off,";
			
			if (document.all) {
				strFeatures += "left=100,top=50";
			} else {
				strFeatures += "screenX=100,screenY=50";
			}
			dwin=window.open(url,"Feedback",strFeatures);
			dwin.focus();
		}

		function openTracking(url) {
			var strFeatures = "resizable,width=700,height=480,location=off,menubar=off,scrollbars,toolbar,";
			if (document.all) {
				strFeatures += "left=100,top=50";
			} else {
				strFeatures += "screenX=100,screenY=50";
			}
			dwin=window.open(url,"tracking",strFeatures);
			dwin.focus();
		}

		function openPrint(url) {
			var strFeatures = "resizable,width=600,height=570,location=off,menubar,scrollbars,toolbar=off,";
			
			if (document.all) {
				strFeatures += "left=100,top=50";
			} else {
				strFeatures += "screenX=100,screenY=50";
			}
			dwin=window.open(url,"print",strFeatures);
			dwin.focus();
		}

// verify compare products on view list from
function verifyForm( form, max_number, one_item_text, max_item_text )
{
	var iChecked = 0 ;
	if (!form.ITEMLIST.length)
	{
		if (!form.ITEMLIST.checked) 
		{
			alert( one_item_text) ;
			return false;
		} else {
			//return true;
			form.submit();
		}
	} else {
			for( var i = 0 ; i < form.ITEMLIST.length ; i++ )
			{
				if( form.ITEMLIST[i].checked )
					iChecked++ ;
			
				if( iChecked > max_number )
				{
					alert( max_item_text + " " + max_number  ) ;
					return false ;
				}
			}
			if( iChecked < 1 )
			{
				alert( one_item_text ) ;
				return false ;
			}	
			//return true ;
			form.submit();
	}
}

// verify keyword search string for minimum number of characters in string
/*function CheckData(form,error_msg, minchar)

{
      var strAlertMessage = error_msg;

i=0;
	var string = form.SRCH.value;
	// remove the wildcard character before checking for minimum length
	string = string.replace(/\*///g,'');
	//form.SRCH.value = string
//	if (string.length < minchar)
//	{	
//		alert(strAlertMessage);
//		return false;
//	}
//	else 
//	{
//		return true;
//	}
//}*/


// verify keyword search string specific for numeric ZIP code
function CheckData(form, error_msg, error_msg1, error_msg2, minchar, maxchar)

{
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;
   var strString = form.SRCH.value;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);

      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
	if (blnResult == false)
	{
		alert(error_msg2);
		return false;
	}

	if (strString.length == 0) 
	{
	   alert(error_msg1);
	   return false;
	}

   if (parseInt(strString.length) < parseInt(minchar)) 
	{
	   alert(error_msg);
	   return false;
	}

   if (parseInt(strString.length) > parseInt(maxchar)) 
	{
	   alert(error_msg);
	   return false;
	}


	return true;
}


// reload frame if text size is changed in the browser
var defaultfontsize = 0
function getFontSize() {
	if (document.defaultView && document.defaultView.getComputedStyle) {
		return parseInt(document.defaultView.getComputedStyle(document.body,'').getPropertyValue("font-size"))
	}
	else if (document.all && document.body.currentStyle) {

		return parseInt(document.body.currentStyle.fontSize)
	}
}
function check() {
	var currentsize = getFontSize()

	if (currentsize != defaultfontsize) {
		//alert ("fontsize change default=" + defaultfontsize + "current size= " + currentsize)
	
	window.document.location.reload(false);
	//document.location.reload();
	}
	defaultfontsize = currentsize

}
function checkfontsize() {
	var theInterval = 500
	if ((document.defaultView && document.defaultView.getComputedStyle) || (document.all && document.body.currentStyle)) {
		defaultfontsize = getFontSize()
		// only do font checking on production servers
		if (document.location.hostname != 'dallas02'){
			setInterval("check()",theInterval)
		}
	}
//	else {
//		alert ("document.defaultView and document.body.currentStyle are not supported")
//	}
}


function validateZip( help)
		{
			var Number = document.form2.zip.value;
			var GoodChars = "0123456789"
			var i = 0

			for (i =0; i <= Number.length -1; i++)
			{
				if (GoodChars.indexOf(Number.charAt(i)) == -1)
				{
				alert(help);
				return false
				} // End if statement
			} // End for loop
			if ( Number.length < 5)
			{
				alert(help);
				return false;
			}
			return true
		}


