/* JS functions for image swap in the menu */
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
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];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function contactForm(){
	var concerning = document.getElementById('concerningDropDown').options[document.getElementById('concerningDropDown').selectedIndex].value;
	var name = document.getElementById('name');
	var email = document.getElementById('contact_email');
	var phone = document.getElementById('phone');
	var ordernum = document.getElementById('ordernum');
	var message = document.getElementById('message');
	var submit = document.getElementById('submit_contact');
	// value of default selection
	if(concerning != "0" && concerning != 0){
		// Ok a select hath been made
		if(concerning == 'inventory01'){
			window.parent.location="http://www.zagg.com/hotgadgets/index.php";
		}else if (concerning == 'replace') {
			window.parent.location='http://www.zagg.com/support/register/register_process.php';
		}else {
			name.disabled = false;
			email.disabled = false;
			phone.disabled = false;
			ordernum.disabled = false;
			message.disabled = false;
			submit.disabled = false;
		}
	}else{		
		name.disabled = true;
		email.disabled = true;
		phone.disabled = true;
		ordernum.disabled = true;
		message.disabled = true;
		submit.disabled = true;
	}
}


var dom = (document.getElementById) ? true : false;
var ns5 = (!document.all && dom || window.opera) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false;

var origWidth, origHeight;


if (nodyn) { event = "nope" }

var tipFollowMouse= true;	

var tipWidth= 160;
var offX= 20;	
var offY= 12; 
var tipFontFamily= "Verdana, arial, helvetica, sans-serif";
var tipFontSize= "8pt";

var tipFontColor= "#ffffff";
var tipBgColor= "#DDECFF"; 
var tipBorderColor= "#000080";
var tipBorderWidth= 3;
var tipBorderStyle= "ridge";
var tipPadding= 4;


var messages = new Array();

messages[0] = new Array('/images/tooltipimages/iphone.png','invisibleSHIELD for the iPhone',"#000000");
messages[1] = new Array('/images/tooltipimages/iphone.png','invisibleSHIELD for the iPhone 3G S.',"#000000");
messages[2] = new Array('/images/tooltipimages/appleipodclassic.jpg','invisibleSHIELD for the Apple iPod Classic',"#000000");
messages[3] = new Array('/images/tooltipimages/macbookair.jpg','invisibleSHIELD for the Macbook Air',"#000000");
messages[4] = new Array('/images/tooltipimages/ipodtouch2ndgen.jpg','invisibleSHIELD for the iPod Touch 2nd gen',"#000000");
messages[5] = new Array('/images/tooltipimages/blackberrybold.jpg','invisibleSHIELD for the Blackberry Bold 9000',"#000000");
messages[6] = new Array('/images/tooltipimages/blackberrycurve8900.png','invisibleSHIELD for the Blackberry Curve 8900',"#000000");
messages[7] = new Array('/images/tooltipimages/blackberrystorm.jpg','invisibleSHIELD for the Blackberry Storm',"#000000");
messages[8] = new Array('/images/tooltipimages/lgdare.png','invisibleSHIELD for the LG Dare',"#000000");
messages[9] = new Array('/images/tooltipimages/nokiaxpress.jpg','invisibleSHIELD for the Nokia XpressMusic 5800',"#000000");
messages[10] = new Array('/images/tooltipimages/palmpre.png','invisibleSHIELD for the Palm Pre',"#000000");
messages[11] = new Array('/images/tooltipimages/tmobileg2.png','invisibleSHIELD for the T-mobile G2',"#000000");


if (document.images) {
	var theImgs = new Array();
	for (var i=0; i<messages.length; i++) {
  	theImgs[i] = new Image();
		theImgs[i].src = messages[i][0];
  }
}


var startStr = '<table width="' + tipWidth + '"><tr><td align="center" width="100%"><img src="';
var midStr = '" border="0"></td></tr><tr><td valign="top">';
var endStr = '</td></tr></table>';


var tooltip, tipcss;
function initTip() {
	if (nodyn) return;
	tooltip = (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
	tipcss = tooltip.style;
	if (ie4||ie5||ns5) {	
		tipcss.width = tipWidth+"px";
		tipcss.fontFamily = tipFontFamily;
		tipcss.fontSize = tipFontSize;
		tipcss.color = tipFontColor;
		tipcss.backgroundColor = tipBgColor;
		tipcss.borderColor = tipBorderColor;
		tipcss.borderWidth = tipBorderWidth+"px";
		tipcss.padding = tipPadding+"px";
		tipcss.borderStyle = tipBorderStyle;
	}
	if (tooltip&&tipFollowMouse) {
		document.onmousemove = trackMouse;
	}
}

window.onload = initTip;


var t1,t2;	
var tipOn = false;	
function doTooltip(evt,num) {
	if (!tooltip) return;
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;

	if (messages[num][2])	var curBgColor = messages[num][2];
	else curBgColor = tipBgColor;
	if (messages[num][3])	var curFontColor = messages[num][3];
	else curFontColor = tipFontColor;
	if (ie4||ie5||ns5) {
		var tip = startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
		tipcss.backgroundColor = curBgColor;
	 	tooltip.innerHTML = tip;
	}
	if (!tipFollowMouse) positionTip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}

var mouseX, mouseY;
function trackMouse(evt) {
	standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
	
	mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
	mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	if (tipOn) positionTip(evt);
}


function positionTip(evt) {
	if (!tipFollowMouse) {
		standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
		mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	}
	
	var tpWd = (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
	
	var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
	var winHt = (ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;

	if ((mouseX+offX+tpWd)>winWd) 
		tipcss.left = mouseX-(tpWd+offX)+"px";
	else tipcss.left = mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) 
		tipcss.top = winHt-(tpHt+offY)+"px";
	else tipcss.top = mouseY+offY+"px";
	if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}

function hideTip() {
	if (!tooltip) return;
	t2=setTimeout("tipcss.visibility='hidden'",100);
	tipOn = false;
}

document.write('<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100"></div>')

