// JavaScript Document


// ROLLOVER
function roll (vID, vNum, DL, TF) {
	
	if (TF == true) {
		newImage = "url(images/bg_on" + vNum + ".jpg)";
		newColor = "#FFFFFF";
	} else {
		if (DL == true) {
			newImage = "url(images/bg_dark" + vNum + ".jpg)";
		} else {
			newImage = "url(images/bg_light" + vNum + ".jpg)";
		}
		newColor = "#666666";
	}
	document.getElementById(vID).style.backgroundImage = newImage;
	document.getElementById(vID).style.color = newColor;
	
}





function imageWindow (ID, GID) {
	var myName = "Image";
	var h = "400";
	var w = "550";
	var scroll = "no";
	var winl = 50;
	var wint = 50;
	winprops = 'height=' + h +',width=' + w + ',top=' + wint + ',left=' + winl + ',scrollbars=' + scroll + ',resizable=yes';
	
	win = window.open (("images.php?ID=" + ID + "&GID=" + GID), myName, winprops)
}



function showVideo () {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="475" height="356" id="video1" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="../flash/video1.swf" />');
	document.write('<param name="quality" value="best" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="../flash/video1.swf" quality="best" bgcolor="#ffffff" width="475" height="356" name="video1" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');

}

function showVideo2 () {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="475" height="356" id="video2" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="../flash/video2.swf" />');
	document.write('<param name="quality" value="best" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="../flash/video2.swf" quality="best" bgcolor="#ffffff" width="475" height="356" name="video2" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');

}



function adjustFlashContent () {
	var x=document.getElementById("intro");
	x.style.height = '100%';
	x.style.width = '100%';
}

function showIntro () {
	document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="1000" height="650" id="intro" align="middle">\n');
	document.write ('<param name="allowScriptAccess" value="sameDomain" />\n');	
	document.write ('<param name="movie" value="flash/intro081103.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" />\n');	
	document.write ('<embed src="flash/intro081103.swf" quality="high" bgcolor="#FFFFFF" width="1000" height="650" name="intro" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');	
	document.write ('</object>\n');	
}


//SHOPPING CART FUNCTIONS

function getCookie(c_name) { 
	if (document.cookie.length>0) {
		
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) {
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
		
	}
	return "";
}

function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	
}


function addToCart(name, price, id) {
	
	var cart = getCookie("DBCart");
	
	
	var f = document.getElementById("orderForm" + id);
	var quantity = (f.quantity.selectedIndex + 1);
	
	
	var purchase = (name + "%%%" + price + "%%%" + quantity + "%%%%");
	
	if (cart != undefined) {
		purchase = cart+purchase;
	}
	
	setCookie("DBCart", purchase, 365);
	
	alert ("Item Added To Cart");
}


function removeFromCart(id) {
	
	var cart = getCookie("DBCart");
	
	cart = cart.split("%%%%");
	var updated = "";
	
	for (i=0; i<cart.length-1; i++) {
		if (i!= id) {
			updated += cart[i] + "%%%%";
		}
	}
	
	setCookie("DBCart", updated, 365);
	alert ("Item Removed From Cart");
}

function checkout () {
	
	var f = document.getElementById("orderForm");
	
	var fname = f.fname.value;
	var lname = f.lname.value;
	var phone = f.phone.value;
	var email = f.email.value;
	var address = f.address.value;
	var city = f.city.value;
	var province = f.province.value;
	var postalcode = f.postalcode.value;
	
	
	var success = true;
	
	if (fname == "" || lname == "" || phone == "" || email == "" || address == "" || city == "" || province == "" || postalcode == "") {
		success = false;
	}
	
		
	
	if (success) {
		f.submit();	
	} else {
		alert ("Please fill out all required fields.");	
	}
}

function deleteCart () {
	setCookie("DBCart", "", -3600);
}

