//set cookie and check cookie

	function checkPreviousPage()
		{
			setCookie("checkpreviouspage","",1);
			 var bd = document.getElementById("brandmodel");
			 if(bd == null)
			 {
				//alert("fail");
			}
			else
			{
			//var bdv = bd.nodeValue;
			//alert(bd.innerHTML)
			setCookie("checkpreviouspage",bd.innerHTML,1);
						//alert(bd.innerHTML)										
			}
	}
	function getCookie(c_name)
	 {
			if (document.cookie.length>0)
			{			
				c_start=document.cookie.indexOf(c_name + "=")			
				if (c_start!=-1)			
			   { 		
				   c_start=c_start + c_name.length+1 		
				   c_end=document.cookie.indexOf(";",c_start)		
				   if (c_end==-1) c_end=document.cookie.length		
				   return unescape(document.cookie.substring(c_start,c_end))		
			   } 			
			}
			return ""
	 }
	 function setCookie(c_name,value,expiredays)
	 {		
	 		
		var today = new Date();

		today.setTime( today.getTime() );

		if ( expiredays ) {

		expiredays = expiredays * 1000 * 60 * 3; //cookie will expire in 3 min
	
		}

		var expires_date = new Date( today.getTime() + (expiredays) );
		document.cookie = c_name+'='+escape( value ) + ( ( expiredays ) ? ';expires='+expires_date.toGMTString() : '' );  	 
	 		//var expires_date=new Date();
			//expires_date.setDate(exdate.getDate()+expiredays);
			//document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
			
	 
	 }
	 
    start = function() {
        // get the reference for the body
	
    var bd = getCookie("checkpreviouspage");
	if (bd != "")
	{
	var name = document.getElementById("pname");
 	var model = document.createElement("span");
		
	var cellText = document.createTextNode(" (works with " + bd + ")");
    model.appendChild(cellText);
	name.appendChild(model);
	//highlightSearchTerms(bd,1);
	}
	setCookie("checkpreviouspage","",1);
	
		
/*URL Model Funciton*/
	var alink = new String(window.location);
	var parameterOfLink = alink.split("?");

	if(parameterOfLink.length>1){
		//var divItem = window.document.getElementById("urlmodel");
		
		var name = document.getElementById("pname");
		var model2 = document.createElement("span");
		//model2.style.color = "red";
		//model2.style.margin="0 5px 0 0";
		var model = new String(parameterOfLink[1]);
		var value = model.split("model=");

		var repStr = new String(value[1]);
	
		if(repStr.indexOf("+") != -1){
   		
			while(repStr.indexOf("+") != -1){
   	 			repStr = repStr.replace("+", " ");
   			}
			
  		}else if(repStr.indexOf("%20") != -1){
		   while(repStr.indexOf("%20") != -1){
    			repStr = repStr.replace("%20", " ");
   			}
		  }
		
		if(repStr !="" && repStr !="undefined"){
		
		var cellText = document.createTextNode(" (works with " +  repStr + ")");
		model2.appendChild(cellText);
		name.appendChild(model2);
		highlightSearchTerms(repStr,1);
		
		 //var cellTextx = document.createTextNode(repStr+" ");
	     //model2.appendChild(cellTextx);
 		 //var parentDiv = name.parentNode;
		 //parentDiv.insertBefore(model2, name);
	
		}
	}

/*	end of url model function*/
	
    }

//
function SimpleSwap(el,which){
  el.src=el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var oversrc = x[i].getAttribute("oversrc");
    if (!oversrc) continue;
      
    // preload image
    // comment the next two lines to disable image pre-loading
    //x[i].oversrc_img = new Image();
    //x[i].oversrc_img.src=oversrc;
    // set event handlers
    x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
    x[i].onmouseout = new Function("SimpleSwap(this);");
    // save original src
    x[i].setAttribute("origsrc",x[i].src);
  }
}

var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();}

function open_window(url, settings){
	mywin = window.open(url,"win",settings);
	
	}
	
// New HoverIMG

var offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset

var displayduration=0; //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 180;	// maximum image size.

if (document.getElementById || document.all){
	document.write('<div id="trailimageid">');
	document.write('</div>');
}

function gettrailobj(){
if (document.getElementById)
return document.getElementById("trailimageid").style
else if (document.all)
return document.all.trailimagid.style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("trailimageid")
else if (document.all)
return document.all.trailimagid
}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showtrail(imagename,title,description,showthumb,height,filetype){
	if (height > 0){
		currentimageheight = height;
	}

	document.onmousemove=followmouse;

	/*	cameraHTML = '';


	if ( !ratingnumber ){
		ratingnumber = 0;
		ratingaverage = 0;
	}
for(x = 1; x <= 5; x++){

		if (ratingaverage >= 1){
			cameraHTML = cameraHTML + '<img src="/images/camera_1.gif">';
		} else if (ratingaverage >= 0.5){
			cameraHTML = cameraHTML + '<img src="/images/camera_05.gif">';
		} else {
			cameraHTML = cameraHTML + '<img src="/images/camera_0.gif">';
		}
	
		ratingaverage = ratingaverage - 1;
	}

	cameraHTML = cameraHTML + ' (' + ratingnumber + ' Review';
	if ( ratingnumber > 1 ) cameraHTML += 's';
	cameraHTML = cameraHTML + ')';
*/
	newHTML = '<div style="padding: 5px; background-color: #FFF; border: 1px solid #888;">';
	newHTML = newHTML + '<strong>' + title + '</strong>';
	//newHTML = newHTML + 'Rating: ' + cameraHTML + '<br/>';
	newHTML = newHTML + description + '<br/>';

	if (showthumb > 0){
		newHTML = newHTML + '<div style="padding: 0px 2px 2px 2px;">';
		newHTML = newHTML + '<img src="' + imagename + '" border="0"></div>';
	}

	newHTML = newHTML + '</div>';
	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobj().display="inline";
}

function showtrailBatch(imagename,title,filetype){
	document.onmousemove=followmouseBatch;

	cameraHTML = '';

	newHTML = '<div style="padding: 5px; background-color: #FFF; border: 1px solid #888;" id="trailInnerDiv">';
	newHTML = newHTML + '<strong>' + title + '</strong>';

	newHTML = newHTML + '<div style="padding: 0px 2px 2px 2px;">';
	newHTML = newHTML + '<img src="' + imagename + '" border="0"></div>';
	

	newHTML = newHTML + '</div>';
	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobj().display="inline";
	gettrailobj().position="absolute";
	currentimageheight = $('trailInnerDiv').offsetHeight;
	
}


function hidetrail(){
	gettrailobj().innerHTML = " ";
	gettrailobj().display="none"
	document.onmousemove=""
	gettrailobj().left="-500px"

}

function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	//if (document.all){
	//	gettrailobjnostyle().innerHTML = 'A = ' + truebody().scrollHeight + '<br>B = ' + truebody().clientHeight;
	//} else {
	//	gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br>D = ' + window.innerHeight;
	//}

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 200){
			xcoord = e.pageX - xcoord - 200; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 110)){
			ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 200){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 200; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 110)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}

function followmouseBatch(e){
	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	var trailInnerDiv = $('trailInnerDiv');
	var currentimageheight = trailInnerDiv.offsetHeight;
	var currentimagewidth = trailInnerDiv.offsetWidth;

	scrollPos = Position.realOffset(truebody());
	
	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 200){
			xcoord = e.pageX - xcoord - 200; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if ((e.pageY - scrollPos[1]) + currentimageheight > docheight){
			ycoord = -ycoord + (e.pageY - currentimageheight);
		} else {
			ycoord += e.pageY;
		}
	} else if (typeof window.event != "undefined"){
		if (event.clientX + currentimagewidth > docwidth){
			xcoord = -xcoord + ((event.clientX + scrollPos[0]) - currentimagewidth); // Move to the left side of the cursor
		} else {
			xcoord += (event.clientX + scrollPos[0]);
		}
		if (event.clientY + currentimageheight > docheight){
			ycoord = -ycoord + ((event.clientY + scrollPos[1]) - currentimageheight);
		} else {
			ycoord += (event.clientY + scrollPos[1]);
		}
	}

	if(ycoord < 0) { ycoord = ycoord*-1; }

	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}
//====================================
//Common functions
//====================================
function verifyNewsletterSingup(f)
{
    var msg;
    var empty_fields = "";
    var errors = "";
    var error_msg = "";

	f = eval('document.' + f);


	if ((f.ea.value == null) || (f.ea.value == "") || isblank(f.ea.value))
	{
		error_msg = "* Your email field is empty.";
        empty_fields += "\n      " + error_msg;
    }


    else if (f.ea.value.indexOf("@")==-1)
    {
		error_msg = "* Your email address is invalid";
        empty_fields += "\n      " + error_msg;
    }

    if (!empty_fields && !errors)
    {
		return true;
	}
    msg  = "  Your request cannot continue. \n";
    msg += "  Please correct the following error(s) and re-submit:\n";
    msg += "_______________________________________________\n";

    if (empty_fields) {
        msg += empty_fields + "\n";
    }
    alert(msg);
    return false;

	
}

// Commom popup window function

function isblank(s)
{
	for(var i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if ((c != ' ')&&(c != '\n')&&(c != '\t')) return false;
	}
	return true;
}
function open_window(url,settings)
{ mywin = window.open(url,"win",settings); }
function makeWin(imsrc, ww, wh) {
ww=ww+25; wh=wh+50;
w1=window.open('','w1','width='+ww+',height='+wh+',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
w1.document.open();
w1.document.write("html><head><title>Image Zoom<\/title><META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\"><META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\"><\/head>");
w1.document.write("<body bgcolor='#FFFFFF' text='#000000' leftmargin=2 topmargin=10><p align=center>");
w1.document.write("<img name=theimg src=" + imsrc + "><br>");
w1.document.write("<a href=\"javascript:window.close();\"><font size=1 face=tahoma color=#000000>close window<\/font><\/a><\/body><\/html>");
w1.document.focus();
};
var selectBoxFlag = 0;

topNav = function() {
	if ((document.all)&&(document.getElementById)&&(cssdropdownRoot = $('nav_list'))) {
		cssdropdownRoot = $('nav_list').getElementsByTagName('li');
		nodes = $A(cssdropdownRoot);
		for (x=0; x<nodes.length; x++) { // length = 7
			node = nodes[x];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					// mimics the :hover functionality
					this.className+=" over";
					selectBoxFlag++;
					hideSelectBoxes('hidden');
				}
				node.onmouseout=function() {
					// mimics the :hover functionality
					this.className=this.className.replace(" over", "");
					selectBoxFlag--;
					if (!selectBoxFlag) hideSelectBoxes('visible');
				}
			}
		}
	}
}
hideSelectBoxes = function(action) {
	if ((action == 'visible') && (selectBoxFlag)) return;
	else if ((browser.isIE6x) && ($('content') && (selectRoot = $('content').getElementsByTagName('select')))) {
		for (i=0; i<selectRoot.length; i++ ) {
			if (selectRoot[i].className.match(/elementToHideOnMenuOpen/)) {
				selectRoot[i].style.visibility = action;
			}
		}
	}
}
// These functions are activated upon page load. They embed JavaScript without function calls from appearing within the HTML.
init = function() {
//	utilityNav(); // activate utility navigational links
	topNav(); // activate top navigation
	//rollover(); // general function for embedded image rollovers
	//eventFinder(); // embeds functions to HREFs 
	//adjust(); // general function for javascript to control browser compatibility issues
	//productDetails(); // function to call Product Detail related functions
	//productDetailLearn(); // function to check for Learning section
	//checkCTO(); // prevents overlap of summary module on CTO pages when there is not enough content
	//isQuickRegister(); // hides select boxes for the entire page for IE6 browsers only.
	//showLogonForm(); // validates the page is checkout landing and loads the appropriate state.
	start();
	//highlightSearchTerms(1);
}


// Standard Global Fully Browser-compat onload function init call.
if (window.addEventListener)
window.addEventListener("load", init, false)
else if (window.attachEvent)
window.attachEvent("onload", init)
else if (document.getElementById)
window.onload=init;

function includeJs(libraryName) {
	document.write('<script type="text/javascript" src="/lib/yhst-66763527056125/'+libraryName+'"></script>');
}

includeJs("SpryTabbedPanels.js");
includeJs("prototype.js");
includeJs("browser-detect.js");
includeJs("scriptaculous.js?load=effects");
includeJs("lightbox.js");

//highlight function
function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{
  // the highlightStartTag and highlightEndTag parameters are optional
  if ((!highlightStartTag) || (!highlightEndTag)) {
    highlightStartTag = "<font style='color:blue; background-color:yellow;'>";
    highlightEndTag = "</font>";
  }
  
  // find all occurences of the search term in the given text,
  // and add some "highlight" tags to them (we're not using a
  // regular expression search, because we want to filter out
  // matches that occur within HTML tags and script blocks, so
  // we have to do a little extra validation)
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();
    
  while (bodyText.length > 0) {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0) {
      newText += bodyText;
      bodyText = "";
    } else {
      // skip anything inside an HTML tag
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
        // skip anything inside a <script> block
        if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
          newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
          bodyText = bodyText.substr(i + searchTerm.length);
          lcBodyText = bodyText.toLowerCase();
          i = -1;
        }
      }
    }
  }
  
  return newText;
}

/*
 * This is sort of a wrapper function to the doHighlight function.
 * It takes the searchText that you pass, optionally splits it into
 * separate words, and transforms the text on the current web page.
 * Only the "searchText" parameter is required; all other parameters
 * are optional and can be omitted.
 */
function highlightSearchTerms(searchText,treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
  // if the treatAsPhrase parameter is true, then we should search for 
  // the entire phrase that was entered; otherwise, we will split the
  // search string so that each word is searched for and highlighted
  // individually
 	//var alinkx = new String(window.location);
	//var parameterOfLinkx = alinkx.split("?");
	//if(parameterOfLinkx.length>1){
//	var model3 = new String(parameterOfLinkx[1]);
//	var value = model3.split("model=");

//	var repStrx = new String(value[1]);
	
//	if(repStrx.indexOf("+") != -1){
   		
//		while(repStrx.indexOf("+") != -1){
 //  	 		repStrx = repStrx.replace("+", " ");
 //  		}
			
//  	}else if(repStrx.indexOf("%20") != -1){
//		while(repStrx.indexOf("%20") != -1){
 //   		repStrx = repStrx.replace("%20", " ");
 //  		}
//	 }
		  
  if (treatAsPhrase) {
    searchArray = [searchText];
  } else {
    searchArray = searchText.split(" ");
  }
  
  var bodyText = document.body.innerHTML;
  for (var i = 0; i < searchArray.length; i++) {
    bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
  }
  
  document.body.innerHTML = bodyText;
  return true;
	}
//}


//hilight function
/*
Hilite={elementid:"content",exact:true,max_nodes:1000,onload:true,style_name:"hilite",style_name_suffix:true,debug_referrer:""};
Hilite.search_engines=[["google\\.","q"],["search\\.yahoo\\.","p"],["search\\.msn\\.","q"],["search\\.live\\.","query"],["search\\.aol\\.","userQuery"],["ask\\.com","q"],["altavista\\.","q"],["feedster\\.","q"],["search\\.lycos\\.","q"],["alltheweb\\.","q"],["technorati\\.com/search/([^\\?/]+)",1],["dogpile\\.com/info\\.dogpl/search/web/([^\\?/]+)",1,true]];

Hilite.decodeReferrer=function(_1)
{var _2=null;var _3=new RegExp("");
for(var i=0;i<Hilite.search_engines.length;i++){var se=Hilite.search_engines[i];_3.compile("^http://(www\\.)?"+se[0],"i");var _6=_1.match(_3);if(_6){var _7;if(isNaN(se[1])){_7=Hilite.decodeReferrerQS(_1,se[1]);}else{_7=_6[se[1]+1];}if(_7){_7=decodeURIComponent(_7);
if(se.length>2&&se[2]){_7=decodeURIComponent(_7);}_7=_7.replace(/\'|"/g,"");_7=_7.split(/[\s,\+\.]+/);return _7;}break;}}return null;};

Hilite.decodeReferrerQS=function(_8,_9)
{var _a=_8.indexOf("?");var _b;if(_a>=0){var qs=new String(_8.substring(_a+1));_a=0;_b=0;
while((_a>=0)&&((_b=qs.indexOf("=",_a))>=0))
{var _d,val;_d=qs.substring(_a,_b);_a=qs.indexOf("&",_b)+1;if(_d==_9){if(_a<=0){return qs.substring(_b+1);}else{return qs.substring(_b+1,_a-1);}}}}return null;};Hilite.hiliteElement=function(_e,_f)
{if(!_f||_e.childNodes.length==0){return;}var qre=new Array();for(var i=0;i<_f.length;i++){_f[i]=_f[i].toLowerCase();if(Hilite.exact){qre.push("\\b"+_f[i]+"\\b");}else{qre.push(_f[i]);}}qre=new RegExp(qre.join("|"),"i");var _12={};for(var i=0;i<_f.length;i++){if(Hilite.style_name_suffix){_12[_f[i]]=Hilite.style_name+(i+1);}else{_12[_f[i]]=Hilite.style_name;}}var _14=function(_15){var _16=qre.exec(_15.data);if(_16){var val=_16[0];var k="";
var _19=_15.splitText(_16.index);var _1a=_19.splitText(val.length);var _1b=_15.ownerDocument.createElement("SPAN");
_15.parentNode.replaceChild(_1b,_19);_1b.className=_12[val.toLowerCase()];_1b.appendChild(_19);return _1b;}else{return _15;}};
Hilite.walkElements(_e.childNodes[0],1,_14);};Hilite.hilite=function(){var q=Hilite.debug_referrer?Hilite.debug_referrer:document.referrer;var e=null;
q=Hilite.decodeReferrer(q);if(q&&((Hilite.elementid&&(e=document.getElementById(Hilite.elementid)))||(e=document.body))){Hilite.hiliteElement(e,q);}};
Hilite.walkElements=function(_1e,_1f,_20){
var _21=/^(script|style|textarea)/i;
var _22=0;while(_1e&&_1f>0){_22++;
if(_22>=Hilite.max_nodes){var _23=function(){Hilite.walkElements(_1e,_1f,_20);};
setTimeout(_23,50);return;}if(_1e.nodeType==1){if(!_21.test(_1e.tagName)&&_1e.childNodes.length>0){_1e=_1e.childNodes[0];_1f++;continue;}}else{if(_1e.nodeType==3){_1e=_20(_1e);}}if(_1e.nextSibling){_1e=_1e.nextSibling;}else{while(_1f>0){_1e=_1e.parentNode;_1f--;if(_1e.nextSibling){_1e=_1e.nextSibling;break;}}}}};if(Hilite.onload){if(window.attachEvent){window.attachEvent("onload",Hilite.hilite);}
else{if(window.addEventListener){window.addEventListener("load",Hilite.hilite,false);}else
{var __onload=window.onload;
window.onload=function(){Hilite.hilite();__onload();};}}}
*/