/*

Javascript file for ALL scripts used on CYC Sydney Hobart Yacht Race

Created 6/11/2002 by Todd Baker @ Massive

*/

function RollImage(objImage, strImage){
	var objStr,obj;
	if(document.images){
		objStr = 'document.' + objImage;
		obj = eval(objStr);
		obj.src = strImage;
	}
}
function SubmitSearch(){
	var strS = document.frmSearch.s.value
	if (strS != "" && strS != "Search"){
		document.frmSearch.submit()
	}else{
		alert("Please enter a word to search for.")
	}
}

function Reset(obj){
	if(obj.value == ""){
		obj.value = "Search";
	}
}

function preload() {
if (!document.images) return;
var ar = new Array();
var arguments = preload.arguments;
for (var i = 0; i < arguments.length; i++) {
  ar[i] = new Image();
  ar[i].src = arguments[i];
}
}

function openPopup(url, w, h){
	if (!w)
		w = 500;
		
	if (!h)
		h = 500;
  if(url.toLowerCase().indexOf("shop_item_pop.asp")>=0){
    var objGalleryWindow = window.open(url,'shop_item','height=560,width=550,left=50,top=50,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0');
  }
  else if (url != ""){
		var objGalleryWindow = window.open(url,'gallery','height=' + h + ',width=' + w + ',left=50,top=50,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0');
	}
}

function strTrim(strText) {
for (i=0; i<strText.length; ++i) {
	if (strText.charAt(i) != ' ') break;
}
if (i >= strText.length) return ('');
if (i > 0) strText = strText.substring(i, strText.length);
for (j=strText.length-1; j > i; --j) {
	if (strText.charAt(j) != ' ') break;
}
if (j < strText.length -1)
	strText = strText.substring(0, j+1);
return strText;
}
function ISEmail(s){
    var i = 1;
    var sLength = s.length;
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }
    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
} 

function openYacht(url){
	if (url != ""){
		var objYachtWindow = window.open(url,'yacht','height=600,width=600,left=50,top=50,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0');
	}
}
function openFavourites(url){
	//alert('here');
	if (url != ""){
		var objFavWindow = window.open(url,'yacht','height=600,width=600,left=50,top=50,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0');
	}
}
