// JavaScript Document for Mophie
// Created by Evan Bartlett of www.evanbartlett.com
// Please do not use without credits


///// Search Replace /////

function fixedWordReplace(tag, findText, replacementText) {
	var list = document.getElementsByTagName(tag);
	for (var i=0; i < list.length; i++) {
		if (list[i].innerHTML.indexOf(findText) > -1) {
			list[i].innerHTML = list[i].innerHTML.replace(findText, replacementText);
			break;
		}
	}
}

///// Start Theme Editor /////

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
  createCookie("style", title, 365);
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

///// End Theme Editor /////

///// Start Toggle Script /////

function toggleIt(id) {
	
	var e = document.getElementById(id);
	
	if (e.style.display == 'block') {
	
		e.style.display = 'none';
	
	} else {
	
		e.style.display = 'block';
		
	}
	
}


///// End Toggle Script /////

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

///// Start Common Required /////

  var monthtext=['','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];

  function populatedropdown(dayfield, monthfield, yearfield){
    var today=new Date()
    var dayfield=document.getElementById(dayfield)
    var monthfield=document.getElementById(monthfield)
    var yearfield=document.getElementById(yearfield)
    dayfield.options[0]=new Option("", "")
    for (var i=1; i<=31; i++) {
      dayfield.options[i]=new Option(i, i)
    }
    //select today's day
    //dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) 

    for (var m=0; m<=12; m++) {
      monthfield.options[m]=new Option(monthtext[m], monthtext[m])
    }
    //select today's month
    //monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true)
 
    var thisyear=today.getFullYear()
    yearfield.options[0]=new Option("", "")
    for (var y=1; y<=3; y++){
      yearfield.options[y]=new Option(thisyear, thisyear)
      thisyear-=1
    }
    //select today's year
    //yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) 
  }
  
    function validate_date(month,day,year) {
    if (month.value=="Feb") {
       if ((year.value%4)==0) {
          if (day.value>29) 
             {alert("Invalid Day!");return false;}
      } else {
          if (day.value>28) 
             {alert("Invalid Day!");return false;}
      }
    }
    if (month.value=="Apr" || month.value=="Jun" || month.value=="Sep" || month.value=="Nov") {
       if (day.value>30) 
          {alert("Invalid Day!");return false;}
    } 
    return true
  }
  
    function isNumeric(strString,alerttxt) {
    //  check for valid numeric strings	
    var strValidChars = "0123456789.-";
    var strChar;

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

    //  test strString consists of valid characters listed above
    for (i=0; i<strString.length; i++) {
      strChar=strString.charAt(i);
      if (strValidChars.indexOf(strChar)==(-1))
         {alert(alerttxt);return false}
    }
    return true;
  }

function validate_required(field,alerttxt) {
	with (field) {
		if (type=="checkbox" || type=="radio") {
			if (checked==false) {
				alert(alerttxt);
				return false;
			} else {
				return true;
			}
		} else {
			if (value==null||value=="") {
				alert(alerttxt);
				return false;
			} else {
				return true;
			}
		}
	}
}

function validate_email(email,alerttxt) {
	var str=email.value
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var ldot=str.lastIndexOf(dot)
	var lstr=str.length
	
	if (lat<=0 || lat>ldot-3 || ldot>lstr-2) {
		alert(alerttxt);
		return false;
	}
	
    if (str.indexOf(at,lat+1)!=-1) {
		alert(alerttxt);
		return false;
	}

    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) {
		alert(alerttxt);
		return false;
	}

    if (str.indexOf(" ")!=-1) {
		alert(alerttxt);
		return false;
	}
	
	return true;
}

function validate_number(field,alerttxt) {
  	strip = /[a-z]/; 
	if(strip.test(field.value)) {
		alert(alerttxt);
		return false;
	}
}

///// End Common Required /////

///// Start Product Registration /////

function validate_registration(thisform) {
    with (thisform) {
      if (validate_required(fname,"First Name must be filled out!")==false)
         {fname.focus();return false;}
      if (validate_required(lname,"Last Name must be filled out!")==false)
         {lname.focus();return false;}
      if (validate_required(street,"Street must be filled out!")==false)
         {street.focus();return false;}
      if (validate_required(city,"City must be filled out!")==false)
         {city.focus();return false;}
if(document.registrationForm.state.value==null||document.registrationForm.state.value=="")
{if(document.registrationForm.province.value==null||document.registrationForm.province.value=="")
{alert("State or Province must be filled out!");return false;}}

if(document.registrationForm.state.value!=null)
{ if(document.registrationForm.state.value!="")
  {if(document.registrationForm.province.value!=null)
   {if(document.registrationForm.province.value!="")
    {alert("State or Province must be filled out one only!");return false;}}}}

      if (validate_required(zip,"Zip Code must be filled out!")==false)
         {zip.focus();return false;}
      if (validate_required(country,"Country must be filled out!")==false)
         {country.focus();return false;}
      if (validate_required(email,"Email must be filled out!")==false)
         {email.focus();return false;}
      if (validate_email(email,"Invalid Email Address!")==false)
         {email.focus();return false;}
      if (validate_required(phone,"Telephone# must be filled out!")==false)
         {phone.focus();return false;}
      if (validate_required(pmonth,"Month must be filled out!")==false)
         {pmonth.focus();return false;}
      if (validate_required(pday,"Day must be filled out!")==false)
         {pday.focus();return false;}
      if (validate_required(pyear,"Year must be filled out!")==false)
         {pyear.focus();return false;}
      if (validate_date(pmonth,pday,pyear)==false)
         {pday.focus();return false;}
      if (validate_required(model,"Model Number must be filled out!")==false)
         {model.focus();return false;} 
      if (validate_required(battery,"Battery Id must be filled out!")==false)
         {battery.focus();return false;}
      if (validate_required(store,"Name of store must be filled out!")==false)
         {store.focus();return false;}
      if (validate_required(price,"Price must be filled out!")==false)
         {price.focus();return false;}
      if (isNumeric(price.value,"Price must be numeric!")==false)
         {price.focus();return false;}
      if (validate_required(learn,"How did you learn must be filled out!")==false)
         {learn.focus();return false;}
      if (validate_required(agreement,"You must agree with the terms and conditions!")==false)
         {agreement.focus();return false;}
    }
  }
  
///// End Product Registration /////

///// Start Warranty /////

function validate_warranty(thisform) {
var street = document.getElementById("00N80000002TZlw"); // street
var city = document.getElementById("00N800000030rpa"); // city
var state = document.getElementById("00N80000002TZmG"); // state
var zip = document.getElementById("00N80000002TZmL"); // zip
var country = document.getElementById("00N80000002TZmQ"); // country
var product = document.getElementById("00N80000002TZls"); // product
var date = document.getElementById("00N80000002TZrk"); // date
var reason = document.getElementById("00N80000002TZtK"); // reason
var subject = document.getElementById("subject"); // subject
var description = document.getElementById("description"); // description

    with (thisform) {
      if (validate_required(name,"Name must be filled out!")==false)
         {name.focus();return false;}
      if (validate_required(street,"Street must be filled out!")==false)
         {street.focus();return false;}
      if (validate_required(city,"City must be filled out!")==false)
         {city.focus();return false;}
      if (validate_required(state,"State must be filled out!")==false)
         {state.focus();return false;}
      if (validate_required(zip,"Zip Code must be filled out!")==false)
         {zip.focus();return false;}
      if (validate_required(country,"Country must be filled out!")==false)
         {country.focus();return false;}
      if (validate_required(product,"Product must be selected!")==false)
         {product.focus();return false;}
      if (validate_required(date,"Date must be filled out!")==false)
         {date.focus();return false;}
      if (validate_required(reason,"Reason must be filled out!")==false)
         {reason.focus();return false;}
      if (validate_required(subject,"Subject must be filled out!")==false)
         {subject.focus();return false;}
      if (validate_required(description,"Description must be filled out!")==false)
         {description.focus();return false;}
    }
  }

///// End Warranty /////

///// Start Reseller Inquiry /////

function validate_reseller(thisform) {
// Set common variables
var fname = document.getElementById("first_name"); // first_name
var lname = document.getElementById("last_name"); // last_name
var titl = document.getElementById("title"); // title
var eml = document.getElementById("email"); // email
var pho = document.getElementById("phone"); // phone
var mble = document.getElementById("mobile"); // mobile
var fx = document.getElementById("fax"); // fax
var cmpy = document.getElementById("company"); // company
var wbste = document.getElementById("URL"); // website
var strt = document.getElementById("street"); // street
var cty = document.getElementById("city"); // city
var stte = document.getElementById("state"); // state
var zp = document.getElementById("zip"); // zip
var cntry = document.getElementById("country"); // country
var emply = document.getElementById("employees"); // employees
var reve = document.getElementById("revenue"); // revenue
var descrn = document.getElementById("description"); // description

	// Set dropdown variables
	var yib = document.getElementById("00N80000002TS7z"); // get years in business
	var nol = document.getElementById("00N80000002TS7y"); // get number of locations
	var bm = document.getElementById("00N80000002TSzC"); // get business model
	var wf = document.getElementById("00N80000002hPzj"); // get agreement
	
	// Reseller type variables
	var retail = document.getElementById("00N80000002TS3X");
	var online = document.getElementById("00N80000002TS3l");
	var distributor = document.getElementById("00N80000002TS3c");
	var catalog = document.getElementById("00N80000002TS3v");
	
	// Product interest variables
	var bpacks = document.getElementById("00N80000002TSzW");
	var cases = document.getElementById("00N80000002TSzl");
	var ispeakers = document.getElementById("00N80000002TSzX");

	// Run through and check all required fields
	with (thisform) {
	
		// Check first name
		if (validate_required(fname,"First Name must be filled out!")==false) {
			fname.focus();
			return false;
		}
		
		// Check last name
		if (validate_required(lname,"Last Name must be filled out!")==false) {
			lname.focus();
			return false;
		}
		
		// Check title
		if (validate_required(titl,"Title must be filled out!")==false) {
			titl.focus();
			return false;
		}
			 
		// Check email
		if (validate_required(eml,"Email must be filled out!")==false) {
			eml.focus();
			return false;
		}
		
		// Validate email
		if (validate_email(eml,"Invalid Email Address!")==false) {
			eml.focus();
			return false;
		}
		
		// Check phone
		if (validate_required(pho,"Telephone # must be filled out!")==false) {
			pho.focus();
			return false;
		}
		
		// Validate phone
		if (validate_number(pho,"The phone number you entered is not valid.\r\nNo letters allowed.")==false) {
			pho.focus();
			return false;
		}
		
		// Validate mobile if entered 
		if (mble != "") {
			if (validate_number(mble,"The mobile number you entered is not valid.\r\nNo letters allowed.")==false) {
				mble.focus();
				return false;
			}
		}	
		
		// Validate fax if entered 
		if (fx.value != "") {
			if (validate_number(fx,"The fax number you entered is not valid.\r\nNo letters allowed.")==false) {
				fx.focus();
				return false;
			}
		}
		
		// Check company
		if (validate_required(cmpy,"Company must be filled out!")==false) {
			cmpy.focus();
			return false;
		}
		
		// Check website
		if (validate_required(wbste,"Website must be filled out!")==false) {
			wbste.focus();
			return false;
		}
		
		// Check street
		if (validate_required(strt,"Street must be filled out!")==false) {
			strt.focus();
			return false;
		}
		
		// Check city
		if (validate_required(cty,"City must be filled out!")==false) {
			cty.focus();
			return false;
		}
		
		// Check state
		if (validate_required(stte,"State must be filled out!")==false) {
			stte.focus();
			return false;
		}
		
		// Check zip
		if (validate_required(zp,"Zip must be filled out!")==false) {
			zp.focus();
			return false;
		}
		
		// Check country
		if (validate_required(cntry,"Country must be filled out!")==false) {
			cntry.focus();
			return false;
		}
		
		// Check years in business
		if (validate_required(yib,"Years in business must be filled out!")==false) {
			yib.focus();
			return false;
		}
		
		// Check number of locations
		if (validate_required(nol,"Number of locations must be filled out!")==false) {
			nol.focus();
			return false;
		}
		
		// Check employees
		if (validate_required(emply,"Employees must be filled out!")==false) {
			emply.focus();
			return false;
		}
		
		// Validate employees
		if (validate_number(emply,"The employees you entered are not valid.\r\nNo letters allowed.")==false) {
			emply.focus();
			return false;
		}
		
		// Check revenue
		if (validate_required(reve,"Revenue must be filled out!")==false) {
			reve.focus();
			return false;
		}
		
		// Validate revenue
		if (validate_number(reve,"The annual revenue you entered is not valid.\r\nNo letters allowed.")==false) {
			reve.focus();
			return false;
		}
		
		// Check business model
		if (validate_required(bm,"Business model must be filled out!")==false) {
			bm.focus();
			return false;
		}
		
		// Check reseller type
		if (retail.checked == false && online.checked == false && distributor.checked == false && catalog.checked == false) {
			alert ('You must choose atleast 1 reseller type!');
			retail.focus();
			return false;
		}
		
		// Check product of interest
		if (bpacks.checked == false && cases.checked == false && ispeakers.checked == false) {
			alert ('You must choose atleast 1 product of interest!');
			bpacks.focus();
			return false;
		}
		
		// Check description
		if (validate_required(descrn,"Description must be filled out!")==false) {
			descrn.focus();
			return false;
		}
		
		// Check agree to terms
		if (wf.checked == false) {
			alert ('You must agree to terms & conditions!');
			wf.focus();
			return false;
		}
		
	}

}

///// End Reseller Inquiry /////

///// Start Technical Support Inquiry /////

function validate_support(thisform) {
	
	var street = document.getElementById("00N80000002TZlw"); // Street
	var city = document.getElementById("00N800000030rpa"); // City
	var state = document.getElementById("00N80000002TZmG"); // State
	var zip = document.getElementById("00N80000002TZmL"); // Zip
	var country = document.getElementById("00N80000002TZmQ"); // Country
	var product = document.getElementById("00N80000002TZls"); // Product
	var purchaseDate = document.getElementById("00N80000002TZrk"); // Purchase Date
	var reason = document.getElementById("00N80000002TZtK"); // Reason
	var subject = document.getElementById("subject"); // Subject
	var explanation = document.getElementById("description"); // Purchase Date
	
    with (thisform) {
      if (validate_required(name,"Name must be filled out!")==false)
         {name.focus();return false;}
      if (validate_email(email,"Invalid Email Address!")==false)
         {email.focus();return false;}
      if (validate_required(phone,"Phone Number must be filled out!")==false)
         {phone.focus();return false;}
      if (validate_required(street,"Street must be filled out!")==false)
         {street.focus();return false;}
      if (validate_required(city,"City must be filled out!")==false)
         {city.focus();return false;}
      if (validate_required(state,"State must be filled out!")==false)
         {state.focus();return false;}
      if (validate_required(zip,"Zip Code must be filled out!")==false)
         {zip.focus();return false;}
      if (validate_required(country,"Country must be filled out!")==false)
         {country.focus();return false;}
      if (validate_required(product,"Product must be filled out!")==false)
         {product.focus();return false;}
      if (validate_required(purchaseDate,"Purchase Date must be filled out!")==false)
         {purchaseDate.focus();return false;}
      if (validate_required(reason,"Reason for Contacting must be filled out!")==false)
         {reason.focus();return false;}
      if (validate_required(subject,"Subject must be filled out!")==false)
         {subject.focus();return false;}
      if (validate_required(explanation,"Explanation must be filled out!")==false)
         {explanation.focus();return false;}
    }
 }
  
///// End Technical Support Inquiry /////

///// Start Customer Support Inquiry /////

function validate_cService(thisform) {
	
	var subject = document.getElementById("subject"); // Subject
	var explanation = document.getElementById("description"); // Purchase Date
	
    with (thisform) {
      if (validate_required(name,"Name must be filled out!")==false)
         {name.focus();return false;}
      if (validate_email(email,"Invalid Email Address!")==false)
         {email.focus();return false;}
      if (validate_required(phone,"Phone Number must be filled out!")==false)
         {phone.focus();return false;}
      if (validate_required(subject,"Subject must be filled out!")==false)
         {subject.focus();return false;}
      if (validate_required(explanation,"Description must be filled out!")==false)
         {explanation.focus();return false;}
    }
 }
  
///// End Customer Support Inquiry /////


///// Start Product Registration Inquiry /////

function validate_pRegistration(thisform) {
	
	var street = document.getElementById("00N80000002TZlw"); // Street
	var city = document.getElementById("00N800000030rpa"); // City
	var state = document.getElementById("00N80000002TZmG"); // State
	var zip = document.getElementById("00N80000002TZmL"); // Zip
	var country = document.getElementById("00N80000002TZmQ"); // Country
	var product = document.getElementById("00N80000002TZls"); // Product
	var purchaseLoc = document.getElementById("00N80000002TZt0"); // Purchase Location
	var orderNum = document.getElementById("00N800000030pPU"); // Order Number
	var purchaseDate = document.getElementById("00N80000002TZrk"); // Purchase Date
	var serialno = document.getElementById("00N800000030rrL"); // Serial Number
	
    with (thisform) {
      if (validate_required(name,"Name must be filled out!")==false)
         {name.focus();return false;}
      if (validate_email(email,"Invalid Email Address!")==false)
         {email.focus();return false;}
      if (validate_required(phone,"Phone Number must be filled out!")==false)
         {phone.focus();return false;}
      if (validate_required(street,"Street must be filled out!")==false)
         {street.focus();return false;}
      if (validate_required(city,"City must be filled out!")==false)
         {city.focus();return false;}
      if (validate_required(state,"State must be filled out!")==false)
         {state.focus();return false;}
      if (validate_required(zip,"Zip Code must be filled out!")==false)
         {zip.focus();return false;}
      if (validate_required(country,"Country must be filled out!")==false)
         {country.focus();return false;}
      if (validate_required(purchaseLoc,"Purchase Location must be filled out!")==false)
         {purchaseLoc.focus();return false;}
      if (validate_required(orderNum,"Order Number must be filled out!")==false)
         {orderNum.focus();return false;}
      if (validate_required(purchaseDate,"Purchase Date must be filled out!")==false)
         {purchaseDate.focus();return false;}
      if (validate_required(product,"Product must be filled out!")==false)
         {product.focus();return false;}
      if (validate_required(serialno,"Serial Number must be filled out!")==false)
         {serialno.focus();return false;}
    }
 }
  
///// End Product Registration Inquiry /////

///// Start Preload Images /////

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];}}
}

///// End Preload Images /////

///// Start Standard Popup Window /////

function NewWindow(url, title, w, h) {
var left = (screen.width - w) / 2;
var top = (screen.height - h) / 2;
var attributes = 'height='+h+',width='+w+',top='+top+',left='+left+'resizable=yes,scrollbars=yes';
window.open(url, title, attributes)
}

///// End Standard Popup Window /////

///// Start Product Tabs /////

// Define an array variable
var tabsArray = new Array();

// Show & Hide Function
function tabsSwitch(piece) {
	for (var i = 0; i<tabsArray.length; i++) {
		var tmp = tabsArray[i];
		document.getElementById(tmp + "Box").style.display = "none";
		document.getElementById(tmp + "Tab").className = "tabbedOff";
	}
	document.getElementById(piece + "Box").style.display = "block";
	document.getElementById(piece + "Tab").className = "tabbedOn";
}

///// End Product Tabs /////

///// Start Web/Mobile Cookie /////

function doesCookieExist(name) {
	var value=null;
	value=getCookieValue(name);
	if (value==null) {
		return false;
	}
	return true;
}

function getCookieValue(name) {
	var cookies=null;
	var cookiePackage=null;
	var value=null;
	var index;
	if (!document.cookie||document.cookie==null) {
		return null;
	}
	cookies=document.cookie.split(';');
	for (index=0;index<cookies.length;index++) {
		cookiePackage=cookies[index];
		while (cookiePackage.charAt(0)==' ') {
			cookiePackage=cookiePackage.substring(1,cookiePackage.length);
		}
		if (cookiePackage.indexOf(name+'=')==0) {
			value=cookiePackage.substring(name.length+1);
			if (value==null||value=='') {
				return'';
			} else {
				return value;
			}
		}
	}
	return null;
}

function addCookie(name,value) {
	document.cookie=escape(name)+'='+escape(value)+'; path=/';
}

function deleteCookie(name) {
	document.cookie=escape(name)+'=; expires=-1; path=/';
}

///// End Web/Mobile Cookie /////

///// Start Apple WebKit Mobile Detect /////

/* 
Copyright (C) 2006 Joost de Valk, http://www.joostdevalk.nl/.  All rights reserved.
Copyright (C) 2006 Mark Rowe, http://bdash.net.nz/.  All rights reserved.
Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Script used for recognizing Safari / Shiira / WebKit. 
A matrix of WebKit versions and OS X versions can be found at:
http://developer.apple.com/internet/safari/uamatrix.html .
*/

function parse_webkit_version(version) {
  var bits = version.split(".");
  var is_nightly = (version[version.length - 1] == "+");
  if (is_nightly) {
    var minor = "+";
  } else {
    var minor = parseInt(bits[1]);
    // If minor is Not a Number (NaN) return an empty string
    if (isNaN(minor)) {
      minor = "";
    }
  }
  return {major: parseInt(bits[0]), minor: minor, is_nightly: is_nightly};
}

function get_webkit_version() {
  var browser = "";
    
  // Check for Safari
  var regex = new RegExp("Mozilla/5.0 \\(.*\\) AppleWebKit/(.*) \\(KHTML, like Gecko\\) Version/.* Safari/(.*)");
  var matches = regex.exec(navigator.userAgent);
  if (matches) {
    var browser = "Safari "+matches[2];
    var webkit_version = parse_webkit_version(matches[1]);    
  } 
  
  // Check for Shiira
  var regex = new RegExp("Mozilla/5.0 \\(.*\\) AppleWebKit/(.*) \\(KHTML, like Gecko\\) Shiira/(.*) Safari/(.*)");
  var matches = regex.exec(navigator.userAgent);
  if (matches) {
    var browser = "Shiira "+matches[2];
    var webkit_version = parse_webkit_version(matches[1]);
  } 

  // Check for OmniWeb 4 or 5
  var regex = new RegExp("Mozilla/5.0 \\(.*\\) AppleWebKit/(.*) \\(KHTML, like Gecko\\) OmniWeb/v(.*) ");
  var matches = regex.exec(navigator.userAgent);
  if (matches) {
    var browser = "OmniWeb "+matches[2];
    var webkit_version = parse_webkit_version(matches[1]);
  }

  // Check for OmniWeb 5.1 and up
  var regex = new RegExp("Mozilla/5.0 \\(.*\\) AppleWebKit/(.*) \\(KHTML, like Gecko, Safari\\) OmniWeb/v(.*) ");
  var matches = regex.exec(navigator.userAgent);
  if (matches) {
    var browser = "OmniWeb "+matches[2];
    var webkit_version = parse_webkit_version(matches[1]);
  }

  // Check for NetNewsWire 2 and higher
  var regex = new RegExp("Mozilla/5.0 \\(.*\\) AppleWebKit/(.*) (KHTML, like Gecko) NetNewsWire/(.*)");
  var matches = regex.exec(navigator.userAgent);
  if (matches) {
    var browser = "NetNewsWire "+matches[2];
    var webkit_version = parse_webkit_version(matches[1]);
  }

  // Check for RealPlayer
  var regex = new RegExp("Mozilla/5.0 \\(.*\\) AppleWebKit/(.*) (KHTML, like Gecko) RealPlayer/(.*)");
  var matches = regex.exec(navigator.userAgent);
  if (matches) {
    var browser = "RealPlayer "+matches[2];
    var webkit_version = parse_webkit_version(matches[1]);
  }
  
  // Check for iPhone
  var regex = new RegExp("Mozilla/5.0 \\((.*)\\) AppleWebKit/(.*) \\(KHTML, like Gecko\\) Version/.* Mobile/(.*) Safari/(.*)");
  var matches = regex.exec(navigator.userAgent);
  if (matches) {
    var deviceName = matches[1].split(";")[0];
    var mobileVersion = matches[3];
    var browserVersion = matches[4];
    var browser = deviceName+" "+mobileVersion+" "+browserVersion;
    var webkit_version = parse_webkit_version(matches[2]);
  }  

  if (browser == "") {
    var webkit_version = {major: "Not Webkit", minor: "Not Webkit", is_nightly: "Not Webkit"};
    var browser = "Not webkit";
  }
  
  return {major: webkit_version['major'], minor: webkit_version['minor'], is_nightly: webkit_version['is_nightly'], browser: browser};
}

///// End Apple WebKit Mobile Detect /////

///// Start Continue Shopping Code /////

function continueShopping() {
	var referrer = null;
	var referrerPage = null;
	var defaultPage = '/';
	var currentPage = window.location.pathname;
	var currentHost = window.location.host;
	var productURL = null;
	
	//Make sure the property exists
	if(document.referrer) {
		referrer = document.referrer;
	}

	//Get the product URL, if any
	try {
		productURL = getProductHistoryURL();				
	} catch(e) {
		productURL = null;
	}
	defaultPage = (productURL == null ? defaultPage : productURL);
				
	//Make sure we have something first
	if(referrer == null || referrer == '') {
		window.location.href = defaultPage;
		return;
	}
	
	try {
		hostPosition = referrer.indexOf(currentHost)
		
		//Check for not found
		if(hostPosition == -1) {
			//Incorrect host
			window.location.href = defaultPage;
			return;	
		}
		
		//Extract the path
		referrerPage = referrer.substring( (hostPosition + currentHost.length));

		//Check to see if we are on the same page
		if(referrerPage.toLowerCase() == currentPage.toLowerCase()) {
			window.location.href = defaultPage;
			return;			
		}
		
		window.location.href = referrerPage;
		return;
	}
	catch(e) {
		//Error, just redirect to default
		window.location.href = defaultPage;
		return;				
	}
}

/**
 * 
 */
function getProductHistoryURL() {
	//%2FHistory
	// /History
	var cookieName = '%2FHistory';
	var cookies = null;
	var cookiePackage = null;
	var productCode = null;
	var productCodes = null;
	
	if(!document.cookie || document.cookie == null) {
		return null;
	}
	
	//Divide up the cookies
	cookies = document.cookie.split(';');

	for(index = 0; index < cookies.length; index++) {
		cookiePackage = cookies[index];
		while(cookiePackage.charAt(0) == ' ') {
			cookiePackage = cookiePackage.substring(1, cookiePackage.length);
		} 
				
		if(cookiePackage.indexOf(cookieName + '=') == 0) {
			productCode = cookiePackage.substring(cookieName.length + 1);
			
			//Check for empty
			if(productCode == null || productCode == '') {
				return null;
			}
			
			//Split up the codes
			productCodes = productCode.split('%2C');
			
			//Return the URL
			return '/ProductDetails.asp?ProductCode=' + productCodes[0];
		}
	}
	
	return null;
}

///// End Continue Shopping Code /////