// Enviroment identificator
var localIsDOM = document.getElementById?true:false;
var localIsJava = navigator.javaEnabled();
var localIsStrict = document.compatMode=='CSS1Compat';
var localPlatform = navigator.platform;
var localVersion = "0";
var localBrowser = "";
if(window.opera && localIsDOM) {
	localBrowser = "Opera";
	if(navigator.userAgent.search(/^.*Opera.([\d.]+).*$/) != -1)
		localVersion = navigator.userAgent.replace(/^.*Opera.([\d.]+).*$/, "$1");
	else if(window.print)
		localVersion = "6";
	else
		localVersion = "5";
} else if(document.all && document.all.item)
	localBrowser = 'MSIE';
if(navigator.appName=="Netscape") {
	if(!localIsDOM) {
		localBrowser = 'Netscape';
		localVersion = navigator.userAgent.replace(/^.*Mozilla.([\d.]+).*$/, "$1");
		if(localVersion != '')
			localVersion = "4";
	} else if(navigator.userAgent.indexOf("Safari") >= 0)
		localBrowser = 'Safari';
	else if(navigator.userAgent.indexOf("Netscape") >= 0)
		localBrowser = 'Netscape';
	else if(navigator.userAgent.indexOf("Firefox") >= 0)
		localBrowser = 'Firefox';
	else 
		localBrowser = 'Mozilla';
	
}
if(navigator.userAgent.indexOf("MSMSGS") >= 0)
	localBrowser = "WMessenger";
else if(navigator.userAgent.indexOf("e2dk") >= 0)
	localBrowser = "Edonkey";
else if(navigator.userAgent.indexOf("Gnutella") + navigator.userAgent.indexOf("Gnucleus") >= 0)
	localBrowser = "Gnutella";
else if(navigator.userAgent.indexOf("KazaaClient") >= 0)
	localBrowser = "Kazaa";

if(localVersion == '0' && localBrowser != '') {
	var rg = new RegExp("^.*"+localBrowser+".([\\d.]+).*$");
	localVersion = navigator.userAgent.replace(rg, "$1");
}
var localIsCookie = ((localBrowser == 'Netscape' && localVersion == '4')?(document.cookie != ''):navigator.cookieEnabled);


// Opener/Closer HTML block
function visibleBox(id,skipOpenClose) {
	elm1 = document.getElementById("open"+id);
	elm2 = document.getElementById("close"+id);
	elm3 = document.getElementById("box"+id);

	if(!elm3)
		return false;

	if (skipOpenClose) {
		elm3.style.display = (elm3.style.display == "")?"none":"";
	} else if(elm1) {
		if (elm1.style.display == "") {
			elm1.style.display = "none";
			if(elm2)
				elm2.style.display = "";
			elm3.style.display = "none";
		} else {
			elm1.style.display = "";
			if(elm2)
				elm2.style.display = "none";
			elm3.style.display = "";
		}
	}
}


// URL encode
function urlEncode(url) {
	return url.replace(/\s/g, "+").replace(/&/, "&amp;").replace(/"/, "&quot;")
}

function productimagedetail(product_id) { 
	var w = "550"; //width 
	var h = "500"; //height 
	window.open('http://www.allmoviereplicas.com/store/product_detailed_images.php?productid='+product_id,"detailedproduct","width="+w+",height="+h+",resizable,scrollbars=yes"); 
}

function ship2diffOpen(mydata, country_name, state_name, county_name, lbl_state, state, is_no_input, full_state, county, default_county, default_countyid, form_name, zipcode_name, user_info_county_name, title_data) {
	
		var obj = document.getElementById('ship2diff');
		var box = document.getElementById('ship_box');
		
		if (obj.checked ==true) {
			box.style.display  = "";
		} else {
			box.style.display  = "none";
			document.getElementById('s_address').value="";
			document.getElementById('s_address_2').value="";
			document.getElementById('s_city').value="";
			document.getElementById('s_zipcode').value="";
			
			document.getElementById('s_firstname').value="";
			document.getElementById('s_lastname').value="";
			
			
			
			document.getElementById(country_name+ '_holder').innerHTML = '<select name="'+ country_name + '"id="'+ country_name + '" onChange="check_zip_code_field(document.forms[\'' +form_name+ '\'].'+country_name+', document.forms[\'' +form_name+ '\'].'+zipcode_name+'); change_states(document.getElementById(\''+ country_name+'\'), \''+state_name+'\', \''+county_name+'\', \''+lbl_state+'\', \''+state+'\', \''+is_no_input+'\', \''+full_state+'\', \''+user_info_county_name+'\', \''+user_info_county_name+'\'); change_counties(\'' + county_name +'\', document.getElementById(\'_' + state_name + '\'), document.getElementById(\'' + country_name +'\'), \''+user_info_county_name+'\', \''+ user_info_county_name +'\');">' +mydata + '</select>';
			
			document.getElementById('title_holder').innerHTML = '<select name="s_title">' + title_data + '</select>';
			
			change_states(document.getElementById(country_name), state_name , county_name, lbl_state , state , is_no_input , full_state, '', county, default_county , default_countyid);
			change_counties( county_name, document.getElementById(state_name), document.getElementById(country_name), default_county, default_countyid);
		}
}


function update_category_layer(id) {
	var maximageWidth =151;
	var maximageHeight =251;
	var padding =6;
	
	var image_tag = document.getElementById("image_tag_" + id);
	var imageWidth = parseInt(image_tag.width);
	var imageHeight = parseInt(image_tag.height);	
	
	var tmp1 = 0;
	var tmp2 = 0;
	var scale_image = false;
		
	if (imageWidth > maximageWidth) {
		tmp1 = imageWidth/maximageWidth;
		imageWidth = maximageWidth;		
		imageHeight = imageHeight/tmp1;
		scale_image = true;
	}
	
	if (imageHeight>maximageHeight) {
		tmp1 = imageHeight/maximageHeight;
		imageHeight = maximageHeight;
		imageWidth = imageWidth/tmp1;
		scale_image = true;
	}
	
	if (scale_image==true) {
		imageWidth = Math.round(imageWidth);
		imageHeight = Math.round(imageHeight);
		
		image_tag.width = imageWidth;
		image_tag.height = imageHeight;
	}	
	
	
	var text_tag = document.getElementById("text_holder_" + id);
	tmp2 = imageWidth - padding;	
	text_tag.style.width = tmp2.toString() + "px";	
}

function MM_changeColor1(id) {  
  var link_holder = document.getElementById("text_holder_" + id);
  link_holder.className ="text_holder simplebg";  
  link_holder.style.color = "#7a7d72";
}

function MM_changeColor2(id) {  
  var link_holder = document.getElementById("text_holder_" + id);  
  link_holder.className ="text_holder transbg";
  link_holder.style.color = "#000000";
}

function validatePrices() {
	val = 0;
	for( i = 0; i < document.pricesearchform.search_group1.length; i++ ) {
		if ( document.pricesearchform.search_group1[i].checked == true ) {
			val = document.pricesearchform.search_group1[i].value;
		}
	}
	if (val==0) {
		document.getElementById('posted_data[price_min]').value = 0.01;
		document.getElementById('posted_data[price_max]').value = "";
	}
	if (val==1) {
		document.getElementById('posted_data[price_min]').value = 0.01;
		document.getElementById('posted_data[price_max]').value = 10;		
	}
	if (val==2) {
		document.getElementById('posted_data[price_min]').value = 10;
		document.getElementById('posted_data[price_max]').value = 20;
	}
	if (val==3) {
		document.getElementById('posted_data[price_min]').value = 20;
		document.getElementById('posted_data[price_max]').value = 75;
	}
	if (val==4) {
		document.getElementById('posted_data[price_min]').value = 75;
		document.getElementById('posted_data[price_max]').value = 100;
	}
	if (val==5) {
		document.getElementById('posted_data[price_min]').value = 100;
		document.getElementById('posted_data[price_max]').value = 500;
	}
	if (val==6) {
		document.getElementById('posted_data[price_min]').value = 500;
		document.getElementById('posted_data[price_max]').value = "";
	}	
	document.pricesearchform.submit();	
}


function PopupPic(bigPic,title,w,h) {	
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var smarty_hack = 'head';	
	var newWindow;
	nme='picture_pop';
	newWindow = window.open('',nme,'height='+h+',width='+w+',top='+wint+',left='+winl+',resizable=0,scrollbars=0');
	newWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
	newWindow.document.write('<html><head><title>'+title+'</title>');
	newWindow.document.write('<meta http-equiv="content-type" content="text/html; charset=UTF-8" />');	
	newWindow.document.write('</'+smarty_hack+'><body onclick="self.close()" style="background: none #353535; padding:0px;margin:0px;">');
	newWindow.document.write('<div align="center"><img src="'+bigPic+'" alt="'+title+'" /></div>');	
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();	
	return newWindow;	
}
