/*
	----------------------------------------------
	Tri Investments
	Copyright (c) 2008 Artsgraphica	www.artsgraphica.com
	This code cannot be redistributed without permission from Artsgraphica
	----------------------------------------------
*/

window.onload = preparePage;

var timeout;

function preparePage()
{
	// Add DOM Rollovers
	//prepareRollovers();
	domRollover();
	// Add Dropdown
	//prepareDropdown();
}

// Function to add DOM rollovers
function prepareRollovers()
{
	var image_array = document.getElementsByTagName("img");
	for (i=0; i<image_array.length; i++)
	{
		// Loop around images
		if(image_array[i].className == "rollover")
		{
			image_array[i].onmouseover = function() 
			{
				// Add this function which works out rollover based on -o.ext
				var length = this.getAttribute('src').length;
				//var new_src = this.getAttribute('src').substr(0, length-4) + "-o" + this.getAttribute('src').substr(-4);
				var new_src = this.getAttribute('src').substr(0, length-4) + "-o.gif" 
				//alert(this);
				
				this.setAttribute('src', new_src);
				return false;
			}
			
			image_array[i].onmouseout = function() 
			{
				// Add this function which works out rollover based on -o.ext
				var length = this.getAttribute('src').length;
				var src = this.getAttribute('src').substr(0, length-6) + ".gif";
				this.setAttribute('src', src);
				return false;
			}
		}
	}
}

function domRollover() {
	if (navigator.userAgent.match(/Opera (\S+)/)) {
		var operaVersion = parseInt(navigator.userAgent.match(/Opera (\S+)/)[1]);
	}
	if (!document.getElementById||operaVersion <7) return;
	var imgarr=document.getElementsByTagName('img');
	var imgPreload=new Array();
	var imgSrc=new Array();
	var imgClass=new Array();
	for (i=0;i<imgarr.length;i++){
		if (imgarr[i].className.indexOf('rollover')!=-1){
			imgSrc[i]=imgarr[i].getAttribute('src');
			imgClass[i]=imgarr[i].className;
			imgPreload[i]=new Image();
			if (imgClass[i].match(/rollover (\S+)/)) {
				imgPreload[i].src = imgClass[i].match(/rollover (\S+)/)[1]
			}
			imgarr[i].setAttribute('xsrc', imgSrc[i]);
			imgarr[i].onmouseover=function(){
				this.setAttribute('src',this.className.match(/rollover (\S+)/)[1])
			}
			imgarr[i].onmouseout=function(){
				this.setAttribute('src',this.getAttribute('xsrc'))
			}
		}
	}
}


function validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }


function doJumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}