<!-- The below javascript allows us to utilize a Safari only stylesheet -->
	var detect = navigator.userAgent.toLowerCase();
	if (checkIt('safari')){
		document.write('<link rel="stylesheet" type="text/css" href="../styles/safari-only.css" media="screen" />');
}
function checkIt(string){
	var place = detect.indexOf(string) + 1;
	return place;
}
/****************************************/
/* validation functions					*/
/****************************************/
/*function validateSearch(f)
{
	// need to add the select list to this validation

	if(isStringWhitespace(f.freeTextCriteria.value)){
		f.freeTextCriteria.focus();
		alert("Please enter Search Type");
		return false; }
	
	if(isStringWhitespace(f.search.value)){
		f.search.focus();
		alert("Please Enter Something to Search");
		return false;}
}*/

var whitespace = " \t\n\r";

function isEmpty(s){   
	return ((s == null) || (s.length == 0));
}

function isStringWhitespace(s){   
	var i;

	if (isEmpty(s)) return true;
	for (i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if (whitespace.indexOf(c) == -1) return false;
	}
	return true;
}

function IsNumeric(sText)
{
	//var ValidChars = "0123456789 \b\t\n\r";
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;

		for (i = 0; i < sText.length && IsNumber == true; i++) 
		{ 
			Char = sText.charAt(i); 
			if (ValidChars.indexOf(Char) == -1) 
			{
				IsNumber = false;
			}
		}
	return IsNumber;
}// end function 

function IsPhoneNumber(sText)
{
	var ValidChars = "0123456789-() \b\t\n\r";
	var IsNumber=true;
	var Char;

		for (i = 0; i < sText.length && IsNumber == true; i++) 
		{ 
			Char = sText.charAt(i); 
			if (ValidChars.indexOf(Char) == -1) 
			{
				IsNumber = false;
			}
		}
	return IsNumber;
}// end function 
// used to validate the search input
function validateSearch(f)
{
	errorMsg = "Enter the following required fields:\n";
	isError = false;

	if(isStringWhitespace(f.search.value)){
		isError = true;
		errorMsg += "Please Enter Something to Search\n"; }

	/*if(isStringWhitespace(f.freeTextCriteria.value)){
		isError = true;
		errorMsg += "Please enter Search Type\n"; }*/

	if(isError){
		alert(errorMsg);
		return false; }
}// end function validateSearch

/****************************************/
/* process tree functions				*/
/****************************************/
var curPath;
curPath = "";

function showthisData(pElem)
{
	//alert(pElem);
	var currentElem = pElem;
	//alert(currentElem);


	if( document.getElementById('pm_' + currentElem) != null ){
		if (document.getElementById(currentElem).style.display == 'none')
		{	
			document.getElementById('pm_' + currentElem).innerHTML =  "<img src=\"" + minusImg.src + "\" />";
			document.getElementById(currentElem).style.display = "block";
		}else{
			document.getElementById('pm_' + currentElem).innerHTML = "<img src=\"" + plusImg.src + "\" />";
			document.getElementById(currentElem).style.display = "none";
		}// end else
	}// end if
}// end function

function showRegionData(pElem)
{
	//alert(pElem);
	var currentElem = pElem;
	//alert(currentElem);


	if( document.getElementById(currentElem) != null ){
		if (document.getElementById(currentElem).style.display == 'none')
		{
			//document.getElementById(currentElem).innerHTML =  "<img src=\"" + minusImg.src + "\" />";
			document.getElementById(currentElem).style.display = "block";				
		}else{
			//document.getElementById(currentElem).innerHTML = "<img src=\"" + plusImg.src + "\" />";
			document.getElementById(currentElem).style.display = "none";			
		}// end else
	}// end if	
}// end function

function initProcessTree()
{
	//document.getElementById('pm_2002').innerHTML = "<img src=\"" + minusImg.src + "\" />";
	//document.getElementById('2002').style.display = "block";
	//document.getElementById('pm_2003').innerHTML = "<img src=\"" + minusImg.src + "\" />";
	//document.getElementById('2003').style.display = "block";
	//document.getElementById('pm_2004').innerHTML = "<img src=\"" + minusImg.src + "\" />";
	//document.getElementById('2004').style.display = "block";
	//document.getElementById('pm_2000086').innerHTML = "<img src=\"" + minusImg.src + "\" />";
	//document.getElementById('2000086').style.display = "block";
}// end fucntion initProcessTree

/****************************************/
/* open window functions				*/
/****************************************/
function goPrint(pID)
{
	page = "print.asp?id=" + pID;
	name = "supplier";
	
	window.open("print.asp?id=" + pID,"Window1", "menubar=no,width=600,height=600,toolbar=yes, scrollbars=yes, resizable=yes");
}

function openWindow(pID)
{

	page = "image.asp?id=" + pID;
	name = "supplier";
	
	window.open("image.asp?id=" + pID,"Window1", "menubar=no,width=430,height=360,toolbar=no, scrollbars=yes, resizable=yes");
}

function openWin(page,name,width,height,scroll,resize){
	window.open(page,name,"toolbar=0,location=0,status=0,menubar=0,scrollbars=" + scroll + ",resizable=" + resize + ",top=0,left=0,width=" + width + ",height=" + height)
}

var sHeight = screen.height;
var sWidth = screen.width;
		
function getDescription(pID){
	//pID = 928
	window.open("description.asp?id=" + pID,"Window1", "menubar=no,width=430,height=360,toolbar=no, scrollbars=yes, resizable=yes");
}// end getDescription function
/****************************************/
/* validate register functions			*/
/****************************************/
function checkThisForm(f)
{
	strCompanyname = f.companyName.value;
	strUsername = f.email.value;
	strPass1 = f.password.value;
	strPass2 = f.password2.value;

	if(strCompanyname.length < 1){
		f.companyName.focus();
		alert("Please enter your Company Name.");
		return false; }

	if(strUsername.length < 1){
		f.email.focus();
		alert("Please enter your Email Address.");
		return false; }
	
	if(strPass1.length < 1){
		f.password.focus();
		alert("Please enter a Password.");
		return false; }

	if(strPass2.length < 1){
		f.password2.focus();
		alert("Please re-enter your password.");
		return false; }

	if(strPass1 != strPass2){
		f.password.focus();
		alert("Your Passwords do not match.");
		return false; }		
}// end function
/****************************************/
/* get X & Y functions					*/
/****************************************/
// returns X pos of id passed 
function getRealLeft(el){
	xPos = document.getElementById(el).offsetLeft;
	tempEl = document.getElementById(el).offsetParent;
	while (tempEl != null) {
	xPos += tempEl.offsetLeft;
	tempEl = tempEl.offsetParent;
	}
	return xPos;
}
// returns Y pos of id passed
function getRealTop(el){
	yPos = document.getElementById(el).offsetTop;
	tempEl = document.getElementById(el).offsetParent;
	while (tempEl != null) {
	yPos += tempEl.offsetTop;
	tempEl = tempEl.offsetParent;
	}
	return yPos;
}
/****************************************/
/* validate user register functions			*/
/****************************************/
//Email Validation
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function checkThisRegForm(f)
{
	strCompanyname = f.companyName.value;
	strUsername = f.email.value;
	strPass1 = f.password.value;
	strPass2 = f.password2.value;
	strfullname = f.fullname.value;
	strUsername1 = f.emailconfirm.value;
	strCountryname = f.country.value;
	strlastname = f.lastname.value;
	
	if(strfullname.length < 1){
		f.fullname.focus();
		alert("Please enter your First Name.");
		return false; }

if(strlastname.length < 1){
		f.lastname.focus();
		alert("Please enter your Last Name.");
		return false; }



	if(strCompanyname.length < 1){
		f.companyName.focus();
		alert("Please enter your Company Name.");
		return false; }

	if(strUsername.length < 1){
		f.email.focus();
		alert("Please enter your Email Address.");
		return false; }	

	if(!echeck(strUsername) && !echeck(strUsername1)){
		f.email.focus();		
		alert("Invalid E-mail ID."); 	
		return false; }

	if(strUsername1 != strUsername){
		f.email.focus();
		alert("your Email Addresses do not match.");
		return false; }
	
	
	if(strPass1.length < 1){
		f.password.focus();
		alert("Please enter a Password.");
		return false; }

	if(strPass2.length < 1){
		f.password2.focus();
		alert("Please re-enter your password.");
		return false; }

	if(strPass1 != strPass2){
		f.password.focus();
		alert("Your Passwords do not match.");
		return false; }	
	if(strCountryname  == ""){
		f.country.focus();
		alert("Please select a country name.");
		return false; }	
	
	
	
}// end function

function show(cid,x,y){	
	xpos = x;
	ytop = y;
	obj = document.getElementById(cid);
	obj.style.left = xpos + "px";
	obj.style.top = ytop + "px";
 	obj.style.marginLeft = "45px";
	obj.style.marginTop = "-10px";
	obj.style.display = "";
	}

	function hide(cid){
	obj = document.getElementById(cid);
	obj.style.display = "none";
	}
function showcur(cid,posx,posy){
obj = document.getElementById(cid);
obj.style.position = "absolute";
obj.style.display = "";
obj.style.left = posx;
obj.style.top = posy;
obj.style.zindex = "50";
}

function hidecur(cid){
obj = document.getElementById(cid);
obj.style.display = "none";
}
