var RotateImageCount = 0;
var searchbox = false;
/*
var imgURLs =new Array(); 

imgURLs[0]= new Image(739,273);
imgURLs[0].src ="images/Rotate_Images/Plexpack_Rotating images_APX_S.jpg";

imgURLs[1]= new Image(739,273);
imgURLs[1].src="images/Rotate_Images/Plexpack_Rotating images_B34-90.jpg";

imgURLs[2]= new Image(739,273);
imgURLs[2].src="images/Rotate_Images/Plexpack_Rotating images_MPS6140.jpg";

imgURLs[3]= new Image(739,273);
imgURLs[3].src="images/Rotate_Images/Plexpack_Rotating images_MPS7500.jpg";
*/

var imgURLs_1033 =new Array(); 

imgURLs_1033[0]= new Image(739,273);
imgURLs_1033[0].src ="images/Rotate_Images_1033/Plexpack_Rotating images_APX_S.jpg";

imgURLs_1033[1]= new Image(739,273);
imgURLs_1033[1].src="images/Rotate_Images_1033/Plexpack_Rotating images_B34-90.jpg";

imgURLs_1033[2]= new Image(739,273);
imgURLs_1033[2].src="images/Rotate_Images_1033/Plexpack_Rotating images_MPS6140.jpg";

imgURLs_1033[3]= new Image(739,273);
imgURLs_1033[3].src="images/Rotate_Images_1033/Plexpack_Rotating images_MPS7500.jpg";


var imgURLs_3082 =new Array(); 

imgURLs_3082[0]= new Image(739,273);
imgURLs_3082[0].src ="images/Rotate_Images_3082/Plexpack_Rotating images_APX_S.jpg";

imgURLs_3082[1]= new Image(739,273);
imgURLs_3082[1].src="images/Rotate_Images_3082/Plexpack_Rotating images_B34-90.jpg";

imgURLs_3082[2]= new Image(739,273);
imgURLs_3082[2].src="images/Rotate_Images_3082/Plexpack_Rotating images_MPS6140.jpg";

imgURLs_3082[3]= new Image(739,273);
imgURLs_3082[3].src="images/Rotate_Images_3082/Plexpack_Rotating images_MPS7500.jpg";


function PopUpWindow(url, iW, iH) {
  popupWin = window.open(url,'new_page','width=' + iW + ',height=' + iH + ' scrollbars=yes')
}

function ShowDetail(vID) {

	var strURL = '/DocPlus.asp?intDocID=' + vID;
    PopUpWindow(strURL, 400, 300);
}

function getObj(objID)
		{
			if(document.getElementById){return document.getElementById(objID);}
			else if(document.all){return document.all[objID];}
			else if(document.layers){return document.layers[objID];}
		}

function getLength(str)
   {
      while (str.substr(str.length-1)==" ") 
	  {
         str = str.substring(0,str.length-1);
      }
      while (str.substr(0,1)==" ") {
         str = str.substring(1,str.length);
      }
      return str.length;
   }

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_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_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 MM_jumpMenu(targ,selObj,restore)
  { //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
   }

function MM_GoMenu(targ,selObjID,restore)
  { //v3.0
    var selObj = getObj(selObjID);
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
   }

/*
function RotateImage()
{
   var imgObj = getObj('imgRotateImage');
   
  
   RotateImageCount++;

   if (RotateImageCount > 4)
   {
	   RotateImageCount = 1;
   }

   if (imgObj != null)
   {
	   imgObj.src  = imgURLs[RotateImageCount - 1].src;
   }

   setTimeout("RotateImage()",6000);

}
*/

function RotateImage_1033()
{
   var imgObj = getObj('imgRotateImage');
   
  
   RotateImageCount++;

   if (RotateImageCount > 4)
   {
	   RotateImageCount = 1;
   }

   if (imgObj != null)
   {
	   imgObj.src  = imgURLs_1033[RotateImageCount - 1].src;
   }

   setTimeout("RotateImage()",6000);

}

function RotateImage_3082()
{
   var imgObj = getObj('imgRotateImage');
   
  
   RotateImageCount++;

   if (RotateImageCount > 4)
   {
	   RotateImageCount = 1;
   }

   if (imgObj != null)
   {
	   imgObj.src  = imgURLs_3082[RotateImageCount - 1].src;
   }

   setTimeout("RotateImage_3082()",6000);

}


function StartRotateImage()
{
   setTimeout("RotateImage()",6000);
}

function StartRotateImage_1033()
{
   setTimeout("RotateImage_1033()",6000);
}

function StartRotateImage_3082()
{
   setTimeout("RotateImage_3082()",6000);
}

function ShowSearch()
{
    var sboxobj = getObj('DivSearchBox');
	var sTextObj = getObj('searchtext');
	var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	  }
 
	if (sboxobj != null && sTextObj != null )
	{
		if (searchbox)
		{
            sboxobj.style.display = "none";
            sboxobj.style.visibility = "hidden";
            sboxobj.style.left =  (400 + (myWidth - 752) / 2) + "px"; 
			searchbox = false;
			sTextObj.focus();
		}
		else
			{
            sboxobj.style.display = "block";
            sboxobj.style.visibility = "visible";
			sboxobj.style.left =  (400 + (myWidth - 752) / 2) + "px"; 
			searchbox = true;
			sTextObj.focus();
		}

	}
}

function valid_day_month_year( strDay, strMonth, strYear )
	{
	
		// does the day value match up with permitted day values for the month?
	
		switch ( strMonth )
		{
			case "01":
					if ( strDay < "01" || strDay > "31" )
					{
						return false;
					}
					break;
			case "02":
					if ( strDay < "01" || strDay > "28" )
					{
						return false;
					}
					break;
			case "03":
					if ( strDay < "01" || strDay > "31" )
					{
						return false;
					}
					break;
			case "04":
					if ( strDay < "01" || strDay > "30" )
					{
						return false;
					}
					break;
			case "05":
					if ( strDay < "01" || strDay > "31" )
					{
						return false;
					}
					break;
			case "06":
					if ( strDay < "01" || strDay > "30" )
					{
						return false;
					}
					break;
			case "07":
					if ( strDay < "01" || strDay > "31" )
					{
						return false;
					}
					break;
			case "08":
					if ( strDay < "01" || strDay > "31" )
					{
						return false;
					}
					break;
			case "09":
					if ( strDay < "01" || strDay > "30" )
					{
						return false;
					}
					break;
			case "10":
					if ( strDay < "01" || strDay > "31" )
					{
						return false;
					}
					break;
			case "11":
					if ( strDay < "01" || strDay > "30" )
					{
						return false;
					}
					break;
			case "12":
					if ( strDay < "01" || strDay > "31" )
					{
						return false;
					}
					break;
			default:
					return false;
					break;
		}
		
		// the month, day combination was acceptable, but is the year >= the current year?
	
		strCurrentDate = new Date();
		var strCurrentYear = strCurrentDate.getYear();
	
		if ( strYear < strCurrentYear )
		{
			return false;
		}
	
		return true;
	
	}

/*

	Function:		valid_date( strDate, strMask )
	Description:	This function checks the submitted date for validity and returns
					true if the date is valid.  Returns false otherwise.
	Parameters:		strDate -> the date being checked for validity
					strMask -> date mask used in validity check

*/

	function valid_date( strDate, strMask )
	{
		switch ( strMask )
		{
			case "mm/dd/yyyy":
					// was a date entered?
					if ( !not_empty(strDate) || !not_blank(strDate) )
					{
						return false;
					}
					else
					{
						// date was entered, is it of the proper length?
						if ( strDate.length != 10 )
						{
							return false;						
						}
						else
						{
							// the entered date is of the proper length, but is it of the proper format?
							var strMonth = strDate.substring(0,2);
							var strDay = strDate.substring(3,5);
							var strYear = strDate.substring(6,10);
							var strFirstSlash = strDate.substring(2,3);
							var strSecondSlash = strDate.substring(5,6);
							
							if ( !is_numeric(strMonth) || !is_numeric(strDay) || !is_numeric(strYear) || ( strFirstSlash != "/" ) || ( strSecondSlash != "/" ) || !valid_day_month_year( strDay, strMonth, strYear  ) )
							{
								return false;
							}
						}					
					}
					break;
			case "dd/mm/yyyy":
					alert("dd/mm/yyyy");
					break;
			case "mmddyyyy":
					alert("mmddyyyy");
					break;
			case "ddmmyyyy":
					break;
			case "mm/dd/yy":
					break;
			default:
					break;		
		}
		
		return true;
	}

/* 
	Function:		radio_index( radio_group, num_buttons )
	Description:	This function returns the index of the checked radio button in a
					radio button group.  If no button is selected the function returns
					-1.
	Parameters:		radio_group -> the radio group form object
					num_buttons -> integer number of buttons in the radio button group
*/

	function radio_index( radio_group, num_buttons )
	{
		for ( counter = 0; counter < num_buttons; counter++ )
		{
			if ( radio_group[counter].checked )
			{
				return counter;
			}		
		}
	
		return -1;
	}

/* 
	Function:		is_numeric(strToBeChecked)
	Description:	This function cycles through a string and determines if it 
					contains any non-numeric characters.  If the string contains
					non-numeric characters, the function returns false, otherwise
					it returns true.	
	Parameters:		strToBeChecked ->	the string being analyzed for non-numeric
										characters
*/

	function is_numeric(strToBeChecked)
	{
			var digits="0123456789"
			var temp
			
			// cycle through the string one character at a time
	
			for (var counter = 0; counter < strToBeChecked.length; counter++)
			{
				temp=strToBeChecked.substring(counter, counter+1)

				// is the temp character contained within the digits string?
				
				if (digits.indexOf(temp)==-1)
				{
					return false;					
				}
			}
			
			return true;
	}
	
/*
	Function:		not_empty(strToBeChecked)
	Description:	This functions checks to see if the length of a string is > 0.
					If the string has a length greater than zero, the function
					returns true, otherwise it returns false.
	Parameters:		strToBeChecked -> the string being analyzed
*/

	function not_empty(strToBeChecked)
	{
		// check to see if the length is 0
		
		if ( strToBeChecked.length == 0 )
		{
			return false;
		}
	
		return true;
	}

/*
	Function:		not_blank(strToBeChecked)
	Description:	This functions checks to see if any of the characters of 
					a string are not blanks.  If at least one of the characters
					of the string is not a blank, the function returns true. If
					not, the function returns false.
	Parameters:		strToBeChecked -> the string being analyzed
*/

	function not_blank(strToBeChecked)
	{
		// check to see if all of the characters are " "
		
		for ( var counter = 0; counter < strToBeChecked.length; counter++ )
		{
			temp = strToBeChecked.substring(counter, counter+1);
		
			if ( temp != " " )
			{
				return true;
			}
		}
		
		return false;
	}
	
/*
	Function:		valid_email(strEmail)
	Description:	This functions checks to see if the submitted email address
					is of the proper format.  If the email address is valid, the
					function returns true, otherwise it returns false.
	Parameters:		strEmail -> the email address to be validated
*/

	function valid_email(strEmail)
	{
		// did the user enter a email number?

		if ( not_empty(strEmail) && not_blank(strEmail) )
		{
			// is the entered email address of the proper format?
			// must be x@x.x
			
			var intEmailAddressLength = strEmail.length;
		
			// an email address must be at least 5 characters in length
		
			if ( intEmailAddressLength < 5 )
			{
				alert("Please enter a valid Email Address.");
				return false;		
			}
			
			// check for the location of the @ in the email address
			
			var intAt = strEmail.indexOf("@");
			
			// the @ cannot be in the first position nor the last
			
			if ( intAt < 1 || intAt > ( intEmailAddressLength - 4 ) )
			{
				alert("Please enter a valid Email Address.");
				return false;
			}
			
			// pull out the mail server portion of the email address
			
			var strMailServer = strEmail.substring(intAt + 1, intEmailAddressLength);
			
			// check for the location of the . in the mail server portion of the email address
			
			var intPeriod = strMailServer.indexOf(".");			
			
			// the . cannot be in the first position nor the last
						
			if ( intPeriod < 1 || intPeriod == ( strMailServer.length - 1 ) )
			{
				alert("Please enter a valid email address.");
				return false;
			}
			
			return true;
		}
	
		alert("Please enter a valid Email Address.");
		return false;
	}

/*
	Function:		valid_phone(strPhone)
	Description:	This functions validates a phone number.  The phone number
					must be of one of the following three formats:
					(xxx) xxx-xxxx
					(xxx)xxx-xxxx
					xxx-xxx-xxxx
					If the phone number is valid, the function returns true,
					otherwise it returns false.  After the numeric portion, the
					user may enter any string of characters ( e.g. extension ).
	Parameters:		strPhone -> the phone number being analyzed
*/	
	
	function valid_phone(strPhone)
	{
		// did the user enter a phone number?

		if ( !not_empty(strPhone) || !not_blank(strPhone) )
		{
			alert("Please enter a valid Phone number.");
			return false;
		}

		// is the phone number of proper format?
		// (xxx) xxx-xxxx or (xxx)xxx-xxxx or xxx-xxx-xxxx
		
//		if ( strPhone.substring(0,1) == "(" && is_numeric(strPhone.substring(1,4)) && strPhone.substring(4,5) == ")" )
//		{
//			if ( strPhone.substring(5,6) == " " && is_numeric(strPhone.substring(6,9)) && strPhone.substring(9,10) == "-" && is_numeric(strPhone.substring(10,14)) )
//			{
//				return true;
//			}
//			
//			if ( is_numeric(strPhone.substring(5,8)) && strPhone.substring(8,9) == "-" && is_numeric(strPhone.substring(9,13)) )
//			{
//				return true;
//			}
//		}
//		else
//		{
//			if ( is_numeric(strPhone.substring(0,3)) && strPhone.substring(3,4) == "-" && is_numeric(strPhone.substring(4,7)) && strPhone.substring(7,8) == "-" && is_numeric(strPhone.substring(8,12)) )
//			{
//				return true;
//			}		
//		}
//		
//		alert("Please enter a valid Phone number.");
		return true;	
	}

/*
	Function:		valid_fax(strFax)
	Description:	This functions validates a fax number.  The fax number
					must be of one of the following three formats:
					(xxx) xxx-xxxx
					(xxx)xxx-xxxx
					xxx-xxx-xxxx
					If the fax number is valid, the function returns true,
					otherwise it returns false. 
	Parameters:		strFax -> the fax number being analyzed
*/	
	
	function valid_fax(strFax)
	{
		// did the user enter a fax number?

		if ( !not_empty(strFax) || !not_blank(strFax) )
		{
			alert("Please enter a valid Fax number.");
			return false;
		}

		// is the fax number of proper format?
		// (xxx) xxx-xxxx or (xxx)xxx-xxxx or xxx-xxx-xxxx
		
//		if ( strFax.substring(0,1) == "(" && is_numeric(strFax.substring(1,4)) && strFax.substring(4,5) == ")" )
//		{
//			if ( strFax.substring(5,6) == " " && is_numeric(strFax.substring(6,9)) && strFax.substring(9,10) == "-" && is_numeric(strFax.substring(10,14)) )
//			{
//				return true;
//			}
//			
//			if ( is_numeric(strFax.substring(5,8)) && strFax.substring(8,9) == "-" && is_numeric(strFax.substring(9,13)) )
//			{
//				return true;
//			}
//		}
//		else
//		{
//			if ( is_numeric(strFax.substring(0,3)) && strFax.substring(3,4) == "-" && is_numeric(strFax.substring(4,7)) && strFax.substring(7,8) == "-" && is_numeric(strFax.substring(8,12)) )
//			{
//				return true;
//			}		
//		}
//		
//		alert("Please enter a valid Fax number.");
		return true;	
	}


function validate_form_gq ()
	{
	        var objFName = getObj('FirstName');
		var objLName = getObj('LastName');
		var objCompany = getObj('Company');
		var objPhone = getObj('PhoneNumber');
		var objEmail = getObj('EmailAddress');


		// check the first name
		if (objFName != null )
		if ( !not_empty(objFName.value) || !not_blank(objFName.value) )
		{
			alert("Please enter your first name.");
			objFName.focus();
			return false;
		}

		// check the last name
                if (objLName != null )
		if ( !not_empty(objLName.value) || !not_blank(objLName.value) )
		{
			alert("Please enter your last name.");
			objLName.focus();
			return false;
		}

		// check the company
                if (objCompany != null ) 
		if ( !not_empty(objCompany.value) || !not_blank(objCompany.value) )
		{
			alert("Please enter your company name.");
			objCompany.focus();
			return false;
		}

		 

		// check the Phone
                if (objPhone != null ) 
		if ( !not_empty(objPhone.value) || !not_blank(objPhone.value) )
		{
			alert("Please enter your phone number.");
			objPhone.focus();
			return false;
		}

		 

		// check the email address 
                if (objEmail != null )
		if ( !not_empty(objEmail.value) || !not_blank(objEmail.value) )
		{
			alert("Please enter your email address.");
			objEmail.focus();
			return false;
		}
		else
		{
			// is the email address of the proper format?
			if ( !valid_email(objEmail.value) )
			{
				objEmail.focus();
				return false;
			}
		}

		return true;
	}
