var d = document;
var params = d.location.search;
var sid = "";

function imgChange(iPath, iName) {
	d[iName].src=iPath;
}
function getParamValue(v) {
	var p_a = params.substring(params.indexOf("?")+1, params.length).split("&");
	for (var i=0; i<p_a.length; i++){
		var s_a = p_a[i].split("=");
		if(s_a[0] == v){
			return s_a[1];
			break;
		}
	}
}
function launchPopUp(URL,ID,WIDTH,HEIGHT) {
	winObject = window.open(URL,ID,'width='+WIDTH+',height='+HEIGHT+',resizable=0,scrollbars=0,menubar=0,toolbar=0,location=0,directories=0,status=0');
	var clientWidth = screen.availWidth;
	var clientHeight = screen.availHeight;
	var xPos = (clientWidth - WIDTH)/2;
	var yPos = (clientHeight - HEIGHT)/2;
	winObject.moveTo(xPos,yPos);
}

function validateform(f){
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(f.email.value)) {
		if(f.firstname.value !="" && f.lastname.value !="" && f.country.value !="") {
			return true;
		} else {
			alert("Please enter all required fields.");
			return false;
		}
	} else {
		alert("Please enter a valid email address.");
		return false;
	}
}
function validateemail(f){
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(f.email.value)) {
		return true;
	} else {
		alert("Please enter a valid email address.");
		return false;
	}
}
function addItemToCart(item_id,redirect){
	var qty = document.getElementById("desired_" + item_id).value;
	var url = "store.redir.php?action=add&inv_id=" + item_id + "&quantity=" + qty + "&refer=" + redirect;
	document.location = url;
}

function addItemToCartFromRegistry(item_id,registry_id,redirect){
	var qty = document.getElementById("desired_" + item_id).value;
	var url = "store.redir.php?action=add&inv_id=" + item_id + "&registry_id=" + registry_id + "&quantity=" + qty + "&refer=" + redirect;
	document.location = url;
}

function addItemToRegistry(product_id,item_id,redirect){
	var qty = document.getElementById("desired_" + item_id).value;
	var url = "addtoregistry.php?p_id=" + product_id + "&quantity=" + qty + "&refer=" + redirect;
	document.location = url;
}
	
function showsearch() {
	var divobj = (d.layers)?d["searchformdiv"]:d.all?d.all["searchformdiv"].style:d.getElementById("searchformdiv").style;
	divobj.visibility = "visible";
	document.searchform.search.focus();
}
function showcartinfo() {
	var divobj = (d.layers)?d["cartinfodiv"]:d.all?d.all["cartinfodiv"].style:d.getElementById("cartinfodiv").style;
	divobj.visibility = "visible";
}

AC_FL_RunContent = 0;
DetectFlashVer = 0;
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Revision of Flash required
var requiredRevision = 24;
// -----------------------------------------------------------------------------

function writeFL(_swf, _w, _h){
	if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
		if(hasRightVersion) {  // if we've detected an acceptable version
			// embed the flash movie
			AC_FL_RunContent(
				'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0',
				'width', _w,
				'height', _h,
				'src', _swf,
				'quality', 'high',
				'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
				'align', 'middle',
				'play', 'true',
				'loop', 'true',
				'scale', 'showall',
				'wmode', 'window',
				'devicefont', 'false',
				'id', _swf,
				'bgcolor', '#ffffff',
				'name', 'site/gallery',
				'menu', 'false',
				'allowScriptAccess','sameDomain',
				'allowFullScreen','false',
				'movie', _swf,
				'salign', ''
				); //end AC code
		} else {  // flash is too old or we can't detect the plugin
			var alternateContent = 'Alternate HTML content should be placed here.'
				+ 'This content requires the Adobe Flash Player.'
				+ '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
			document.write(alternateContent);  // insert non-flash content
		}
	}
}
