var useEfSch = false;
var useEf2Sch = false;
var searchByYsOnly = 0;
var html = '';
var c = '';

function SearchRedirectPage() {
	var stxt = document.getElementById("SearchBoxQueryTbx").value;

	if(stxt == "")
	{
		alert("You must input Search textbox");
		return false;
	}
	else
	{
		var isEfSchReady = true;
		if(searchByYsOnly == 1) {
			isEfSchReady = false;
		}
		var f = document.forms["SearchBoxFrm"];
		var divv = document.getElementById("TestImageDiv");
		divv.innerHTML = "";
		divv.innerHTML = "<img id=\"CSCheck\" onerror=\"SearchRedirectPage1(false);EfcSearch();\" src=\"http://search10.eforcity.com/EFSearch/images/spacer.gif\" onload=\"SearchRedirectPage1(true);EfcSearch();\" /><img id=\"CSCheck2\" onerror=\"SearchRedirectPage2(false);\" src=\"http://search.eforcity.com/EFSearchTest/images/spacer.gif\" onload=\"SearchRedirectPage2(true);\" />";

		if(useEfSch == true && isEfSchReady == true) {
			f.oid = OID;
			f.lid = LID;
			f.mp = MP;
			f.action = "http://www.eforcity.com/efsearch2.html";
		}
		else {
			f.action = "http://search.store.yahoo.com/cgi-bin/nsearch";
		}
		return true;
	}
}
function SearchRedirectPage1(result) {
	useEfSch = result;
}
function SearchRedirectPage2(result) {
	useEf2Sch = result;
}
function EfcSearch()
{
	if(document.getElementById("resultsHtml") == null)
	{
		return;
	}
	var qstr='';
	var x=queryString("x");
	var q=queryString("query");
	var qm=queryString("qm");
	var ps=queryString("ps");
	var pg=queryString("pg");
	var pcf=queryString("pcf");
	var pct=queryString("pct");
	var sb=queryString("sb");
	var ic=queryString("ic");
	var qp=queryString("qp");
	var cat=queryString("cat");
	var pt=queryString("pt");
	var bd=queryString("bd");
	var sr=queryString("sr");
	var md=queryString("md");
	var cni=queryString("cni");
	var pni=queryString("pni");
	var bni=queryString("bni");
	var sni=queryString("sni");
	var mni=queryString("mni");
	var sc=queryString("sc");
	var s=queryString("s");

	qstr='&query='+q+'&qm='+qm+'&qp='+qp+'&pcf='+pcf+'&pct='+pct+'&ps='+ps+'&pg='+pg+'&cat='+cat+'&pt='+pt+'&bd='+bd+'&sr='+sr+'&md='+md+'&cni='+cni+'&pni='+pni+'&bni='+bni+'&sni='+sni+'&mni='+mni+'&sc='+sc+'&s='+s+'&sb='+sb+'&ic='+ic+'&oid='+OID+'&lid='+LID;
	var qt=queryString("qt");
	if(qt==""){qt="all";}

	var head = document.getElementsByTagName("head")[0];
	var script = document.createElement("script");
	script.language = "javascript";
	script.type = "text/javascript";
	if(useEfSch == true)
	{
		script.src = "http://search10.eforcity.com/EFSearch/WebSearchEngine.aspx?wsi=1&qt="+qt+qstr+"&x="+x;
	}
	else
	{
		script.src = "http://search.eforcity.com/EFSearchTest/WebSearchEngine.aspx?wsi=1&qt="+qt+qstr+"&x="+x;
	}
	head.appendChild(script);
}
function setBookmark(url,str)
{
    if(str=='')
        { str=url; }
    url = url + trackinglink;
    if (document.all)
        { window.external.AddFavorite(url,str); }
    else
    {
        if (window.sidebar)
        { window.sidebar.addPanel(str, url, ""); }
        else
        { alert('Press CTRL and D to add a bookmark to:\n"'+url+'".'); }
    }
}
function popup(name,url,w,h)
{
    mywindow = window.open (url,name,"location=0,status=0,scrollbars=1,width="+w+",height="+h);
}
function showFaq()
{
    popup('eforcity_com_FAQ','https://www.hostedsupport.com/support/index.cfm?C=11383',800,600);
    //self.location.href='https://www.hostedsupport.com/support/index.cfm?C=11383';
}
function addOnLoadEvent(func)
{
    if (window.addEventListener) {
        window.addEventListener("load", func, false); }
    else if (window.attachEvent) {
        window.attachEvent("onload", func); }
    else if (document.getElementById) {
        window.onload=func; }
}
function addOnChangeEvent(obj,func)
{
    if (obj.addEventListener) {
        obj.addEventListener("change", func, false); }
    else if (obj.attachEvent) {
        obj.attachEvent("onchange", func); }
    else if (document.getElementById) {
        obj.onchange=func; }
}
function printpage() {
    window.print();
}


var persisteduls=new Object();
var ddtreemenu=new Object();

ddtreemenu.closefolder="http://site.eforcity.com/template/Rvmp2/images/common/dotline_plus.jpg"; //set image path to "closed" folder image
ddtreemenu.openfolder="http://site.eforcity.com/template/Rvmp2/images/common/dotline_subtract.jpg"; //set image path to "open" folder image

//ddtreemenu.openhref="Cell Phone Accessories";
//ddtreemenu.openhref="Computer Accessories";
//ddtreemenu.openhref="Camera Accessories";
//ddtreemenu.openhref="DVDs";

//ddtreemenu.openhref="Games";
//ddtreemenu.openhref="MP3 Accessories";
//ddtreemenu.openhref="PDA Accessories";
//ddtreemenu.openhref="Printer Inks";

//ddtreemenu.openhref="Cell Phone Plans";
//ddtreemenu.openhref="Holiday";
//ddtreemenu.openhref="Sports";
//ddtreemenu.openhref="Others";

//////////No need to edit beyond here///////////////////////////

ddtreemenu.createTree=function(treeid, enablepersist, persistdays)
{
    var rootnode=document.getElementById(treeid);
    if(rootnode!=undefined)
    {
    var ultags=document.getElementById(treeid).getElementsByTagName("ul");//get all url gar in parent div

    if (typeof persisteduls[treeid]=="undefined") //get cookie arry of treeid containted.
        persisteduls[treeid]=(enablepersist==true && ddtreemenu.getCookie(treeid)!="")? ddtreemenu.getCookie(treeid).split(",") : "";

    for (var i=0; i<ultags.length; i++)
    {//build subtree in div tree.
        ddtreemenu.buildSubTree(treeid, ultags[i], i);
        if(ddtreemenu.openhref && ddtreemenu.openhref.length>0)
        {
			try
			{
			   if(ultags[i].parentNode.childNodes[0].innerHTML.toLowerCase().match(ddtreemenu.openhref.toLowerCase()))
					call:ultags[i].parentNode.onclick(null);
			}
			catch (err)
			{
			}
        }
    }

    if (enablepersist==true)
    { //if enable persist feature
        var durationdays=(typeof persistdays=="undefined")? 1 : parseInt(persistdays);
        ddtreemenu.dotask(window, function(){ddtreemenu.rememberstate(treeid, durationdays)}, "unload"); //save opened UL indexes on body unload
    }
    }
}



ddtreemenu.buildSubTree=function(treeid, ulelement, index)
{
    ulelement.parentNode.className="submenu";//set super parent node className="submenu";
    if (typeof persisteduls[treeid]=="object")
    { //if cookie exists (persisteduls[treeid] is an array versus "" string)
        if (ddtreemenu.searcharray(persisteduls[treeid], index))
        {
        ulelement.setAttribute("rel", "open");
        ulelement.style.display="block";
        ulelement.parentNode.style.backgroundImage="url("+ddtreemenu.openfolder+")";
        }
        else
        ulelement.setAttribute("rel", "closed");
    } //end cookie persist code

    else if (ulelement.getAttribute("rel")==null || ulelement.getAttribute("rel")==false) //if no cookie and UL has NO rel attribute explicted added by user
        ulelement.setAttribute("rel", "closed");
    else if (ulelement.getAttribute("rel")=="open") //else if no cookie and this UL has an explicit rel value of "open"
        ddtreemenu.expandSubTree(treeid, ulelement); //expand this UL plus all parent ULs (so the most inner UL is revealed!)

    ulelement.parentNode.onclick=function(e)
    {
        var submenu=this.getElementsByTagName("ul")[0];
        if (submenu.getAttribute("rel")=="closed")
        {
            //alert(submenu.innerHTML);
            submenu.style.display="block";
            submenu.setAttribute("rel", "open");
            ulelement.parentNode.style.backgroundImage="url("+ddtreemenu.openfolder+")";
        }
        else if (submenu.getAttribute("rel")=="open")
        {
            //alert(submenu.innerHTML);
            submenu.style.display="none";
            submenu.setAttribute("rel", "closed");
            ulelement.parentNode.style.backgroundImage="url("+ddtreemenu.closefolder+")";
        }
        else
        {
            alert("Error!!");
        }
        ddtreemenu.preventpropagate(e);
    }

    ulelement.onclick=function(e)
    {
        ddtreemenu.preventpropagate(e);
    }
}



ddtreemenu.expandSubTree=function(treeid, ulelement){ //expand a UL element and any of its parent ULs
var rootnode=document.getElementById(treeid);
var currentnode=ulelement;
currentnode.style.display="block";
currentnode.parentNode.style.backgroundImage="url("+ddtreemenu.openfolder+")";
while (currentnode!=rootnode){
if (currentnode.tagName=="UL"){ //if parent node is a UL, expand it too
currentnode.style.display="block";
currentnode.setAttribute("rel", "open"); //indicate it's open
currentnode.parentNode.style.backgroundImage="url("+ddtreemenu.openfolder+")";
}
currentnode=currentnode.parentNode;
}
}



ddtreemenu.flatten=function(treeid, action){ //expand or contract all UL elements
var rootnode=document.getElementById(treeid);
if(rootnode!=undefined)
{
var ultags=rootnode.getElementsByTagName("ul");
for (var i=0; i<ultags.length; i++){
ultags[i].style.display=(action=="expand")? "block" : "none";
var relvalue=(action=="expand")? "open" : "closed";
ultags[i].setAttribute("rel", relvalue);
ultags[i].parentNode.style.backgroundImage=(action=="expand")? "url("+ddtreemenu.openfolder+")" : "url("+ddtreemenu.closefolder+")";
}
}
}


ddtreemenu.rememberstate=function(treeid, durationdays){ //store index of opened ULs relative to other ULs in Tree into cookie
var ultags=document.getElementById(treeid).getElementsByTagName("ul");
var openuls=new Array();
for (var i=0; i<ultags.length; i++){
if (ultags[i].getAttribute("rel")=="open");
openuls[openuls.length]=i; //save the index of the opened UL (relative to the entire list of ULs) as an array element
}
if (openuls.length==0) //if there are no opened ULs to save/persist
openuls[0]="none open"; //set array value to string to simply indicate all ULs should persist with state being closed
ddtreemenu.setCookie(treeid, openuls.join(","), durationdays); //populate cookie with value treeid=1,2,3 etc (where 1,2... are the indexes of the opened ULs)
}





////A few utility functions below//////////////////////

ddtreemenu.getCookie=function(Name){ //get cookie value
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1]; //return its value
return "";
}




ddtreemenu.setCookie=function(name, value, days){ //set cookei value
var expireDate = new Date()
//set "expstring" to either future or past date, to set or delete cookie, respectively
var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days))
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}



ddtreemenu.searcharray=function(thearray, value){ //searches an array for the entered value. If found, delete value from array
var isfound=false;
for (var i=0; i<thearray.length; i++){
if (thearray[i]==value){
isfound=true;
thearray.shift(); //delete this element from array for efficiency sake
break;
}
}
return isfound;
}




ddtreemenu.preventpropagate=function(e)
{ //prevent action from bubbling upwards
    if(e===null) return;
    if(typeof e!="undefined")
        e.stopPropagation();
    else
        event.cancelBubble=true;
}



ddtreemenu.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype;
alert(tasktype);
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false);
else if (target.attachEvent)
target.attachEvent(tasktype, functionref);
}



var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

function checkmail(e){
    var returnval=emailfilter.test(e.value)
    if (returnval==false){
        e.select()
    }
    return returnval
}
function verifySingup(f,emailid) {
  var msg;
  var empty_fields = "";
  var errors = "";
  var error_msg = "";

  var re = new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/);

  var email = document.getElementById(emailid);

  if(email!=undefined)
  {
      if ((email.value == null) || (email.value == "") || isblank(email.value)) {
        error_msg = "* Your email field is empty.";
        empty_fields += "\n      " + error_msg;
      }
      else if (!email.value.match(re)) {
      //else if (f.email.value.indexOf("@")==-1) {
        error_msg = "* Your email address is invalid";
        empty_fields += "\n      " + error_msg;
      }
  }

  if (!empty_fields && !errors) {
    f.method = "POST";
    f.action = "http://subscription.eforcity.com/EmailUnsubscribe/subscribe.aspx?branchId=1";
    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;
}
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 signUp() {
//  var f = document.getElementById('fSignUp');
    var f = document.forms['fSignUp'];

      if(verifySingup(f,'element-formsubscribe-email')) {
        f.submit();
      }
}
function showTab(t,i)
{
    var divObj=document.getElementById(t+"_div"+i);
   	var upObj=document.getElementById(t+"_up"+i);
	var downObj=document.getElementById(t+"_down"+i);
    divObj.style.display="block";
	upObj.style.display="none";
	downObj.style.display="block";

    for(var n=1;n<=99;n++)
    {
        if(n!=i)
        {
            var hidDivObj=document.getElementById(t+"_div"+n);
		    var hidUpObj=document.getElementById(t+"_up"+n);
		    var hidDownObj=document.getElementById(t+"_down"+n);
		    if(hidDivObj!=null && hidDivObj!=undefined)
		    {
                hidDivObj.style.display="none";
            }
            if(hidUpObj!=null && hidUpObj!=undefined)
            {
		        hidUpObj.style.display="block";
            }
            if(hidDownObj!=null && hidDownObj!=undefined)
            {
		        hidDownObj.style.display="none";
		    }
        }
    }
}

// -------------------------------------------------------------------
// Image Thumbnail Viewer II- By Dynamic Drive, available at: http://www.dynamicdrive.com
// Last updated: Feb 5th, 2007
// -------------------------------------------------------------------

var thumbnailviewer2={
enableTitle: true, //Should "title" attribute of link be used as description?
enableTransition: true, //Enable fading transition in IE?
hideimgmouseout: false, //Hide enlarged image when mouse moves out of anchor link? (if enlarged image is hyperlinked, always set to false!)

/////////////No need to edit beyond here/////////////////////////

iefilterstring: 'progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=0.7)', //IE specific multimedia filter string
iefiltercapable: document.compatMode && window.createPopup? true : false, //Detect browser support for IE filters
preloadedimages:[], //array to preload enlarged images (ones set to display "onmouseover"
targetlinks:[], //array to hold participating links (those with rel="enlargeimage:initType")
alreadyrunflag: false, //flag to indicate whether init() function has been run already come window.onload

loadimage:function(linkobj){
var imagepath=linkobj.getAttribute("href") //Get URL to enlarged image
var showcontainer=document.getElementById(linkobj.getAttribute("rev").split("::")[0]) //Reference container on page to show enlarged image in
var dest=linkobj.getAttribute("rev").split("::")[1] //Get URL enlarged image should be linked to, if any
var description=(thumbnailviewer2.enableTitle && linkobj.getAttribute("title"))? linkobj.getAttribute("title") : "" //Get title attr
var imageHTML='<img src="'+imagepath+'" style="border-width: 0" />' //Construct HTML for enlarged image
if (typeof dest!="undefined") //Hyperlink the enlarged image?
imageHTML='<a href="'+dest+'">'+imageHTML+'</a>'
if (description!="") //Use title attr of the link as description?
imageHTML+='<br />'+description
if (this.iefiltercapable){ //Is this an IE browser that supports filters?
showcontainer.style.filter=this.iefilterstring
showcontainer.filters[0].Apply()
}
showcontainer.innerHTML=imageHTML
this.featureImage=showcontainer.getElementsByTagName("img")[0] //Reference enlarged image itself
this.featureImage.onload=function(){ //When enlarged image has completely loaded
if (thumbnailviewer2.iefiltercapable) //Is this an IE browser that supports filters?
showcontainer.filters[0].Play()
}
this.featureImage.onerror=function(){ //If an error has occurred while loading the image to show
if (thumbnailviewer2.iefiltercapable) //Is this an IE browser that supports filters?
showcontainer.filters[0].Stop()
}
},

hideimage:function(linkobj){
var showcontainer=document.getElementById(linkobj.getAttribute("rev").split("::")[0]) //Reference container on page to show enlarged image in
showcontainer.innerHTML=""
},


cleanup:function(){ //Clean up routine on page unload
if (this.featureImage){this.featureImage.onload=null; this.featureImage.onerror=null; this.featureImage=null}
this.showcontainer=null
for (var i=0; i<this.targetlinks.length; i++){
this.targetlinks[i].onclick=null
this.targetlinks[i].onmouseover=null
this.targetlinks[i].onmouseout=null
}
},

addEvent:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
},

init:function(){ //Initialize thumbnail viewer script
this.iefiltercapable=(this.iefiltercapable && this.enableTransition) //True or false: IE filters supported and is enabled by user
var pagelinks=document.getElementsByTagName("a")
for (var i=0; i<pagelinks.length; i++){ //BEGIN FOR LOOP
if (pagelinks[i].getAttribute("rel") && /enlargeimage:/i.test(pagelinks[i].getAttribute("rel"))){ //Begin if statement: Test for rel="enlargeimage"
var initType=pagelinks[i].getAttribute("rel").split("::")[1] //Get display type of enlarged image ("click" or "mouseover")
if (initType=="mouseover"){ //If type is "mouseover", preload the enlarged image for quicker display
this.preloadedimages[this.preloadedimages.length]=new Image()
this.preloadedimages[this.preloadedimages.length-1].src=pagelinks[i].href
pagelinks[i]["onclick"]=function(){ //Cancel default click action
return false
}
}
pagelinks[i]["on"+initType]=function(){ //Load enlarged image based on the specified display type (event)
thumbnailviewer2.loadimage(this) //Load image
return false
}
if (this.hideimgmouseout)
pagelinks[i]["onmouseout"]=function(){
thumbnailviewer2.hideimage(this)
}
this.targetlinks[this.targetlinks.length]=pagelinks[i] //store reference to target link
} //end if statement
} //END FOR LOOP


} //END init() function

}


if (document.addEventListener) //Take advantage of "DOMContentLoaded" event in select Mozilla/ Opera browsers for faster init
thumbnailviewer2.addEvent(document, function(){thumbnailviewer2.alreadyrunflag=1; thumbnailviewer2.init()}, "DOMContentLoaded") //Initialize script on page load
else if (document.all && document.getElementsByTagName("a").length>0){ //Take advantage of "defer" attr inside SCRIPT tag in IE for instant init
thumbnailviewer2.alreadyrunflag=1
thumbnailviewer2.init()
}
thumbnailviewer2.addEvent(window, function(){if (!thumbnailviewer2.alreadyrunflag) thumbnailviewer2.init()}, "load") //Default init method: window.onload
thumbnailviewer2.addEvent(window, function(){thumbnailviewer2.cleanup()}, "unload")

/*
	Header Information------------------------------------[Do Not Remove This Header]--
	Title: OO Dom Image Rollover
	Description: This script makes it easy to add rollover/ mousedown
  	effects to any image on the page, including image submit buttons. Automatically
  	preloads images as well. Script works in all DOM capable browsers- IE5+, NS6+,
  	Opera7+.

	Legal: Copyright 2005 Adam Smith
	Author Email Address: ibulwark@hotmail.com
	Date Created: June 6, 2005
	Website: Codevendor.com | eBadgeman.com
	Script featured on Dynamic Drive: http://www.dynamicdrive.com
	-----------------------------------------------------------------------------------
*/

function imageholderclass(){
	this.over=new Array();
	this.down=new Array();
	this.src=new Array();
	this.store=store;

	function store(src, down, over){
		var AL=this.src.length;
		this.src[AL]=new Image(); this.src[AL].src=src;
		this.over[AL]=new Image(); this.over[AL].src=over;
		this.down[AL]=new Image(); this.down[AL].src=down;
	}
}

var ih = new imageholderclass();
var mouseisdown=0;

function preloader(t){
	for(i=0;i<t.length;i++){
		if(t[i].getAttribute('srcover')||t[i].getAttribute('srcdown')){

			storeimages(t[i]);
			var checker='';
			checker=(t[i].getAttribute('srcover'))?checker+'A':checker+'';
			checker=(t[i].getAttribute('srcdown'))?checker+'B':checker+'';

			switch(checker){
			case 'A' : mouseover(t[i]);mouseout(t[i]); break;
			case 'B' : mousedown(t[i]); mouseup2(t[i]); break;
			case 'AB' : mouseover(t[i]);mouseout(t[i]); mousedown(t[i]); mouseup(t[i]); break;
			default : return;
			}

			if(t[i].src){t[i].setAttribute("oldsrc",t[i].src);}
		}
	}
}
function mouseup(t){
	var newmouseup;
	if(t.onmouseup){
		t.oldmouseup=t.onmouseup;
		newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("srcover");this.oldmouseup();}

	}
	else{newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("srcover");}}
	t.onmouseup=newmouseup;
}

function mouseup2(t){
	var newmouseup;
	if(t.onmouseup){
		t.oldmouseup=t.onmouseup;
		newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("oldsrc");this.oldmouseup();}
		}
	else{newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("oldsrc");}}
	t.onmouseup = newmouseup;
}

function mousedown(t){
	var newmousedown;
	if(t.onmousedown){
		t.oldmousedown=t.onmousedown;
		newmousedown=function(){if(mouseisdown==0){this.src=this.getAttribute("srcdown");this.oldmousedown();}}
	}
	else{newmousedown=function(){if(mouseisdown==0){this.src=this.getAttribute("srcdown");}}}
	t.onmousedown=newmousedown;
}

function mouseover(t){
	var newmouseover;
	if(t.onmouseover){
		t.oldmouseover=t.onmouseover;
		newmouseover=function(){this.src=this.getAttribute("srcover");this.oldmouseover();}
	}
	else{newmouseover=function(){this.src=this.getAttribute("srcover");}}
	t.onmouseover=newmouseover;
}

function mouseout(t){
	var newmouseout;
	if(t.onmouseout){
		t.oldmouseout=t.onmouseout;
		newmouseout=function(){this.src=this.getAttribute("oldsrc");this.oldmouseout();}
	}
	else{newmouseout=function(){this.src=this.getAttribute("oldsrc");}}
	t.onmouseout=newmouseout;
}

function storeimages(t){
	var s=(t.getAttribute('src'))?t.getAttribute('src'):'';
	var d=(t.getAttribute('srcdown'))?t.getAttribute('srcdown'):'';
	var o=(t.getAttribute('srcover'))?t.getAttribute('srcover'):'';
	ih.store(s,d,o);
}

function preloadimgsrc(){
	if(!document.getElementById) return;
	var it=document.getElementsByTagName('IMG');
	var it2=document.getElementsByTagName('INPUT');
	preloader(it);
	preloader(it2);
}

if(window.addEventListener){window.addEventListener("load", preloadimgsrc, false);}
else{
	if(window.attachEvent){window.attachEvent("onload", preloadimgsrc);}
	else{if(document.getElementById){window.onload=preloadimgsrc;}}
}

function ifmeOnload()
{
	var wrapper = document.getElementById('frameWrapper');
	if(wrapper!=undefined)
	{
		wrapper.id = 'frameWrapperDone';
	}
	var frame = document.getElementById('DocIFrame');
	if(frame!=undefined)
	{
		frame.style.visibility = 'visible';
	}
}


var persistedulsSitemap=new Object();
var ddtreemenuSitemap=new Object();

ddtreemenuSitemap.closefolder="http://site.eforcity.com/template/Rvmp2/images/common/efc_arrow2.jpg"; //set image path to "closed" folder image
ddtreemenuSitemap.openfolder="http://site.eforcity.com/template/Rvmp2/images/common/efc_arrow2.jpg"; //set image path to "open" folder image

//////////No need to edit beyond here///////////////////////////

ddtreemenuSitemap.createTree=function(treeid, enablepersist, persistdays){
var ultags=document.getElementById(treeid).getElementsByTagName("ul");
if (typeof persistedulsSitemap[treeid]=="undefined")
persistedulsSitemap[treeid]=(enablepersist==true && ddtreemenuSitemap.getCookie(treeid)!="")? ddtreemenuSitemap.getCookie(treeid).split(",") : "";
for (var i=0; i<ultags.length; i++)
ddtreemenuSitemap.buildSubTree(treeid, ultags[i], i);
if (enablepersist==true){ //if enable persist feature
var durationdays=(typeof persistdays=="undefined")? 1 : parseInt(persistdays);
ddtreemenuSitemap.dotask(window, function(){ddtreemenuSitemap.rememberstate(treeid, durationdays)}, "unload"); //save opened UL indexes on body unload
}
}

ddtreemenuSitemap.buildSubTree=function(treeid, ulelement, index){
ulelement.parentNode.className="sitemap-submenu";
if (typeof persistedulsSitemap[treeid]=="object"){ //if cookie exists (persistedulsSitemap[treeid] is an array versus "" string)
if (ddtreemenuSitemap.searcharray(persistedulsSitemap[treeid], index)){
ulelement.setAttribute("rel", "open");
ulelement.style.display="block";
ulelement.parentNode.style.backgroundImage="url("+ddtreemenuSitemap.openfolder+")";
}
else
ulelement.setAttribute("rel", "closed");
} //end cookie persist code
else if (ulelement.getAttribute("rel")==null || ulelement.getAttribute("rel")==false) //if no cookie and UL has NO rel attribute explicted added by user
ulelement.setAttribute("rel", "closed");
else if (ulelement.getAttribute("rel")=="open") //else if no cookie and this UL has an explicit rel value of "open"
ddtreemenuSitemap.expandSubTree(treeid, ulelement); //expand this UL plus all parent ULs (so the most inner UL is revealed!)
ulelement.parentNode.onclick=function(e){
var submenu=this.getElementsByTagName("ul")[0];
if (submenu.getAttribute("rel")=="closed"){
    submenu.style.display="block";
    submenu.setAttribute("rel", "open");
    ulelement.parentNode.style.backgroundImage="url("+ddtreemenuSitemap.openfolder+")";
}
else if (submenu.getAttribute("rel")=="open"){
    submenu.style.display="none";
    submenu.setAttribute("rel", "closed");
    ulelement.parentNode.style.backgroundImage="url("+ddtreemenuSitemap.closefolder+")";
}
else {
    alert("Error!!");
}
ddtreemenuSitemap.preventpropagate(e);
}
ulelement.onclick=function(e){
ddtreemenuSitemap.preventpropagate(e);
}
}

ddtreemenuSitemap.expandSubTree=function(treeid, ulelement){ //expand a UL element and any of its parent ULs
var rootnode=document.getElementById(treeid);
var currentnode=ulelement;
currentnode.style.display="block";
currentnode.parentNode.style.backgroundImage="url("+ddtreemenuSitemap.openfolder+")";
while (currentnode!=rootnode){
if (currentnode.tagName=="UL"){ //if parent node is a UL, expand it too
currentnode.style.display="block";
currentnode.setAttribute("rel", "open"); //indicate it's open
currentnode.parentNode.style.backgroundImage="url("+ddtreemenuSitemap.openfolder+")";
}
currentnode=currentnode.parentNode;
}
}

ddtreemenuSitemap.flatten=function(treeid, action){ //expand or contract all UL elements
var ultags=document.getElementById(treeid).getElementsByTagName("ul");
for (var i=0; i<ultags.length; i++){
ultags[i].style.display=(action=="expand")? "block" : "none";
var relvalue=(action=="expand")? "open" : "closed";
ultags[i].setAttribute("rel", relvalue);
ultags[i].parentNode.style.backgroundImage=(action=="expand")? "url("+ddtreemenuSitemap.openfolder+")" : "url("+ddtreemenuSitemap.closefolder+")";
}
}

ddtreemenuSitemap.rememberstate=function(treeid, durationdays){ //store index of opened ULs relative to other ULs in Tree into cookie
var ultags=document.getElementById(treeid).getElementsByTagName("ul");
var openuls=new Array();
for (var i=0; i<ultags.length; i++){
if (ultags[i].getAttribute("rel")=="open");
openuls[openuls.length]=i; //save the index of the opened UL (relative to the entire list of ULs) as an array element
}
if (openuls.length==0) //if there are no opened ULs to save/persist
openuls[0]="none open"; //set array value to string to simply indicate all ULs should persist with state being closed
ddtreemenuSitemap.setCookie(treeid, openuls.join(","), durationdays); //populate cookie with value treeid=1,2,3 etc (where 1,2... are the indexes of the opened ULs)
}

////A few utility functions below//////////////////////

ddtreemenuSitemap.getCookie=function(Name){ //get cookie value
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1]; //return its value
return "";
}

ddtreemenuSitemap.setCookie=function(name, value, days){ //set cookei value
var expireDate = new Date()
//set "expstring" to either future or past date, to set or delete cookie, respectively
var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days))
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

ddtreemenuSitemap.searcharray=function(thearray, value){ //searches an array for the entered value. If found, delete value from array
var isfound=false;
for (var i=0; i<thearray.length; i++){
if (thearray[i]==value){
isfound=true;
thearray.shift(); //delete this element from array for efficiency sake
break;
}
}
return isfound;
}

ddtreemenuSitemap.preventpropagate=function(e){ //prevent action from bubbling upwards
if (typeof e!="undefined")
e.stopPropagation();
else
event.cancelBubble=true;
}

ddtreemenuSitemap.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype;
alert(tasktype);
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false);
else if (target.attachEvent)
target.attachEvent(tasktype, functionref);
}

// counter
function DrawCounter(sku)
{
    //sendRequest('http://www.checkoutexpert.com/webpromo/countdownVal.aspx?sku='+sku, handleRequest);
    var obj = document.getElementById('FlowCounter');
    if(obj!=undefined)
    {
		var now = new Date();
//        obj.innerHTML = '<iframe id="frmCounter" name="frmCounter" src="http://www.checkoutexpert.com/webpromo/countdownJpg.aspx?w=50&h=20&sku='+sku+'" width="100px" height="40px" frameborder="0" scrolling="No">';
		obj.innerHTML = '<img id="imgCounter" border=0 src="http://www.checkoutexpert.com/webpromo/countdownJpg.aspx?w=50&h=20&sku='+sku+'&g='+now.getMilliseconds()+'" />';
    }
    setTimeout("DrawCounter('"+sku+"');", 60000);
}

function PageQuery(q) {
if(q.length > 1) this.q = q.substring(1, q.length);
else this.q = null;
this.keyValuePairs = new Array();
if(q) {
for(var i=0; i < this.q.split("&").length; i++) {
this.keyValuePairs[i] = this.q.split("&")[i];
}
}
this.getKeyValuePairs = function() { return this.keyValuePairs; }
this.getValue = function(s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
if(this.keyValuePairs[j].split("=")[0] == s)
return this.keyValuePairs[j].split("=")[1];
}
return '';
}
this.getParameters = function() {
var a = new Array(this.getLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
a[j] = this.keyValuePairs[j].split("=")[0];
}
return a;
}
this.getLength = function() { return this.keyValuePairs.length; }
}
function queryString(key){
var page = new PageQuery(window.location.search);
return unescape(page.getValue(key));
}

//Item Page Tab Control 2009
function selecttab(n)
{
	for(i=1;i<=5;i++)
	{
		var menu=document.getElementById("menu"+i);
		var tab=document.getElementById("tab"+i);
		if(menu != null && tab != null)
		{
			menu.className=i==n?"current":"";
			tab.style.display=i==n?"block":"none";
		}
	}
}


//Search
function SortSearchResult(searchLink,sortBy)
{
	var patrn = /sb=\d?/;
	var sb = searchLink.match(patrn);
	var newsb = 'sb=' + sortBy;
	if(sb == null)
	{
		searchLink = searchLink + '&' + newsb;
	}
	else
	{
		searchLink = searchLink.replace(patrn,newsb);
	}
	self.location.href = searchLink;
}

function ChangeRecordsPerPage(searchLink,pageRecords)
{
	var patrn = /sb=\d*/;
	var ps = searchLink.match(patrn);
	var newps = 'ps=' + pageRecords;
	if(ps == null)
	{
		searchLink = searchLink + '&' + newps;
	}
	else
	{
		searchLink = searchLink.replace(patrn,newps);
	}
	self.location.href = searchLink;
}


/*-- menu tree Begin--*/
var ddtreemenu = {};
ddtreemenu.openhref = '';
ddtreemenu.createTree = function () {return false;}

function toggleMenu(ele) {
	ele.toggleClass('select')
	    .parent('.nav-hasSon').toggleClass('nav-text-select')
							.next('ul').animate({height: 'toggle'}, 'fast');
}
function treeMenu(ele) {
	var ele = $('#'+ele+'');
	ele.find('li:has(ul)').find('.nav-text a')
					   .click(function (e) {
						   e.preventDefault();
						   this.blur();
						   var eleData = ele.NavFocusObj;
						   if(eleData && eleData != this && $(eleData).attr('class')=='select') {
							  toggleMenu($(ele.NavFocusObj));
						   }
						   ele.NavFocusObj = this;
						   toggleMenu($(this));
					   })
					  .parent('div.nav-text').addClass('nav-hasSon');
	ele.find('li:not(:has(ul))').find('.nav-text a').click(function () {
		$(this).addClass('select');
		ele.NavFocusObj = this;
	});
	//select current page
      var curid = ddtreemenu.openhref;
	if(curid) {
            var cur = $('#'+curid.replace(/(\s*)|(\s*$)/g,''));
            if(!cur.length) {
                  curid = curid*1;
                  cur = ele.find('li').filter(function () {
                        return $(this).attr('navid')*1 === curid;
                  });
            }
            cur.find('.nav-text a').click();
	}
}
/*-- menu tree End--*/

/** Auto complete Begin **/
function GetAutoComplete(keyword,e)
{
	var acDiv = document.getElementById("AutoCompleteDiv");
	if(acDiv == null || e.keyCode == 13)
	{
		return;
	}
	if(e.keyCode == 38 || e.keyCode == 40)
	{
		SelectFocusKeyword(e.keyCode == 40);
		return;
	}
	if(keyword.length >= 1)
	{
		var head = document.getElementsByTagName("head")[0];
		var script = document.createElement("script");
		script.type = "text/javascript";
		script.src = "http://search10.eforcity.com/EFAutoComplete/SearchAutoComplete.aspx?kw=" + keyword;
		head.appendChild(script);


		if (!/*@cc_on!@*/0)
		{
			script.onload = function()
			{
				DisplayAutoCompleteList();
			}
		}
		else
		{
			script.onreadystatechange = function()
			{
				if (script.readyState == 'loaded' || script.readyState == 'complete')
				{
					DisplayAutoCompleteList();
				}
			}
		}
	}
	else
	{
		acDiv.style.display = "none";
	}
}

function DisplayAutoCompleteList()
{
	var acDiv = document.getElementById("AutoCompleteDiv");
	if(acDiv != null)
	{
		var liList = acDiv.getElementsByTagName("li");
		if(liList != null && liList.length > 0)
		{
			acDiv.style.display = "block";
		}
		else
		{
			acDiv.style.display = "none";
		}
	}
}
function SetAutoComplete(keyword)
{
	var searchTxt = document.getElementById('SearchBoxQueryTbx');
	if(searchTxt != null)
	{
		searchTxt.value = keyword;
		SetFocusKeyword(keyword);
	}
}

function SetFocusKeyword(keyword)
{
	var acDiv = document.getElementById("AutoCompleteDiv");
	if(acDiv != null)
	{
		var liList = acDiv.getElementsByTagName("li");
		for(i = 0 ; i < liList.length; i++)
		{
			if(keyword == liList[i].innerHTML)
			{
				liList[i].className = "sch-auto-complete-focus";
			}
			else
			{
				liList[i].className = "";
			}
		}
	}
}

function SelectFocusKeyword(isDown)
{
	var acDiv = document.getElementById("AutoCompleteDiv");
	if(acDiv != null)
	{
		var liList = acDiv.getElementsByTagName("li");
		var keyword = "";
		var hasSelected = false;
		if(liList.length > 0)
		{
			for(i = 0 ; i < liList.length; i++)
			{
				if(liList[i].className == "sch-auto-complete-focus")
				{
					if(isDown)
					{
						if(i == liList.length - 1)
						{
							keyword = liList[0].innerHTML;
						}
						else
						{
							keyword = liList[i + 1].innerHTML
						}
					}
					else
					{
						if(i == 0)
						{
							keyword = liList[liList.length - 1].innerHTML;
						}
						else
						{
							keyword = liList[i - 1].innerHTML
						}
					}
					hasSelected = true;
				}
			}
			if(!hasSelected)
			{
				if(isDown)
				{
					keyword = liList[0].innerHTML;
				}
				else
				{
					keyword = liList[liList.length - 1].innerHTML;
				}
			}
			SetAutoComplete(keyword);
		}
	}
}

document.onclick = function(event)
{
	var acDiv = document.getElementById("AutoCompleteDiv");
	if(acDiv != null)
	{
		acDiv.style.display = "none";
	}
}
/** Auto complete End **/

//Mobile Redirect Start
function setCookie(c_name,value)
{
	var exdate=new Date();
	exdate.setTime(exdate.getTime() + (1800 * 1000));
	document.cookie=c_name+ "=" +escape(value)+";expires="+exdate.toGMTString();
}

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

var mobileIndicators = [
  "Smartphone",
  "IEMobile",
  "WindowsCE",
  "Palm",
  "hiptop",
  "amoi",
  "AvantGo",
  "Alcatel-",
  "AnexTek",
  "AU-MIC",
  "AUDIOVOX-",
  "BlackBerry",
  "Blazer",
  "CDM-",
  "Dopod-",
  "Ericsson",
  "Hitachi-",
  "HPiPAQ-",
  "HTC-",
  "Droid",
  "Android",
  "iPhone",
  "iPod",
  "KDDI",
  "LG",
  "MM-",
  "MO01",
  "MOT-",
  "Motorola",
  "N515i",
  "N525i",
  "NEC-",
  "Nokia",
  "NOKIA",
  "OpenWeb",
  "Operamini",
  "Opera mini",
  "OPWV",
  "Panasonic",
  "Pantec",
  "PG-",
  "PLS",
  "PM-",
  "PN-",
  "portalmmm",
  "QCI-",
  "RL-",
  "SAGEM",
  "Samsung",
  "SAMSUNG",
  "SCH",
  "SCP-",
  "SEC-",
  "Sendo",
  "SGH-",
  "SHARP-",
  "SIE-",
  "SonyEricsson",
  "SPH",
  "SPV",
  "UP.Browser",
  "UP.Link",
  "V60t",
  "VI600",
  "VK530",
  "VM4050",
  "Vodafone",
  "ZTE",
  "802SH"
 ];

function mobileQueryString(ji) {
  hu = window.location.search.substring(1);
  gy = hu.split("&");
  for (i = 0; i < gy.length; i++) {
      ft = gy[i].split("=");
      if (ft[0] == ji) {
          return ft[1];
      }
  }
  return (false);
}


var fromMobileCookie = getCookie("fromMobileSite");
if (fromMobileCookie != 'true') {

	var fromMobile = mobileQueryString("fromMobileSite");
	if ((fromMobile == 'false') || (fromMobile == '')) {
	
	  var isMobile = false;
	  var agent = navigator.userAgent.toLowerCase();
		for (var i = 0; i < mobileIndicators.length; i++){ 
	    var indicator = mobileIndicators[i].toLowerCase();
	    if (agent.indexOf(indicator) > -1) {
	        isMobile = true;
	    }
	  }
	  if (isMobile) {
	    if (location.host.indexOf("eforcity.com") != -1) {
	        var host = "http://m.eforcity.com" + location.pathname + location.search;
	        location.replace(host);
	    }
	  }
	
	} else {
	  setCookie('fromMobileSite', 'true');
	}

}
//Mobile Redirect End
