<!--
// Name: openWin
// Language: JavaScript
// Author: Travis Beckham | squidfingers.com
// Description: This script is for opening external windows.
// --------------------------------------------------
openWin = function(url,name,width,height,xpos,ypos,chrome,scroll){
  var x, y, w, h, moveX=0, moveY=0, features="";
  chrome = chrome ? "yes" : "no";
  scroll = scroll ? "yes" : "no";
  features += "toolbar="+chrome+",location="+chrome+",status="+chrome+",menubar="+chrome;
  features += ",scrollbars="+scroll+",resizable="+scroll;
  if(width) features += ",width="+width;
  if(height) features += ",height="+height;
  if(xpos && window.screen){
    w = window.screen.availWidth;
    width = parseInt(width);
    switch(xpos){
      case "left": x = 0; break;
      case "center": x = (w-width)/2; break;
      case "right": x = w-width; break;
      default: x = xpos;
    }
    features += ",screenX="+x+",left="+x;
    var moveX = x;
  }
  if(ypos && window.screen){
    h = window.screen.availHeight;
    height = parseInt(height);
    switch(ypos){
      case "top": y = 0; break;
      case "middle": y = (h-height)/2; break;
      case "bottom": y = h-height; break;
      default: y = ypos;
    }
    features += ",screenY="+y+",top="+y;
    var moveY = y;
  }
  openWinReference = window.open(url,name,features);
  if(moveX || moveY){
    // position the window for browsers that don't recognize screenX, screenY
    openWinReference.moveTo(moveX,moveY);
  }
}
openScroll = function(url,name,width,height){
  openWin(url,name,width,height,false,false,false,"scroll");
}
openCenter = function(url,name,width,height){
  openWin(url,name,width,height,"center","middle");
}
openCenterScroll = function(url,name,width,height){
  openWin(url,name,width,height,"center","middle",false,"scroll");
}
openFull = function(url,name){
  openWin(url,name,false,false,false,false,"chrome","scroll");
}

// ---------------------------
function noSpam(user,domain) {
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
}
// MM rolovers
function swapImgRestore() { 
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() { 
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function findObj(n, d) { 
  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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() { 
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}	


var noFlash = 0;
var flashCookie = document.cookie.indexOf('noFlash=');

if( flashCookie != -1 )
{
	noFlash = document.cookie.substring( flashCookie + 8, flashCookie + 9 ); 
}

function setNoFlash( on )
{ 
	document.cookie = 'noFlash=' + on;
	location.reload();
}

function RandomServiceFlash()
{
	var randomNum;

	randomNum = Math.floor( Math.random() * 15 );

	document.write( "<tr><td colspan=\"2\" align=\"center\" background=\"img/global/flashbk.jpg\"><p class=\"print\"><embed src=\"media/flash/anim_shell.swf?sec=services.swf&cue=" + randomNum + "\" width=\"762\" height=\"125\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed></p></td></tr>" );
}

function RandomTrainingFlash()
{
	var randomNum;

	randomNum = Math.floor( Math.random() * 4 );

	document.write( "<tr><td colspan=\"2\" align=\"center\" background=\"img/global/flashbk.jpg\"><p class=\"print\"><embed src=\"media/flash/anim_shell.swf?sec=training.swf&cue=" + randomNum + "\" width=\"762\" height=\"125\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed></p></td></tr>" );
}

function RandomProductsFlash()
{
	var randomNum;

	randomNum = Math.floor( Math.random() * 7 );

	document.write( "<tr><td colspan=\"2\" align=\"center\" background=\"img/global/flashbk.jpg\"><p class=\"print\"><embed src=\"media/flash/anim_shell.swf?sec=products.swf&cue=" + randomNum + "\" width=\"762\" height=\"125\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed></p></td></tr>" );
}

function RandomProductsFlash2()
{
	var randomNum;

	randomNum = Math.floor( Math.random() * 7 );

	document.write( "<tr><td colspan=\"2\" align=\"center\" background=\"../../img/global/flashbk.jpg\"><p class=\"print\"><embed src=\"../../media/flash/anim_shell_mylab.swf?sec=products.swf&cue=" + randomNum + "\" width=\"762\" height=\"125\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed></p></td></tr>" );
}

function RandomCompanyFlash()
{
	var randomNum;

	randomNum = Math.floor( Math.random() * 5 );

	document.write( "<tr><td colspan=\"2\" align=\"center\" background=\"img/global/flashbk.jpg\"><p class=\"print\"><embed src=\"media/flash/anim_shell.swf?sec=company.swf&cue=" + randomNum + "\" width=\"762\" height=\"125\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed></p></td></tr>" );
}

function CheckChoice(whichbox)
{
	with (whichbox.form)
	{
		//Handle differently, depending on type of input box.
		if (whichbox.type == "radio")
		{
			//First, back out the prior radio selection's price from the total:
			hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio.value);
			//Then, save the current radio selection's price:
			hiddenpriorradio.value = eval(whichbox.price);
			//Now, apply the current radio selection's price to the total:
			hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.price);
		}
		else
		{
			//If box was checked, accumulate the checkbox value as the form total,
			//Otherwise, reduce the form total by the checkbox value:
			if (whichbox.checked == false)
				{ hiddentotal.value = eval(hiddentotal.value) - eval(whichbox.value); }
			else 	{ hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.value); }
		}

		//Ensure the total never goes negative (some browsers allow radiobutton to be deselected):
		if (hiddentotal.value < 0)
			{
			InitForm();
			}

		//Now, return with formatted total:
		return(formatCurrency(hiddentotal.value));
	}
}

function formatCurrency(num)
{
   ///
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	   num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		      num.substring(num.length-(4*i+3));
  	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function InitForm()
{
	//Reset the displayed total on form:
	document.myform.total.value='$0';
	document.myform.hiddentotal.value=0;
	document.myform.hiddenpriorradio.value=0;
	document.myform2.total.value='$0';
	document.myform2.hiddentotal.value=0;
	document.myform2.hiddenpriorradio.value=0;
	document.myform2.hiddenpriorradio.value=0;

	//Set all checkboxes and radio buttons on form-1 to unchecked:
	for (xx=0; xx < document.myform.elements.length; xx++)
	{
	   if (document.myform.elements[xx].type == 'checkbox' | document.myform.elements[xx].type == 'radio')
		{
		document.myform.elements[xx].checked = false;
		}
	}
	//Set all checkboxes and radio buttons on form-2 to unchecked:
	for (xx=0; xx < document.myform2.elements.length; xx++)
	{
	   if (document.myform2.elements[xx].type == 'checkbox' | document.myform2.elements[xx].type == 'radio')
		{
		document.myform2.elements[xx].checked = false;
		}
	}

}

function ChangeLanguageFrench()
{
	var str;
	var index = location.href.lastIndexOf('/');

	if( index == -1 )
		return;

	str = location.href.substring( 0, index );
	str += '/fr';
	str += location.href.substring( index );

	location.href = str;
}

function ChangeLanguageEnglish()
{
	var str;
	var index = location.href.indexOf( '/fr/' );

	if( index == -1 )
		return;

	str = location.href.substring( 0, index );
	str += location.href.substring( index + 3 );

	location.href = str;
}

//-->
