// JavaScript Document
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
var strCode;
var strSUP, strUL, strLI

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (checkIt('fire')) browser = "Fire Fox"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


function docjslib_getRealLeft() {
	var WidthObject = document.getElementById("rightside");
	
	xPos = eval(WidthObject).offsetLeft;
	tempEl = eval(WidthObject).offsetParent;
  	while (tempEl != null) {
  		xPos += tempEl.offsetLeft;
  		tempEl = tempEl.offsetParent;
  	}
	return xPos;
}


var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
var strCode;
var strSUP, strUL, strLI

//BUILT-IN MM functionality for preloading images
//Images are passed as arguments to this function in
//the onLoad statement from within the body tag
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];}}
}


//BUILT-IN MM functionality for restoring moused over images
//Used to swap images back to their original state
//after mouse rollover
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;
}

//BUILT-IN MM functionality for finding objects within a document
//This function is primarily used by the other MM built in functions
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;
}

//BUILT-IN MM functionality for preloading images
//Used to swap images back to their original state
//after mouse rollover
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];}
}

//allows all text to be selectable within absolute positioned layers
//IE6 has a huge problem with this when the layer is positioned absolute
if (window.createPopup && document.compatMode && document.compatMode=="CSS1Compat")
{
  document.onreadystatechange = onresize = function fixIE6AbsPos()
  {
    if (!document.body) return;
    if (document.body.style.margin != "0px") document.body.style.margin = 0;
    onresize = null;
    document.body.style.height = 0;
    setTimeout(function(){ document.body.style.height = document.documentElement.scrollHeight+'px'; }, 1);
    setTimeout(function(){ onresize = fixIE6AbsPos; }, 100);
  }
}


function formCheck(strRequest, strReturnPage, strForm, strError)
{

	var intCount = document.forms[strForm].length;
	var i = 0;
	var bSendFlag = true;
	
	while(i != intCount)
	{
		if(document.forms[strForm].elements[i].value == "")
		{
				var strName = document.forms[strForm].elements[i].name;
				
				if(strName.indexOf("*") != -1)
				{
					var iLength = strName.length;
					strName = strName.substring(1, iLength);
					strName = strName.replace("_", " ");
					
					var obj = document.getElementById(strError);
	
						obj.innerHTML = '<span class="error">Please fill in the <B>' + strName + '</B> field.</span>';
						
						document.forms[strForm].elements[document.forms[strForm].elements[i].name].focus();
						bSendFlag = false;
						break;
				}
				i = i+1;
		}
		else
		{
			i = i+1;
		}
		
	}
	
	if(bSendFlag == true)
	{
		document.forms[strForm].action = "html/asp/submit.asp?request=" + strRequest + "&return=" + strReturnPage;
		document.forms[strForm].submit();
	}
}

function printContent()
{
	if (document.getElementById!= null) 
	{ 
		var html = '<HTML>\n<HEAD>\n'; 

		if (document.getElementsByTagName!= null) 
		{ 
			var headTags = document.getElementsByTagName("head"); 
			
			if (headTags.length > 0) 
			html += headTags[0].innerHTML; 
		} 

		html += '\n</HE' + 'AD>\n<BODY>\n'; 


		html += '<table="width="800"><TR  background="#00386b"><TD><img src="images/nav/top_nav_logo_long.jpg" width="800" height="101"></TD></TR></table><BR><BR>'
		html += '<div id="main_content_div" class="print-content-div" style="height:485px; width:800px;">'
		var printPageElem = document.getElementById("main_content_div"); 

		if (printPageElem!= null) 
		{ 
			html += printPageElem.innerHTML; 
		} 
		else 
		{ 
			return; 
		} 
		html += '<br><BR>';
		html += '<span class="copyright-text">© Copyright Hubspan 2005-6 All rights reserved</span>';
		html += '</div>'
		html += '\n</BO' + 'DY>\n</HT' + 'ML>'; 

	var printWin = window.open("","printFriendly"); 
		printWin.document.open(); 
		printWin.document.write(html); 
		printWin.print();
		printWin.document.close(); 
	
	} 
	else 
	{ 
		alert("Sorry, the printer friendly feature works\nonly in javascript enabled browsers."); 
	} 
} 




function DisplayLargeImage(strProdCode)
{
	window.open("../global/popup.asp", "LargeImage", "height=270, width=250, toolbars=no, status=no");
}



var s, w;
var defaultWindowWidth = 250;
var defaultWindowHeight = 120;

function search() {
	s = document.getElementById('searchform').searchentry.value;
	if (s != '') {
		if (document.getElementById('searchform').searchchoice[0].checked) {
			w = window.open('http://69.0.211.58/~pubexpress/pmc/php/search.php?product=' + escape(s), 'searchWindow', 'width=' + defaultWindowWidth + ',height=' + defaultWindowHeight + ',resizable=yes,scrollbars=yes'); }
		else {
		   if (document.getElementById('searchform').searchchoice[1].checked) {
			w = window.open('http://69.0.211.58/~pubexpress/pmc/php/search.php?showroom=' + escape(s), 'searchWindow', 'width=' + defaultWindowWidth + ',height=' + defaultWindowHeight + ',resizable=yes,scrollbars=yes');
		w.focus(); }
		    else  {
				w = window.open('http://69.0.211.58/~pubexpress/pmc/php/search.php?line=' + escape(s), 'searchWindow', 'width=' + defaultWindowWidth + ',height=' + defaultWindowHeight + ',resizable=yes,scrollbars=yes');
			w.focus(); }
		}
	}
	else
	{
		document.getElementById('searchform').searchentry.value = '';
		//return false;
	}
}

function setWindowSize(numRows) {
	var windowHeight;

	if (numRows < 12) {
		windowHeight = defaultWindowHeight + 28*numRows;
	} else {
		windowHeight = defaultWindowHeight + 336;
	}
	
	window.resizeTo(defaultWindowWidth, windowHeight);
}


function checkEnter(e)
{ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable

	if(e && e.which)
	{ //if which property of event object is supported (NN4)
		e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	}
	else
	{
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}

	if(characterCode == 13)
	{ //if generated character code is equal to ascii 13 (if enter key)
		search(); //submit the form
		return false;
	}
	else
	{
		return true;
	}
}


function LaunchPopupWindow(strWhich)
{
		if(strWhich == "sr")
		{
			window.open("http://69.0.211.58/~pubexpress/pmc/html/index.html","popup","height=768,width=1024")
		}
		if(strWhich == "fp")
		{
			window.open("http://69.0.211.58/~pubexpress/pmc/php/floor-plan.php","popup","height=768,width=1024")
		}
		if(strWhich == "mp")
		{
			window.open("http://69.0.211.58/~pubexpress/pmc/php/market-planner.php","popup","height=768,width=1024")
		}
}


function LaunchFlash()
{
	if(browser == "Internet Explorer")
	{
		window.open("../global/flashmovie.asp", "popup", "height=432, width=432, toolbars=no");
	}
	else
	{
		window.open("http://www.pacificmarketcenter.com/html/global/flashmovie.asp", "popup", "height=432, width=432, toolbars=no");
	}
}