// Pop up Universal Script
// How-to: call function pop with the following parameters:
// style:  either 'up' or 'under'
// url:  the location of the file to be displayed in the popup/under.
// width: the width of the window
// height: the height of the window
// offset: the number of pixels to offset from the opening window
// other:  other assignables, e.g. screenX, toolbars, etc... left blank for all no's

function pop(style,url,width,height,offset,other) {
	if (other == "") other = "scrollbars=no,resizable=no,toolbar=no,directories=no,status=no,menubar=no";
	other += ",width=" + width + ",height=" + height;
	if (isNaN(offset)) offset = 0;
	if (!document.all) 
	  other += ",screenX=" + (window.screenX + offset) + ",screenY=" + (window.screenY + offset);
	else
	  other += ",top=" + (window.screenTop + offset) + ",left=" + (window.screenLeft + offset);
	
	var popped =  window.open(url,"window" + (new Date()).getTime(),other);
	if (style == "under") {
	  popped.blur();
	  popped.opener.focus();
	}	
}

function getCookie(name) {
  var result = null;
  var cookieX = " " + document.cookie + ";";
  var searchName = " " + name + "=";
  var startOfCookie = cookieX.indexOf(searchName);
  var endOfCookie;
  if (startOfCookie != -1) {
    startOfCookie += searchName.length;
	endOfCookie = cookieX.indexOf(";",startOfCookie);
	result = unescape(cookieX.substring(startOfCookie,endOfCookie));
  }
  return result;
}

function viewVideoPopUp(id) {
	URL="video.jsp?ID=" + id;
	wid = window.open(URL, "Popup", "toolbar=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,copyhistory=0,width=485,height=410");
}

function MM_ProductJumpMenu(targ,selObj,restore){ //v3.0
	if (selObj.value != "")	document.ProductSearch.submit();
}

function Client_Display(url) {

	var newWindow;
	var props = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=350,height=230';
	newWindow = window.open(url, "ManufacturerInfo", props);
}

function popMeUp(url) {

	var newWindow;
	var props = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480';
	newWindow = window.open(url, "640x480", props);
}

function SubmitIt(formName){ //v3.0
	eval("document." + formName + ".submit()");
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		sd_mock_layout_top_01_sd_mock_layout_top_12_over = newImage("images/sd_mock_layout_top_01-sd_mo.jpg");
		sd_mock_layout_top_01_sd_mock_layout_top_14_over = newImage("images/sd_mock_layout_top_01-sd-03.jpg");
		sd_mock_layout_top_02_over = newImage("images/sd_mock_layout_top_02-over.jpg");
		sd_mock_layout_top_03_sd_mock_layout_top_02_over = newImage("images/sd_mock_layout_top_03-sd_mo.jpg");
		sd_mock_layout_top_03_sd_mock_layout_top_04_over = newImage("images/sd_mock_layout_top_03-sd-08.jpg");
		sd_mock_layout_top_04_over = newImage("images/sd_mock_layout_top_04-over.jpg");
		sd_mock_layout_top_05_sd_mock_layout_top_06_over = newImage("images/sd_mock_layout_top_05-sd_mo.jpg");
		sd_mock_layout_top_06_over = newImage("images/sd_mock_layout_top_06-over.jpg");
		sd_mock_layout_top_07_sd_mock_layout_top_06_over = newImage("images/sd_mock_layout_top_07-sd_mo.jpg");
		sd_mock_layout_top_08_over = newImage("images/sd_mock_layout_top_08-over.jpg");
		sd_mock_layout_top_09_sd_mock_layout_top_08_over = newImage("images/sd_mock_layout_top_09-sd_mo.jpg");
		sd_mock_layout_top_10_over = newImage("images/sd_mock_layout_top_10-over.jpg");
		sd_mock_layout_top_12_over = newImage("images/sd_mock_layout_top_12-over.jpg");
		sd_mock_layout_top_14_over = newImage("images/sd_mock_layout_top_14-over.jpg");
		sd_mock_layout_top_15_sd_mock_layout_top_14_over = newImage("images/sd_mock_layout_top_15-sd_mo.jpg");
		sd_mock_layout_top_15_sd_mock_layout_top_16_over = newImage("images/sd_mock_layout_top_15-sd-31.jpg");
		sd_mock_layout_top_16_over = newImage("images/sd_mock_layout_top_16-over.jpg");
		preloadFlag = true;
	}
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		sd_interface_wp_bot_nav_02_over = newImage("images/sd_interface_wp_bot_nav_02-.jpg");
		sd_interface_wp_bot_nav_04_over = newImage("images/sd_interface_wp_bot_nav_04-.jpg");
		sd_interface_wp_bot_nav_06_over = newImage("images/sd_interface_wp_bot_nav_06-.jpg");
		sd_interface_wp_bot_nav_08_over = newImage("images/sd_interface_wp_bot_nav_08-.jpg");
		sd_interface_wp_bot_nav_10_over = newImage("images/sd_interface_wp_bot_nav_10-.jpg");
		sd_interface_wp_bot_nav_12_over = newImage("images/sd_interface_wp_bot_nav_12-.jpg");
		preloadFlag = true;
	}
}

document.MM_sr=new Array();

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; document.MM_sr=new Array();
  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) { //v3.0
  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); return x;
}

function MM_swapImage() { //v3.0
  var i,j=document.MM_sr.length,x,a=MM_swapImage.arguments; 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_destjumpMenu(targ,selObj,restore){ //v3.0

	 if (selObj.value != "")
		document.destinationJumper.submit();

}

function MM_jumpMenu1(targ,selObj,restore){ //v3.0

  splitVal = selObj.options[selObj.selectedIndex].value.split(" ")


  if (splitVal[1] == 0)
  {
	eval("parent.location='" + splitVal[0] + "'");

  } else {

	window.open(splitVal[0],"","");

  }

  if (restore) selObj.selectedIndex=0;
}

function MM_equipjumpMenu(targ,selObj,restore){ //v3.0
	 if (selObj.value != "")
	 document.equipmentJumper.submit();

}

function validateMe()
{

	 Xdone=0;
	 optionbox=document.voterpoll.selected.length;

	 for (i=0; i < optionbox; i++)
	 {
		  if (document.voterpoll.selected[i].checked )
			   Xdone=1};

		  if (Xdone==0)
			   alert("Please select an answer");
		  else {

			  document.voterpoll.submit();
	 }
}

// for the dynamic instructions on wallpapers
function showInstructions() {
		// NN4
		if (document.layers) {
			Instructions = window.open("","Instructions","width=450,height=200");
			self.Instructions.document.open();
			if (navigator.platform == "Win32") {
				var help = '<p style="text-align:left">Click on the desired resolution and wait for the image to load.  Then right click your mouse, select "Set Wallpaper" to change your desktop picture immediately.  Or select "Save Pictures As"  to download it to your hard drive.  Then right click on your desktop, select "Properties", and choose the "Background" tab to set your image.</p>';
			} else if (navigator.platform == "MacPPC") {
				var help = '<p style="text-align:left">Click on the desired resolution and wait for the image to load.  Then click on the image and choose "Save As".  Save the image to the desktop or folder of your choice.  Then use your Appearance Control Panel to select the image as your background.</p>';
			}
			self.Instructions.document.write(help);
			self.Instructions.document.write('<div style="text-align:center"><a href="javascript:window.close()">Close this window</a></div>');
			self.Instructions.document.close();
			return;
		}
		// IE
		if (document.all) {
			if (document.all.instructions.style.display == "none") {
				document.all.instructions.style.display = "";
			} else {
				document.all.instructions.style.display = "none";
			}
			return;
		}
		// NN6
		if (document.getElementById && navigator.appName == "Netscape") {
			if (document.getElementById("instructions").style.display == "none") {
				document.getElementById("instructions").style.display = "";
			} else {
				document.getElementById("instructions").style.display = "none";
			}
			return;
		}
		// Opera
		if (document.getElementById && navigator.appName == "Opera") {
			Instructions = window.open("","Instructions","width=450,height=200");
			self.Instructions.document.open();
			if (navigator.platform == "Win32") {
				var help = '<p style="text-align:left">Click on the desired resolution and wait for the image to load.  Then right click your mouse, select "Set Wallpaper" to change your desktop picture immediately.  Or select "Save Pictures As"  to download it to your hard drive.  Then right click on your desktop, select "Properties", and choose the "Background" tab to set your image.</p>';
			} else if (navigator.platform == "MacPPC") {
				var help = '<p style="text-align:left">Click on the desired resolution and wait for the image to load.  Then click on the image and choose "Save Image".  Save the image to the desktop or folder of your choice.  Then use your Appearance Control Panel to select the image as your background.</p>';
			}
			self.Instructions.document.write(help);
			self.Instructions.document.write('<div style="text-align:center"><a href="javascript:window.close()">Close this window</a></div>');
			self.Instructions.document.close();
			return;
		}
	}

function textCounter(field, countfield, maxlimit)
{
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	else
		countfield.value = maxlimit - field.value.length;

}

function textCounter(field, maxlimit)
{
	if (field.value.length > maxlimit) // if too long...trim it!
	{
		field.value = field.value.substring(0, maxlimit);
		alert("you have entered too much text");
	}

}

function checkAll(checkboxSet) {
  for (var i = 0; i < checkboxSet.length; i++) {
    checkboxSet[i].checked = true;
  }
}

function switchPage(direction,formObj) {
  if (direction == "-")
    formObj.page.value--;
  if (direction == "+")
    formObj.page.value++;
  formObj.submit();
}

// This is for the PhpAdsNew banner system - do not delete
function phpads_deliverActiveX(content)
{
	document.write(content);	
}
