function addBookmark() {
    if (window.sidebar) { // firefox
    	window.sidebar.addPanel(window.document.title, window.document.location, "");
    } else if(window.opera && window.print) { // opera
    	var elem = document.createElement('a');
    	elem.setAttribute('href',window.document.location);
    	elem.setAttribute('title',window.document.title);
    	elem.setAttribute('rel','sidebar');
    	elem.click();
    } else if(document.all) {// ie
    	window.external.AddFavorite(window.document.location, window.document.title);
    }
}
var unit = 'px';
var currentSize = 11;
var minSize = 8;
var maxSize = 24;
var fs = 0;
var lh = 0;
function setCurrentSize(in_size) {
    currentSize = in_size;
}
function changeFontSize(increase) {

    if ((currentSize == minSize && !increase) || (currentSize == maxSize && increase)) return;
    currentSize = (increase) ? currentSize + 2 : currentSize - 2;

    setFontSize();
    ajaxSetFontSize(currentSize);
}
function setFontSize() {
    var p = document.getElementById('page-main-content-leftcenter');

    p.style.fontSize = currentSize+unit;
    p.style.lineHeight = (currentSize*1.5)+unit;

}
function editChunk(in_id) {
    window.open('/page/chunkedit/'+in_id+'/','editPage','width=550,height=550');
    return false;
}
function editPage(in_id) {
    window.open('/page/seo/'+in_id+'/','editPage','width=550,height=400,scrollbars,resizable=yes');
    return false;
}
function chunkClose() {
    window.opener.location.reload(true);
    window.close();
}
function email(in_id) {
    window.open('/home/email/'+in_id+'/','emailPage','width=450,height=400');
}
function details(details_id) {
    window.open('/store/details/'+details_id+'/','details','width=450,height=400');
}
function qtvr(in_size) {
    var width = 0;
    var height = 0;
    switch (in_size) {
        case 1: width = 575;  height = 310; break;
        case 2: width = 750;  height = 505; break;
        case 3: width = 1100; height = 800; break;
        default: break;
    }
    window.open('/home/qtvr/'+in_size+'/','qtvrPage'+in_size,'width='+width+',height='+height+',resizable=1');
}

document.getElementsByClassName = function(className) {
  var children = document.getElementsByTagName('*') || document.all;
  var elements = new Array();

  for (var i = 0; i < children.length; i++) {
    var child = children[i];
    var classNames = child.className.split(' ');
    for (var j = 0; j < classNames.length; j++) {
      if (classNames[j] == className) {
        elements.push(child);
        break;
      }
    }
  }
  return elements;
}

document.addEvent = function(object, eventType,fn, useCapture) {
	if (object.addEventListener) {
		object.addEventListener(eventType, fn, useCapture);
		return true;
	} else {
		if (object.attachEvent) {
			var r = object.attachEvent("on"+eventType, fn);
			return r;
		}
	}
};

var clickmessage="Right click has been disabled.";
function associateimages(){
	//function from dynamicdrive.com
	for(i=0;i<document.images.length;i++)
	document.images[i].onmousedown=disableclick;
}

function disableclick(e) {
if ( (navigator.appName == 'Netscape' && (e.which == 2 || e.which == 3 || e.ctrlKey || e.altKey) && e.target.tagName!='A' ) || (navigator.appName != 'Netscape' && (event && (event.button==2||event.button==3||event.ctrlKey||event.altKey) && event.srcElement.tagName=='IMG')) ) {
	alert(clickmessage);
	return false;
}
	return true;
}

function protectImages() {
	if ( (/pelago/gi).test(document.domain) ) return false;
	if (document.all)
		document.onmousedown=disableclick
	else if (document.getElementById)
		document.onmouseup=disableclick
	else if (document.layers)
		associateimages();
	window.onmousedown=disableclick;

}

document.addEvent(window,'load',protectImages, false);

// auto rollovers <img src="image.gif" class="rollover"> format: image.gif and image_on.gif
function autoPreload(){
	var overs = document.getElementsByClassName('rollover');
	for( var i=0; i<overs.length; i++){
		//preload
		overs[i].imgOn = new Image();
		overs[i].imgOn.src = overs[i].src.replace(/\.(gif|jpg)/,"_on.$1");
		//assign over/out state
		overs[i].onmouseover = rollover;
		overs[i].onmouseout = rollout;
	}
}

function rollover() {
	//if ( !this.src ) return;
	this.oldsrc = this.src;
	this.src = this.imgOn.src;
}

function rollout() {
	//if ( !this.oldsrc ) return;
	this.src = this.oldsrc;
}

function switchPhoto(sImg) {
	var span = document.getElementById('store-index-product');
	var i = new Image();
	i.src = sImg;
	i.onload = function () {
		span.innerHTML = '<img src="' + i.src + '" width="' + i.width + '" height="' + i.height + '" />';
		span.style.textAlign = i.width < 180 ? 'center' : 'left';
	}
	return false;
}

document.addEvent(window,'load',autoPreload, false);

function video(url) {
	var winWidth = 500;
	var winHeight = 350;
   	var left = Math.floor( (screen.width - winWidth) / 2);
    var top = Math.floor( (screen.height - winHeight) / 2);
	var g = window.open(url,'VideoWindow',"scrollbars=no,resizable=yes,width="+winWidth+",height="+winHeight+",left="+left+",top="+top);
	g.focus();
	return false;
}

function cvv_win() {
	var thewin = window.open("/cart/cvv/","cvv","height=450,width=550,toolbar=no,statusbar=no,scrollbars=yes");
	thewin.focus();
	return false;
}
function updateWatts() {
    var formWatts = document.getElementById('f_watts');
    var formVolts = document.getElementById('f_volts');
    var formAmps = document.getElementById('f_amps');

    if (isNaN(formVolts.value) || formVolts.value <= 0) return true;
    if (isNaN(formAmps.value) || formAmps.value <= 0) return true;

    formWatts.value = formVolts.value * formAmps.value;
}
function toggleStep3(in_show) {
    var divStep3 = document.getElementById('step3');

    divStep3.style.display = in_show ? 'block' : 'none';

    if (!in_show) {
        document.getElementById('f_watts').value = '400';
    }
}

function IsNumeric()
{

   var ValidChars = "$,0123456789.";
   var IsNumber=true;
   var sText = document.form.f_price.value;
   var Char;
   
   
   for (i = 0; i < sText.length && IsNumber == true; i++)
   {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
       {
         IsNumber = false;
         alert('Please enter in a valid number for your offer');
       }
   }
   return IsNumber;
 }



//popup window for viewing accessory
function showPicture(imageName,imageWidth,imageHeight) {
   	var left = Math.floor( (screen.width - imageWidth) / 2);
    var top = Math.floor( (screen.height - imageHeight) / 2);
	newWindow = window.open("","accessoryWindow","scrollbars=no,width="+imageWidth+",height="+imageHeight+",left="+left+",top="+top);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+imageName+'</title>');
	newWindow.document.write('<head>');
	newWindow.document.write('<' + 'script language="JavaScript1.2" type="text/javascript">');
	newWindow.document.write("\n"+'function disableclick(e) {');
	newWindow.document.write("\n"+'if (');
	newWindow.document.write("\n"+'   			(navigator.appName == "Netscape" && (e.which == 2 || e.which == 3 || e.ctrlKey || e.altKey) && e.target.tagName=="IMG")');
	newWindow.document.write("\n"+'   			||');
	newWindow.document.write("\n"+'   			(navigator.appName != "Netscape" && (event && (event.button==2||event.button==3||event.ctrlKey||event.altKey) && event.srcElement.tagName=="IMG"))');
	newWindow.document.write("\n"+'   		) {');
	newWindow.document.write("\n"+'			alert("Manipulation of images has been disabled to protect brand integrity.");');
	newWindow.document.write("\n"+'			return false;');
	newWindow.document.write("\n"+'	} ');
	newWindow.document.write("\n"+'	return true;');
	newWindow.document.write("\n"+'}');
	newWindow.document.write("\n"+'window.onload = function() {');
	newWindow.document.write("\n"+'	if (document.all)');
	newWindow.document.write("\n"+'		document.onmousedown=disableclick');
	newWindow.document.write("\n"+'	else if (document.getElementById)');
	newWindow.document.write("\n"+'		document.onmouseup=disableclick');
	newWindow.document.write("\n"+'	else if (document.layers)');
	newWindow.document.write("\n"+'		associateimages();');
	newWindow.document.write("\n"+'	window.onmousedown=disableclick;');
	newWindow.document.write("\n"+'}');
	newWindow.document.write("\n"+'function associateimages(){');
	newWindow.document.write("\n"+'	//function from dynamicdrive.com');
	newWindow.document.write("\n"+'	for(i=0;i<document.images.length;i++)');
	newWindow.document.write("\n"+'	document.images[i].onmousedown=disableclick;');
	newWindow.document.write("\n"+'}');
	newWindow.document.write('</script' + '>');
	newWindow.document.write('</head>');
	newWindow.document.write('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" >');
	newWindow.document.write('<center><img src="'+imageName+'" alt="'+imageName+'" ></center>');
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}
document.addEvent(window,'load',protectImages, false);

var oXml = null;
var callback = null;

function ajaxSetFontSize(in_size) {
    var uri = '/home/changefontsize/' + in_size + '/';
    ajaxRequest(uri);
}

function ajaxRequest(uri) {
	oXmlInit();
	if( oXml != null ) {
		oXml.open("GET", uri, true); //asynchronously or not
		/*
		readyState Status Codes:
		0 = uninitialized
		1 = loading
		2 = loaded
		3 = interactive
		4 = complete
		*/
		oXml.onreadystatechange = function() {
			if (oXml.readyState == 4) {
				if (oXml.status == 200) {
				    if (callback != undefined) {
				        if (callback != null) {
				            eval(callback+'();');
				        }
				    }
				}
			}
		}
		oXml.send(null);
	}
}

function oXmlInit() {
	try {
		oXml = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			oXml=new ActiveXObject("Microsoft.XMLHTTP");
		} catch (oc) {
			oXml=null;
		}
	}
	if(!oXml && typeof XMLHttpRequest != "undefined") {
		oXml = new XMLHttpRequest();
	}
}

function travelVideo(url) {
	var winWidth = 762;
	var winHeight = 420;
   	var left = Math.floor( (screen.width - winWidth) / 2);
    var top = Math.floor( (screen.height - winHeight) / 2);
	var g = window.open(url,'TravelVideoWindow',"scrollbars=no,resizable=yes,width="+winWidth+",height="+winHeight+",left="+left+",top="+top);
	g.focus();
	return false;
}