
function $(objname)
{
	if (document.getElementById) return document.getElementById(objname);
	if (document.all) return document.all[objname];
	if (document.layers) return document.layers[objname];
}
function MM_findObj(n, d) { //v4.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);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
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;
}
if (document.getElementById)
{
	DOMtype = "std";
}
else if (document.all)
{
	DOMtype = "ie4";
}
else if (document.layers)
{
	DOMtype = "ns4";
}
function grabobj(objname) // v1.0
{
var ret = null;
	switch (DOMtype)
	{
		case "std":
		{
			ret = document.getElementById(objname);
		}
		break;

		case "ie4":
		{
			ret = document.all[objname];
		}
		break;
		case "ns4":
		{
			ret = document.layers[objname];
		}
		break;
	}
return ret;
}
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];}
}
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;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function prodImageSwap (opt,obj)
{
  if (obj)
  {
	obj=grabobj(obj);
	if (obj)
	{
	
	 if (opt==1)
	 {
	  obj.src=obj.src.replace('/products/opt3/medium/','/products/medium/');
	  obj.src=obj.src.replace('/products/opt2/medium/','/products/medium/');
	 } else {

	  obj.src=obj.src.replace('/products/opt3/medium/','/products/opt'+opt+'/medium/');
	  obj.src=obj.src.replace('/products/opt2/medium/','/products/opt'+opt+'/medium/');
	  obj.src=obj.src.replace('/products/medium/','/products/opt'+opt+'/medium/');
	 }
	}

  }
}
function menuInit ()
{
	var i=1;
	while ($('menu_'+i))
	{
		$('menu_'+i).onmouseover=function(){ displayMenu(this);}
		$('menu_'+i).onmouseout=function(){ hideMenu(this);}
		i++;
	}
	i=1;
	while ($('menu_'+i+'_content'))
	{
		$('menu_'+i+'_content').onmouseover=function(){ clearMenuTimer(); }
		$('menu_'+i+'_content').onmouseout=function(){ menuTimer=window.setTimeout("closeMenus()",300);  }
		if($('menu_'+i+'_content').innerHTML=="") {$('menu_'+i+'_content').style.border = "none";}
		i++;
	}
}
function displayMenu(obj)
{	
	clearTimeout(menuTimer);
	var i=1;
	while ($('menu_'+i+'_content'))
	{
		$('menu_'+i+'_content').style.display='none';
		removeElementByID('iFrameBack');
		i++;
	}
	var id=obj.id.split('_')[1];
	$('menu_'+id+'_content').style.display='block';
	$('menu_'+id+'_content').style.top='241px';



	var popupWidth=$('menu_'+id+'_content').offsetWidth;
	var tabWidth=$('menu_'+id).offsetWidth;

	if ((findPos(obj)[0]+popupWidth)>1000)
	{
	 	var newLeft=(findPos(obj)[0]-findPos($('wrapper'))[0])-popupWidth+tabWidth;
		if (newLeft>0)
		{
			$('menu_'+id+'_content').style.left=(newLeft)+'px';
		} else {
			var bWidth=(findPos($('wrapper'))[0]*2)+1000;
			
			$('menu_'+id+'_content').style.left=((bWidth/2)-(popupWidth/2)-findPos($('wrapper'))[0])+'px';
		}
	} else {
		$('menu_'+id+'_content').style.left=(((findPos(obj)[0]-findPos($('wrapper'))[0])-10)+30)+'px';
	}
	makeIFrame($('menu_'+id+'_content').offsetTop-14, $('menu_'+id+'_content').offsetLeft, $('menu_'+id+'_content').offsetHeight, $('menu_'+id+'_content').offsetWidth)
}
function makeIFrame(top, left, height, width)
{
//	alert(top+" - "+left+" - "+height+" - "+width)
	iFrameBack	=	document.createElement('iframe');
	iFrameBack.id	=	'iFrameBack';
	iFrameBack.style.top	=	top+'px';
	iFrameBack.style.left	=	left+'px';
	iFrameBack.style.height	=	height+'px';
	iFrameBack.style.width	=	width+'px';
	try
	{
		$('wrapper').firstChild.appendChild(iFrameBack);
	}
	catch(e){}
}

var menuTimer;
function hideMenu (id)
{
	menuTimer=window.setTimeout("closeMenus()",300);
}
function closeMenus ()
{
	var i=1;
	while ($('menu_'+i+'_content'))
	{
		$('menu_'+i+'_content').style.display='none';
		i++;
	}
	removeElementByID('iFrameBack');
}

function removeElementByID(ID)
{
//	document.body.setAttribute('onmousedown','');
	Obj=ID
	if(typeof ID== 'string') Obj=document.getElementById(ID);
	if(Obj && Obj.parentNode)Obj.parentNode.removeChild(Obj);
	if(document.getElementById(ID)) {removeElementByID(ID);}
	return
}


function clearMenuTimer ()
{
	clearTimeout(menuTimer);
}

function findPos(obj)
{

	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}

	return [curleft,curtop];
	
}
function imgSwap(src,obj)
{
	var i=1;
	if (obj)
	{
		obj=$(obj);
		if (obj)
		{
			obj.src=src;
		}
	}
}
function stringFilter (s) {
 filteredValues = "#";     // Characters stripped out
 var i;
 var returnString = "";
 for (i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
 var c = s.charAt(i);
 if (filteredValues.indexOf(c) == -1) returnString += c;
 }
 return returnString;
}
function rl ()
{
	window.location=stringFilter(window.location);
}