// JavaScript Document
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_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_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];}
}

/* shopping cart stuff */


function checkout(){/*
  if (document.viewcartform.orderTotal.value > 0){
		document.viewcartform.action='checkout/checkout.php';
		return true;
	}
  else{
		alert("Your shopping cart is empty!");
		return false;
	}*/
}

function resetForm(){
  document.viewcartform.action='processes/updatecart.php'; 
  document.viewcartform.target='';
  return true;
}

function openTarget(form, features, windowName){
  if (!windowName){
	  windowName = 'formTarget' + (new Date().getTime());
  	form.target = windowName;
  	open ('', windowName, features);
	}
}




/*
function fadeElement
author: Glen Kleinig for PerthWeb PTY LTD
notes:	obj: can either be an object literal (this) or a reference to 
		an object in the document ('about_btn').
		oSrc: a string representing the filepath/name of the image to fade to
		duration: duration of fade in seconds.

*/
	function fadeElement(obj, oSrc, duration) {
	
		if(typeof(obj)!="object") {
			obj = MM_findObj(obj);
		}
		
		if (document.all) {
			obj.style.filter="blendTrans(duration="+duration+")";			
			obj.filters.blendTrans.Apply();
			obj.src = oSrc;
			obj.filters.blendTrans.Play();
		}
		else 
		{
			obj.src = oSrc;
		}
		
	}

// validate contact form
function contactForm_Validator(theForm)
{
if (theForm.Name.value == "")
  {
    alert("Please enter your name.");
    theForm.Name.focus();
    return (false);
  }
else if (theForm.Email.value.indexOf("@") == -1 )
  {
    alert("Please enter a valid email address.");
    theForm.Email.focus();
    return (false);
  }
  
  else if (theForm.GeneralQueries.value == "")
  {
    alert("Please enter your query.");
    theForm.GeneralQueries.focus();
    return (false);
  }
}

function trim(str){
   return str.replace(/^\s*|\s*$/g,"");
 }

// validate search form
function searchFormCheck(theForm){
  if((trim(theForm.keyword.value) == "") && (trim(theForm.category.value) == "")){
    alert("Please enter a keyword for your search, or select a category you would like to search in.");
	return (false);
  }
}


//flash detect
var flashVersion = 0;function getFlashVersion(){var latestFlashVersion=8;var agent=navigator.userAgent.toLowerCase();if(navigator.plugins!=null&&navigator.plugins.length>0){var flashPlugin=navigator.plugins['Shockwave Flash'];if (typeof flashPlugin=='object'){for(var i=latestFlashVersion;i>=3;i--){if (flashPlugin.description.indexOf(i+'.')!=-1){flashVersion=i;break;}}}}else if(agent.indexOf("msie")!=-1&&parseInt(navigator.appVersion)>=4&&agent.indexOf("win")!=-1&&agent.indexOf("16bit")==-1){var doc='<scr'+'ipt language="VBScript"\>\n';doc+='On Error Resume Next \n';doc+='Dim obFlash \n';doc+='For i='+latestFlashVersion+' To 3 Step -1 \n';doc+='Set obFlash=CreateObject("ShockwaveFlash.ShockwaveFlash."&i)\n';doc+='If IsObject(obFlash) Then \n';doc+='flashVersion=i \n';doc+='Exit For \n';doc+='End If \n';doc+='Next \n';doc+='</script>\n';document.write(doc);} else{flashVersion=flashVersion_DONTKNOW;}return flashVersion;}flashVersion_DONTKNOW=-1;function flasher(flashfile,statik,minver,height,width,alt){var flashVersion=getFlashVersion();if(flashVersion>=minver){document.write('<object type="application/x-shockwave-flash" data="' + flashfile + '" width="' + width + '" height="' + height + '">');document.write('<param name="movie" value="' + flashfile + '" /><param name="wmode" value="transparent" />');document.write('<img src="' + statik + '" width="' + width + '" height="' + height + '" alt="' + alt + '" title="" />');document.write(' </object>');}else{document.write('<img src="' + statik + '" width="' + width + '" height="' + height + '" alt="' + alt + '" title="" />');}}