var ndx = 0;
var x = "";


/***************
Browser data used when handling the menu nav especailly... but globally available.
*****************/

function BrowserData(){
	agent  = navigator.userAgent.toLowerCase();
					
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
			
	/* detection for netscape Browsers */
	this.ns    = ((agent.indexOf('mozilla')   !=   -1) && 
				 ((agent.indexOf('spoofer')   ==   -1) && 
				 (agent.indexOf('compatible') ==   -1)));
	this.ns4   = (this.ns && (this.major      ==    4));
	this.ns6   = (this.ns && (this.major      >=    5));
	this.dom = (document.getElementsByTagName && !document.all);
	//alert(this.ns4);alert(this.ns6);alert(this.dom);
	/* detection for ie Browsers */
	this.ie    = (agent.indexOf("msie")       !=   -1);
	this.ie3   = (this.ie && (this.major      < 4));
	this.ie4   = (this.ie && (this.major      ==    4) && 
	             (agent.indexOf("msie 5.0")   ==   -1));
			             
	this.ie5 = (document.getElementById && document.all);             
	this.ie50   = (this.ie && (this.major      ==    4) && 
	             (agent.indexOf("msie 5.0")   !=   -1));
	this.ie55  = (this.ie && (this.major      ==    4) && 
	             (agent.indexOf("msie 5.5")   !=   -1));
			
	this.ie6   = (this.ie && (agent.indexOf("msie 6.0") != -1) );
			
	this.ie5Mac = ((agent.indexOf("mac") != -1) && this.ie5);
			
	/* detection for aol ie browsers */
	this.aol = (agent.indexOf("aol") != -1);
	this.aol3 = (this.aol && this.ie3);
	this.aol4 = (this.aol && this.ie4);
	this.aol5 = (this.aol && this.ie5);
}

//instantiate the new browser data the gets used in most of the nav functions
oBD = new BrowserData();


function gotoPage()
{
	//alert(goto.arguments.length);
	try{
		if (gotoPage.arguments.length == 2)
			self.location.href="/us/pph_index.asp";
		else
			self.location.href="/us/index.asp";
			
	}catch(e){
		alert("Unable to load the page. Please try again.");
	}
}

function gotoNavContent(linkURL, currentSubNavItem)
{
	try{
		if(linkURL.length > 0){
			//alert(linkURL);
			top.location.href=linkURL;
		}else{
		}
	}
	catch(e)
	{
		alert(e.description);
	}
		
}



function FrontPage_Form1_Validator(theForm)
{

  if (trimAll(theForm.Name.value) == "")
  {
    alert("Please tell us your name.");
    theForm.Name.focus();
    return (false);
  }


  if (trimAll(theForm.Title.value) == "")
  {
    alert("Please tell us your title.");
    theForm.Title.focus();
    return (false);
  }

  if (trimAll(theForm.Company.value) == "")
  {
    alert("Please tell us what company you work for.");
    theForm.Company.focus();
    return (false);
  }

  if (trimAll(theForm.Phone.value) == "")
  {
    alert("Please tell us your phone number");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Phone.value.length < 7)
  {
    alert("Please enter a complete phone number.");
    theForm.Phone.focus();
    return (false);
  }

  if (trimAll(theForm.Email.value) == "")
  {
    alert("Please tell us your e-mail address");
    theForm.Email.focus();
    return (false);
  }

  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
  if (!filter.test(theForm.Email.value)){
	alert("Please enter a valid e-mail address.")
	return (false);
  }
  return (true);
}

function trimAll(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function showRollOverImg(which,imgWidth, imgHt)
{
//	alert(which);
//	alert(imgWidth);
//	alert(imgHt);
	
	try{
		var tNailTD = document.getElementById("tdThumbNail");	
		if(imgHt==null || imgHt=="")
			imgHt=0;
		if(imgWidth==null || imgWidth=="")
			imgWidth=0;
		if(tNailTD!=null){
			tNailTD.innerHTML = "<img src='/images/portfolio/"+which+"' width='"+imgWidth+"' height='"+imgHt+"' vspace='6'>";
		}
//		alert(tNailTD.innerHTML )
	}
	catch(e){
		alert(e.descrption);
	}
}

function showBigImg(which, width, height)
{
	//the width and height are deprecated as we do not use em anymore..
	//popUpWin("/images/portfolio/print/"+which+"_full.jpg",width,height);
	
	//create the image URL.. and send it as a param to asp
	//the javascript inside that page does the rest
	var picURL= "/images/portfolio/"+which;
	window.open ("showBigImg.asp?picUrl="+picURL,"_popUp", "resizable=0,width=600, height=600");
}

function switchOnOffNavItems(which, bOn)
{

	var whichid = which.id;
	try{
		if(bOn)
			which.setAttribute("src","/images/navigation/"+whichid+"_on.gif");
		else
			which.setAttribute("src","/images/navigation/"+whichid+".gif");
	}catch(e){}

}
/*
function popUpWin(url)
{
	var strURL = url;
	if(popUpWin.arguments.length == 3){
		
		alert(popUpWin.arguments[1]);
		alert(popUpWin.arguments[2]);
		if(popUpWin.arguments[1]!="")
			windowW = popUpWin.arguments[1];
		if(popUpWin.arguments[2]!="")
			windowH = popUpWin.arguments[2];
		
		try{
			var iMyWidth;
			var iMyHeight;
			//gets top and left positions based on user's resolution so hint window is centered.
			iMyWidth = (window.screen.width/2) - (windowW/2); //half the screen width minus half the new window width (plus 5 pixel borders).
			iMyHeight = (window.screen.height/2) - (windowH/2); //half the screen height minus half the new window height (plus title and status bars).
			
			alert(windowH);
			alert(windowW);
			windowH += .18*windowH;
			windowW += .14*windowW;
			alert(windowH);
			alert(windowW);
			//windowW = windowW+25;
			//windowH = windowH+55;
			//alert(iMyWidth);
			//alert(iMyHeight);
			//alert(windowH);
			//alert(windowW);
			//var _newWindow = window.open("/common/showImg.asp?imgurl="+strURL+"&w="+windowW+"&h="+windowH,"_ppPopup","status=0,height="+windowH+"px,width="+windowW+"px,resizable=1,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=0");
			var _newWindow = window.open(strURL,"_ppPopup","status=0,height="+windowH+"px,width="+windowW+"px,resizable=1,scrollbars=0");//,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + "
			_newWindow.resizeTo(windowW,windowH);
			_newWindow.moveTo(iMyWidth,iMyHeight);
			
			_newWindow.focus();
		}
		catch(e){
			alert("We could not launch a new browser to display the site.\n\nPlease shut off any pop-up blockers.");
		}
	}
	else
	{
		var _newWindow = window.open(strURL,"_newWin","status=1,height=600,width=800,scrollbars=1,location=1,menubar=1,resizable=1");
		_newWindow.focus();
	}
}
*/