// JavaScript Document

s4 = (document.layers)? true:false
ie4 = (document.all)? true:false
ns6 = ((!document.all) && (document.getElementById))? true:false 
// JavaScript Document.... created by Click4Designers...  Chris Ruecker
//	alert('Divname: ' + divname + ' & divnameName: ' + divname + '  TEST HERE!!!')


function getObj(name)
{
  if (ns6)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (ie4)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (ns4)
  {
	this.obj = getObjNN4(document,name);
	this.style = this.obj;
  }
}

function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}

// getAnchorPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the page.
function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// getAnchorWindowPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the window
function getAnchorWindowPosition(anchorname) {
	var coordinates=getAnchorPosition(anchorname);
	var x=0;
	var y=0;
	if (document.getElementById) {
		if (isNaN(window.screenX)) {
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
			}
		else {
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
			}
		}
	else if (document.all) {
		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
		y=coordinates.y-document.body.scrollTop+window.screenTop;
		}
	else if (document.layers) {
		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
	}	
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
	}

function getIndex(form_name,this_element) {
var form_Short = new getObj(form_name);
    for (var i=0;i<form_Short.obj.elements.length;i++)	{
        if (this_element == form_Short.obj.elements[i].name)	{
            return i;	}
		}
    return -1;
}

function switchtab(tablinkname,tabcontentname, newclass)	{
	var tablink = new getObj(tablinkname);
	tablink.obj.className = newclass;
	var tabcontent = new getObj(tabcontentname);
	tabcontent.obj.className = newclass;
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
   
function popup_show(name)	{
	var nameDiv = new getObj(name);
	nameDiv.style.visibility = 'visible';
	nameDiv.style.display = 'block';
}
function popup_hide(name)	{
	var nameDiv = new getObj(name);
	nameDiv.style.visibility = 'hidden';
	nameDiv.style.display = 'none';
}

/*
function popup_show()	{
	popup1.style.visibility = 'visible';
	popup1.style.display = 'block';
}
function popup_hide()	{
	popup1.style.visibility = 'hidden';
	popup1.style.display = 'none';
}
*/

function verifyRequired(formname) {
	var frm = new getObj(formname);
  if (frm.obj.fields_email.value == "") {
    alert("The Email Address field is required.");
    return false;
  }
  if (frm.obj.fields_fname.value == "") {
    alert("The Name field is required.");
    return false;
  }
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(frm.obj.fields_email.value))	{
		alert('Invalid Email Address.');
		return false;
	}
if (hide_popup_after_submit)	{
	popup_hide(hide_popup_after_submit);
}
return true;
}














function ClearForm()
{
	var FieldType;
	for (var i = 0; i < document.EditForm.length; i++) {
		FieldType = document.EditForm.elements[i].type
		if (FieldType == "text" || FieldType == "textarea") {
			document.EditForm.elements[i].value = ""
		}
		if (FieldType == "select-one") {
			document.EditForm.elements[i].options.selectedIndex = 0
		}
	}
}

function OpenNewWindow(url, width, height)
{
	var randomnumber=Math.floor(Math.random()*5001)
	window.open(url, randomnumber, "top=10,left=10,menubar=0,resizable=1,scrollbars=1,width=" + width + ",height=" + height)
}

function OpenWindowNoScroll(url, width, height) { 
	window.open(url, 'popup_noscroll',
	  "top=10,left=10,menubar=0,resizable=0,scrollbars=0,width=" + width + ",height=" + height)
}

function protect_images2(e) {
var msg = "Sorry, our images are copyrighted.";
if (navigator.appName == 'Netscape' && e.which == 3) {
	alert(msg);
	return false;
}
if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
	alert(msg);
	return false;
}
else return true;
}

function protect_images1() {
	if(document.images) {
	    for(i=0;i<document.images.length;i++) {
			document.images[i].onmousedown = protect_images2;
			document.images[i].onmouseup = protect_images2;
		}
	}
}

function OpenSideWindow(url){
	rightwidth=300;
	if (document.all) {
		windowheight = screen.availHeight;		
		leftwidth=screen.availWidth-rightwidth-11;
		SideWindow=window.open(url,'SideWindow','width='+rightwidth+',height='+(windowheight-60)+',screenX='+leftwidth+',screenY=0,top=0,left=' +leftwidth+',toolbar=0,location=0,status=1,menubar=0,resizable=1');
		SideWindow.focus();
	} else {
		SideWindow=window.open(url,'','width=280,height=480,toolbar=0,location=0,status=1,menubar=0,resizable=1');
	}
}

function PageName() {
	var pageName = window.location.href.toLowerCase();
	if (pageName.indexOf('_p/') != -1) {
		pageName = 'productdetails.asp';
	}
	else if (pageName.indexOf('_s/') != -1) {
		pageName = 'searchresults.asp';
	}
	else {
		pageName = pageName.substr(pageName.lastIndexOf("/") + 1).replace(/\?[\s\S]*/, "");
	}
	return pageName;
}

function PagePath() {
	return window.location.href.toLowerCase().replace(/http[s]?:\/\/[^\/]*\/?/, "").replace(/\?[\s\S]*/, "");
}

function QueryString(name) {
	var qsRE = new RegExp("[?&]" + name + "=([^&]*)", "i");
	var value = qsRE.exec(location.href);
	return (value) ? decode(value[1]) : "";
}

function GetCookieArray() {
	if (document.cookie.length > 0) {
		var cookieRE = new RegExp("(?:^|;)[\\s]*([^=]*)=([^;]*)", "gi");
		var cookie, cookieArray = new Array();
		cookie = cookieRE.exec(unescape(document.cookie.toString()))
		while (cookie) {
			cookieArray[cookie[1]] = cookie[2];
			cookie = cookieRE.exec(unescape(document.cookie.toString()))
		}
		return cookieArray;
	}
	return "";
}

function GetCookie(name, key, encoded) {
	var value = '', cookies = ';' + document.cookie;
	if (cookies.length > 1) {
		if (key) {
			var cookieRE = new RegExp(';[\\s]*' + name + '=[^;]*' + key + '=([^&;]*)[^;]*', 'i')
		}
		else {
			var cookieRE = new RegExp(';[\\s]*' + name + '=([^;]*)', 'i');
		}
		value = cookieRE.exec(cookies);
		value = (value) ? value[1] : '';
		if (!encoded) {
			value = decode(value);
		}
	}
	return value;
}

var c_minutes = 1, c_hours = 60, c_days = 1440, c_years = 525600;
function SetCookie(name, value, duration, key) {
	var cookie = '';
	if (key) {
		cookie = GetCookie(name, '', true);
		if (cookie != '') {
			cookie = '&' + cookie;
			var keyRE = new RegExp('([\\s\\S]*?)(&' + key + '=)[^&]*([\\s\\S]*)', 'i');
			if (keyRE.test(cookie)) {
				if (value == '') {
					cookie = cookie.replace(keyRE, '$1$3');
				}
				else {
					cookie = cookie.replace(keyRE, '$1$2' + encode(value) + '$3');
				}
			}
			else if (value != '') {
				cookie += '&' + key + '=' + encode(value);
			}
			cookie = cookie.substr(1);
		}
		else if (value == '') {
				cookie = '';
		}
		else {
			cookie = key + '=' + encode(value);
		}
	}
	else if (value != '') {
		cookie = encode(value);
	}
	if (cookie == '') {
		duration = -1000;
	}
	cookie = name + '=' + cookie + ';path=/';

	if (duration) {
		var expireDate = new Date();
		expireDate.setMinutes(expireDate.getMinutes() + parseInt(duration));
		cookie = cookie + ';expires=' + expireDate.toGMTString();
	}
	document.cookie = cookie;
	return value;
}

function encode(value) {
	value = escape(value);
	value = value.replace(/@/gi, "%40");
	value = value.replace(/\*/gi, "%2A");
	value = value.replace(/_/gi, "%5F");
	value = value.replace(/-/gi, "%2D");
	value = value.replace(/\+/gi, "%2B");
	value = value.replace(/\./gi, "%2E");
	value = value.replace(/\//gi, "%2F");
	value = value.replace(/%20/gi, "+");
	return value;
}

function decode(value) {
	value = value.replace(/\+/g, " ");
	value = unescape(value);
	return value;
}

function v$(id) {
	if (typeof(id) == 'string') {
		return document.getElementById(id);
	}
	else {
		return id;
	}
}

function FixEvent(event) {
	if (window.event) {
		var event = window.event;
		event.target = event.srcElement;
	}
	else {
		var event = event;
	}
	return event;
}

function AttachEvent(element, event, func) {
	if (element.addEventListener) {
		element.addEventListener(event.toLowerCase(), func, false)
	}
	else {
		element.attachEvent('on' + event.toLowerCase(), func);
	}
}

function DetachEvent(element, event) {
	if (element.removeEventListener) {
		element.removeEventListener(event.toLowerCase(), func, false)
	}
	else {
		element.detachEvent('on' + event.toLowerCase(), func);
	}
}

function ShowHide(Element_ID, Show) {
	var Element = v$(Element_ID);
	if (Element) {
		Show = eval(Show)
		if (typeof(Show) == 'undefined' && Element.style['display'] != 'none' || Show == false) {
			Element.style['display'] = 'none';
			return false;
		}
		else {
			Element.style['display'] = '';
			return true;
		}
	}
}

// 05/08/2007 - vTrim() Added by ERW1N GUNG0N - changed to regex brad
function vTrim(arg_value) {
	return arg_value.toString().replace(/^[\s]+|[\s]+$/g, '');
}


var agt = '';
if (navigator.userAgent) { agt=navigator.userAgent.toLowerCase(); }
// *** BROWSER VERSION *** 
// note: on IE5, these return 4, so use is_ie5up to detect IE5. 
var is_major = parseInt(navigator.appVersion); 
var is_minor = parseFloat(navigator.appVersion); 
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
			&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
			&& (agt.indexOf('webtv')==-1)); 
var is_nav4 = (is_nav && (is_major == 4)); 
var is_nav4up = (is_nav && (is_major >= 4)); 
var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) || 
					  (agt.indexOf("; nav") != -1)) ); 
var is_nav5 = (is_nav && (is_major == 5)); 
var is_nav5up = (is_nav && (is_major >= 5)); 
var is_ie   = (agt.indexOf("msie") != -1); 
var is_ie3  = (is_ie && (is_major < 4)); 
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) ); 
var is_ie4up  = (is_ie  && (is_major >= 4)); 
var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) ); 
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4); 