// Image Swaper ----
var imageDir = "images/";
var imageNames = new Array("hp_mn_01","hp_mn_02","hp_mn_03","hp_mn_04","hp_mn_05","hp_mn_06","sb_mn_01","sb_mn_02","sb_mn_03","sb_mn_04","sb_mn_05","sb_mn_06");

// Browser Detector ----
function BrowserMaster() {
	this.ver=navigator.appVersion;
	this.ua=navigator.userAgent;
	this.mac=(this.ua.indexOf("Mac")!=-1)?1:0;
	this.win=(this.ua.toUpperCase().indexOf("WINDOWS")!=-1)||(this.ua.toUpperCase().indexOf("WINNT")!=-1)?1:0;
	this.x11=(this.ua.toUpperCase().indexOf("X11")!=-1)?1:0;
	this.dom=document.getElementById?1:0;
	this.ie5=(this.ver.indexOf("MSIE")>-1 && this.dom)?1:0; 
	this.ie4=(document.all && !this.dom)?1:0; 
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0; 
	this.bw=this.ie5?'ie5':this.ie4?'ie4':this.ns4?'ns4':this.ns5?'ns5':''
	return this;
}

bw=new BrowserMaster();

// Image Swaper ----
var onImg = new Array();
var offImg = new Array();

for (var i = 0; i < imageNames.length; i++) {
	refName = imageNames[i];
	imgName = imageDir + refName + ".gif";
	imgHLName = imageDir + refName + "_on.gif";
	onImg[refName] = new Image();
	offImg[refName] = new Image();
	onImg[refName].src = imgHLName;
	offImg[refName].src = imgName;
}

function on(imgName,layerName) {
	if (bw.ns4&&layerName!=null) document.layers[layerName].document.images[imgName].src=onImg[imgName].src
	else document[imgName].src = onImg[imgName].src
}

function off(imgName,layerName) {
	if (bw.ns4&&layerName!=null) document.layers[layerName].document.images[imgName].src=offImg[imgName].src
	else document[imgName].src = offImg[imgName].src
}
// End Image Swaper ----

function checkform(myForm){
	var flag =0;
	var msg = "";
	if(myForm.yourname.value == ""){
		flag = 1;
		msg = msg + "Please input the name.\n";
	}
	if(myForm.phone.value == ""){
		flag = 1;
		msg = msg + "Please input the phone number.\n";
	}
	if(myForm.email.value == ""){
		flag = 1;
		msg = msg + "Please input the email address.\n";
	}
	if(flag==0){
		myForm.subject.value="Inquiry%20Form";
		inquiryValue=replace(myForm.inquiry.value,"\r","%0a%0d");
		addressValue=replace(myForm.address.value,"\r","%0a%0d");
		myForm.body.value="Name:"+myForm.yourname.value+"%0a%0d"+
			"Title:"+myForm.title.value+"%0a%0d"+
			"Company Name:"+myForm.company.value+"%0a%0d%0a%0d"+
			"Address:"+addressValue+"%0a%0d"+
			"City:"+myForm.city.value+"%0a%0d"+
			"State/Province/Region:"+myForm.state.value+"%0a%0d"+
			"Country:"+myForm.country.value+"%0a%0d"+
			"Zip/Postal Code:"+myForm.zip.value+"%0a%0d%0a%0d"+
			"Telephone:"+myForm.phone.value+"%0a%0d"+
			"Fax:"+myForm.fax.value+"%0a%0d"+
			"Email:"+myForm.email.value+"%0a%0d%0a%0d"+
			"Inquiry:"+inquiryValue+"%0a%0d"
			document.location.href="mailto:pang@quattrostudios.com?subject="+myForm.subject.value+"&body=Olympic Equiry Form%0a%0d%0a%0d"+myForm.body.value;
//		myForm.submit();
	}else{
		alert(msg);
	}
}

function replace(string,text,by) {
// Replaces text with by in string
	var i = string.indexOf(text);
	var newstr = '';
	if ((!i) || (i == -1)) return string;
	newstr += string.substring(0,i) + by;
	if (i+text.length < string.length) newstr += replace(string.substring(i+text.length,string.length),text,by);
	return newstr;
}

function popup(url, popW, popH) {
	popWidth=popW?popW:320;
	popHeight=popH?popH:320;
	x=Math.round(Math.random()*10000000);
	popName=x.toString();

	var awidth = screen.availWidth - 12;; //screen width
	var aheight = screen.availHeight - 12;; //screen height
	win_x = Math.floor((awidth - popWidth) / 2);
	win_y = Math.floor((aheight - popHeight) / 2);
	myWin=window.open(url, popName, "width="+popWidth+",height="+popHeight+",location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no")
	myWin.moveTo(win_x, win_y);
}
function excel_popup() {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax =530, yMax=460;

    var xOffset = (xMax - 530)/2, yOffset = (yMax - 460)/2;

    window.open('excel_1.html','_blank',
    'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=530,height=460,screenX=' + xOffset + ',screenY=' + yOffset + ',top=' + yOffset + ',left=' + xOffset);
}