/* copyright digital trooper */
/* flash embedding */
document.write("<script type='text/javascript' src='/scripts/flash.js'><\/script>");
// --------------- //

if (windowID == null) var windowID=1;
if (Loaded == null) var Loaded=false;
productPattern = /-[0-9]{1,9}-/;
productPatternLG = /-[0-9]{1,9}/;

var agntUsr=navigator.userAgent.toLowerCase();
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var isMac = (navigator.appVersion.indexOf("Mac") != -1);

function msieversion() {
 var ua = window.navigator.userAgent
 var msie = ua.indexOf ( "MSIE " )

 if ( msie > 0 )      // If Internet Explorer, return version number
   return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
 else                 // If another browser, return 0
  return 0
}

//if (InternetExplorer && (msieversion() < 7)) document.write("<script language='JavaScript' src='/scripts/fixpng.js'><\/script>");
if (!InternetExplorer) document.write("<script type='text/javascript' src='/scripts/mozilla.js'><\/script>");

function popUp() {}
function popDown() {}

function trim(str) { 
    str.replace(/^\s*/, '').replace(/\s*$/, ''); 

   return str;
} 

function numvalidate(string) {
  if (!string) return false;
  var Chars = "0123456789";

  for (var i = 0; i < string.length; i++) {
     if (Chars.indexOf(string.charAt(i)) == -1)
        return false;
     }
   return true;
} 

function SelectAll(obj) {
 for (var i=0; i<obj.length; i++)
  obj.options[i].selected=1; 
}

function addListItem(obj, valueObj) {
 newItem = valueObj.value;
 obj.options[obj.options.length] = new Option(newItem,newItem,false,false);
 valueObj.value=''; 
}

function remListItems(container) {
 counter=0;
 while (counter<container.length) 
 if (container.options[counter]) { if (container.options[counter].selected) container.options[counter] = null; else counter++;}
  else counter++;
}

function prevPic(args) {
	for (var i = prodArray[args].length-1; i>-1; i--) {
		if (parseInt(eval("pin" + args).innerText) > i+1) { 
			eval("pin" + args).innerText = i+1; 
			obj = document.images["pim" + args];
			objSrc = obj.src;

			objSrc = objSrc.replace(productPattern, '-'+prodArray[args][i]+'-');
			obj.src = objSrc;

			break; 
		}
	}
}

function nextPic(args) {
	for (var i = 0; i<prodArray[args].length; i++) {
		if (parseInt(eval("pin" + args).innerText) < i+1) { 
			eval("pin" + args).innerText = i+1; 
			obj = document.images["pim" + args];
			objSrc = obj.src;

			objSrc = objSrc.replace(productPattern, '-'+prodArray[args][i]+'-');
			obj.src = objSrc;

			break;
		}
	}
 }

function resizePhoto(width, height, id) {
	if (document.getElementById('pim'+id) != null) objType = 'pim';
	else if (document.getElementById('pic'+id) != null) objType = 'pic';
	else return;

	obj = (InternetExplorer) ? document.getElementById(objType+id) : document.embeds[objType+id];
	obj.width = width;
	obj.height = height;

	if (parent.usingIFRAME != null) { parent.iFrameRedraw(); }
}


var iframeids=["n"];

function iFrameRedraw(height) {
  var dyniframe=new Array()
  for (i=0; i<iframeids.length; i++){
	if (document.getElementById) { //begin resizing iframe procedure
		dyniframe[dyniframe.length] = document.getElementById(iframeids[i]);
		if (dyniframe[i]) {
			dyniframe[i].style.display="block"
			if (window.opera) { //Opera 7+ syntax
				document.title = dyniframe[i].document.title;
				dyniframe[i].height = dyniframe[i].document.documentElement.clientHeight;
			}
			else if (dyniframe[i].contentDocument && dyniframe[i].contentDocument.body.offsetHeight) { //ns6 syntax
				document.title = dyniframe[i].contentDocument.title;
				dyniframe[i].height = dyniframe[i].contentDocument.body.offsetHeight+20; 
			}
			else if (dyniframe[i].Document && dyniframe[i].Document.body.scrollHeight) { //ie5+ syntax
				document.title = dyniframe[i].Document.title;
				dyniframe[i].height = dyniframe[i].Document.body.scrollHeight;
			}

			if (height != null && height > dyniframe[i].height) dyniframe[i].height = height;
		}
	}
  }
}

function Loadit() {
  if (parent.nav != null && parent.nav.Go != null) parent.nav.Go();
  else if (parent.Go != null) parent.Go();
  Loaded=false;
}

function visi(id, isIt) {
 document.getElementById(id).style.visibility = (isIt) ? 'visible' : 'hidden'; 
}

function slide(toX, toY, id, hide, speed) {
 if (speed == null) speed = 10; 
 if (hide == null) hide = false;
 
 obj = document.getElementById(id);
 obj.style.visibility = 'visible';
 
 changed = false;
 if (obj) {
  wX = parseInt(obj.style.left);
  wY = parseInt(obj.style.top);

  if (wX != toX) {
   obj.style.left = (wX > toX) ? wX-1 : wX+1;
   changed = true;
  }
  if (wY != toY) {
   obj.style.top = (wY > toY) ? wY-1 : wY+1;
   changed = true;
  }
  
  if (changed) setTimeout("slide(" + toX + "," + toY + ",'" + id + "')", 10);   
 }
 
 if (hide) obj.style.visibility = 'hidden';
}

function centerWindow(windowID, resizeX, resizeY) {
 if (resizeX != null && resizeY != null) windowID.resizeTo(resizeX, resizeY);
 else {
  if (document.body.clientWidth == null || (document.body.clientWidth != null && document.body.clientWidth == 0)) return;

  resizeX=document.body.clientWidth;
  resizeY=document.body.clientHeight;
 }
 
 windowID.moveTo(screen.availWidth/2-resizeX/2, screen.availHeight/2-resizeY/2);
 windowID.focus();
}

function resizeWindow(wx, wy) {
 if (document.body.clientWidth == null || (document.body.clientWidth != null && document.body.clientWidth == 0)) return;
 window.resizeTo(wx,wy);
 var Xoffset=wx-document.body.clientWidth;
 var Yoffset=wy-document.body.clientHeight;
 var resizeX=document.getElementById('resize').offsetWidth+Xoffset;
 var resizeY=document.getElementById('resize').offsetHeight+Yoffset;

 centerWindow(window, resizeX, resizeY);  
 window.focus();
}

function gotoURL(url,tgt) {
 if (url.indexOf('javascript:')!=-1) var Vote = eval(url.substring(11, url.length));
  else if (tgt != '_self' && tgt != '_top') window.open(url,tgt);
   else window.location=url;
}

function checkEnter(e) { 
	var characterCode;

	if (e && e.which) characterCode = e.which;
	else {
		e = event;
		characterCode = e.keyCode;
	}

	return (characterCode == 13);
}
function mOvr(src,cOvr,msg) {
	window.status=msg;
	if (cOvr != null) (cOvr.indexOf('#') == -1) ? src.className = cOvr : src.bgColor = cOvr;
}
function mOut(src,cOut) {
	window.status='';
	if (cOut != null) (cOut.indexOf('#') == -1) ? src.className = cOut : src.bgColor = cOut;
}

function printPage() {
 if (window.print) window.print()
 else alert("Sorry, your browser doesn't support this feature.");
}

function printIFRAME(frame) {
 if (InternetExplorer) {
	document.getElementById(frame).focus();
	document.getElementById(frame).print();
 }
 else {
	window.frames[frame].focus();
	window.frames[frame].print();
 }
}

function popURL(url, w, h, scrollbars, center, toolbar, resizable, name) {
 if (w == null) w = 530;
 if (h == null) h = 500;
 if (scrollbars == null) scrollbars = 'yes';
 if (center == null) center = false;
 if (toolbar == null) toolbar = 'no';
 if (resizable == null) resizable = 'no';
  
 lt = (center) ? ',left='+(screen.availWidth - w) / 2 + ',top='+(screen.availHeight - h) / 2 : '';

 if (url.indexOf(':') == -1 && url.indexOf('/images/') == -1 && url.indexOf('/p/') == -1) url = '/index.cfm/p/'+url; 
 
 if (name == null) {
	windowID = url.length*windowID;
	windowID++;
 }
 else windowID = name;

 try {
  wID = window.open(url,'mpop'+windowID,'menubar=no,resizable='+resizable+',width='+w+',height='+h+',screenX=0,screenY=0,scrollbars='+scrollbars+',statusbar=no,toolbar='+toolbar + lt);
  wID.focus();
 }
 catch(e) {} 
}

function ecom_cart(id) {
 document.location = '/index.cfm/p/shopping.cart.add/id/'+id;
}

function ecom_wishList(id) {
 document.location = '/index.cfm/p/shopping.wishlist.add/id/'+id
}

function ecom_expandPhoto(id, index) {
 popURL('products/opt/onlyPhoto/id/' + id + '&index=' + document.getElementById('pin'+index).innerText, 480, 400, 'yes', 'yes');
}

function ecom_status(action) {
	switch (action) {
		case 'addBasket': 
			window.status = 'Add to Cart.'; 
			break;
		case 'wishList':
			window.status = 'Add to Wishlist.'; 
			break;
		case 'expandPhoto':	 
			window.status = 'Expand Photo.'; 
			break;
		case 'clear':	 
			window.status = ''; 
	}	 
}

function showmessage(msg) {
 alert(msg);
}

function changeColor(element, color) {
	if (element != null) element.style.backgroundColor = color; 
}

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 CF_RunContent(src){document.write(src);}

// tooltip
document.write('<link rel="stylesheet" type="text/css" href="/scripts/css/dhtmltip.css">');
document.write("<script type='text/javascript' src='/scripts/dhtmltip.js'><\/script>");

var sig1 = new Image();
var sig2 = new Image();
sig1.src = '/misc_images/dt-fade-100.png';
sig2.src = '/misc_images/morphogine-fade-100.png';

function showCredits(e, html) {
 document.onmousemove = null;
 if (InternetExplorer) ddrivetip(html, 280);	
 else ddrivetip(html);	
 positiontip(e);
 
 if (InternetExplorer && (msieversion() < 7)) correctPNG();
}

function hideCredits() {
	hideddrivetip();
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

function insertTips(id, tipPattern) {
	divs = document.getElementById(id);
	for (t = 0; t < tipPattern.length; t++)
		if (divs.innerText.search(tipPattern[t][0]) != -1) divs.innerHTML = divs.innerHTML.replace(tipPattern[t][0], tipPattern[t][1]);
}

function search(str) {
	document.forms[0].SrchStr.value = str; 
	document.forms[0].submitIt.click();
}

function srchCheck() {
	if (document.forms[0].SrchStr.value.length<3) { alert("Please enter a Search string of at least 3 characters."); (document.forms[0].SrchStr.type == 'hidden') ? '': document.forms[0].SrchStr.focus(); return false; }
	 else return true;
}
function fieldChecker(theform) {
	var theField = "";
	var msg = "";
	var doPrompt = 0;
	var isChecked = 0;
	
 	for (var i = 0; i<fieldCheck.length; i++) {
		if (fieldCheck[i][0] == '') { msg += "\n\n------- "+ fieldCheck[i][1] +" -------\n"; continue; }

		theField = eval("document.forms[theform]." + fieldCheck[i][0]);
		theField.id = fieldCheck[i][0];
		if (typeof jQuery != 'undefined') $('#'+ theField.id).addClass('FieldsReq');
												  
		if (fieldCheck[i][0].indexOf('email') != -1 && ( theField.value.indexOf('@')==-1 || theField.value.indexOf('.')==-1 ) ) { doPrompt += 1; msg += "- "+ fieldCheck[i][1] +" (invalid address)\n"; }
		else if (fieldCheck[i][0].indexOf('country') != -1 && (theField.value == "X" || theField.value == "")) { doPrompt += 1; msg += "- "+ fieldCheck[i][1] +"\n"; }	
		else if (fieldCheck[i][0] == "password") {
			if (theField.value.length<6) { doPrompt += 1; msg += "- Your password must be at least 6 characters.\n"; }
			if (fieldCheck[i][1] != "" && theField.value != eval("document.forms[theform]." + fieldCheck[i][1]).value) { doPrompt += 1; msg += "- Your passwords don't match.\n"; }
		}
		else if ((theField.length != null && (theField[0].type == "checkbox" || theField[0].type == "radio")) || theField.type == "checkbox" || theField.type == "radio") {
			if (theField.length != null) {
				isChecked = 0;
				
				for (var li = 0; li<theField.length; li++)
					if (theField[li].checked) isChecked++;
					
				if (isChecked == 0) { doPrompt += 1; msg += "- "+ fieldCheck[i][1] +"\n"; }
			}
			else if (!theField.checked) { doPrompt += 1; msg += "- "+ fieldCheck[i][1] +"\n"; }
		}
		else if (theField.value.length == 0) { doPrompt += 1; msg += "- "+ fieldCheck[i][1] +"\n"; }	
		else if (typeof jQuery != 'undefined') $('#'+ theField.id).removeClass('FieldsReq');

		if (doPrompt > 20) break;
	}
	
	if (doPrompt > 0) { alert("Please complete the highlighted fields:\n\n" + msg); return false; }
	
	return true;
}
