
/* Basic sitewide functions */

var cW; // Client Width
var cH; // Client Height
var w; //width
function getClientWindowSize() { //this should be centralized
	if (self.innerHeight) // all except Explorer
	{
		cW = self.innerWidth;
		cH = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		cW = document.documentElement.clientWidth;
		cH = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		cW = document.body.clientWidth;
		cH = document.body.clientHeight;
	}
//	w = cW;
	cW = cW - 5; //Compensate for scroll bars
}
getClientWindowSize();


enterFunction = 0; //which function to call after checkEnter
function checkEnter(e,fn){ //e is event object passed from function invocation
	e = e || window.event
	if ((e.which || e.keyCode) == 13) {fn();}; //Using variables to call a dynamic function name!
}



function getCage(val) //This should be centralized
{
	nobubble = 1;
	val = "/vendor.php?cage=" + val + "&hK=" +hK;

	LOP = window.open(val, 'vendor', 'scrollbars,resizable,width=610,height=490, left=45%, top=10%');
	if ((document.all) || (document.layers)) 
	{
		var LOPMoveWidth  = ((screen.width/2) - 400);
		var LOPMoveHeight = ((screen.height/2) - 300);
		LOP.moveTo(LOPMoveWidth,LOPMoveHeight); 
	}
	LOP.focus();
	return false;
	
}

function displayNextPage(ret) {	
	var tmp = ret[0];
//	alert(tmp);
//	tmp = "qsOutputReplace" //document.getElementById('qsOutputReplace').innerHTML;
	document.getElementById(tmp).innerHTML = ret[1];
}

function getPref(name) {
	/* Get preference and adjust radio buttons or checkboxes */
	x_getPrefSajax(name,returnPref);
}

function setPref(name,value) {
//	alert(name+"\n"+value)
	x_setPrefSajax(name,value,returnPref);
}

function returnPref(ret) {
	if (ret) updateElementCheck(ret[0],ret[1])
}

function debug(val) {
	var test = document.getElementById("test");
	if (typeof test == 'object' && test.style.display == 'none') test.style.display = 'block';
	test.innerHTML = test.innerHTML + val + "<br />";
}

function popMIL(val){
		loc = "milspecs/"+val;
		//alert(loc);
		LOP = window.open(loc, 'help_pdf_mil', 'scrollbars, width=650,height=700, left=45%, top=10%');
		if ((document.all) || (document.layers)) 
		{
			var LOPMovewidth  = ((screen.width/2) - 150);
			var LOPMoveHeight = ((screen.height/2) - 100);
			LOP.moveTo(LOPMovewidth,LOPMoveHeight); 
		}
		LOP.focus();
	}	
function showBidFromSearch(pKey,id,table) {
	/* Show bid when selected from search notes or QuickSearch */
	//There is a copy of this in notes.js 
	
	var lcS = document.getElementById(lastColorSearch);
	if (lastColor) {
//		alert("lc:"+lastColor)
		changeColorBack2(lastColor);
	}					
	if (lastColorSearch && lcS) {
//		alert("lcs:"+lastColorSearch)
		lcS.className = lastRowClass;				
	}


		lastRowClass = document.getElementById(id).className;
		lastColorSearch = id;
		document.getElementById(id).className = "dataRow_blue";

	qSBidDetails = document.getElementById("bid_condensed");			

	if (document.getElementById("bso_frame")) { /* It's in the bid manager */
		cMDisp = '';
	}else {
		cMDisp = "&c=1"; //Force cMode to display red X in right corner

	}
	cMDisp = "&c=1"; //Force cMode to display red X in right corner - Override - show it no matter what.
	bid_condensed.location.href = "/include/bid_details_mini.php?pKey="+pKey+"&t="+table +cMDisp;
	
//	SPM4A7-10-R-1292
	
}


/*
 var viewportwidth;
 var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
//http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/
//We're not using this piece of crap anyway.
*/
