
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
  if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
  function mischandler(){
   return false;
 }
  function mousehandler(e){
 	var myevent = (isNS) ? e : event;
 	var eventbutton = (isNS) ? myevent.which : myevent.button;
    if((eventbutton==2)||(eventbutton==3)) return false;
 }
 document.oncontextmenu = mischandler;
 document.onmousedown = mousehandler;
 document.onmouseup = mousehandler;

function loadProducts(vars){
		
	document.getElementById("products").innerHTML = '<div class="loading"></div>';
	
	$.post("/ajax/products.php", {vars:vars}, function(data) {
		document.getElementById("products").innerHTML = data;
		var script = document.getElementById("script").innerHTML;
		eval(script);
	});
}

function changeCurrency(id){
	
	document.getElementById("products").innerHTML = '<div class="loading"></div>';
	
	$.post("/ajax/products.php", {action:"change_currency",currency_id:id}, function(data) {
		document.getElementById("products").innerHTML = data;
		var script = document.getElementById("script").innerHTML;
		eval(script);
	});
}

function changeOrder(url,rst){
	
	var n_products = document.forms['products'].n_products.value;
	var start = document.forms['products'].start.value;
	var price = document.forms['filter'].price.value;
	var recycled = "";
	var neww = "";
	
	if(document.forms['filter'].recycled.checked==true){
		recycled = 1;	
	}
	
	if(document.forms['filter'].elements['new'].checked==true){
		neww = 1;	
	}
	
	if(rst==1){start=0;}
	
	location.href = url+'?n_products='+n_products+'&start='+start+"&price="+price+"&recycled="+recycled+"&new="+neww;
}

function changeOrderButton(which,url){
	
	if(which=="previous"){
		document.forms['products'].start.selectedIndex = document.forms['products'].start.selectedIndex-1;
	}
	
	if(which=="next"){
		document.forms['products'].start.selectedIndex = document.forms['products'].start.selectedIndex+1;
	}
	
	changeOrder(url,0);
	
}

function showSignUp(){
	
	var ob = document.getElementById("sup");
	//var ob2 = document.getElementById("sign_up");
	ob.style.visibility="visible";
	//ob2.style.borderLeft="1px #fff solid";
	//ob2.style.borderRight="1px #fff solid";
	
		
	var pos = $(".sign_up").offset();  
	var width = $(".sign_up").width();
	$("#sup").css( { "left": (pos.left-120) + "px", "top":pos.top +35+ "px" } );
}

function hideSignUp(){
	var ob = document.getElementById("sup");
	//var ob2 = document.getElementById("sign_up");
	ob.style.visibility="hidden";	
	//ob2.style.borderLeft="none";
	//ob2.style.borderRight="none";
}

$(document).click(function() { 
	//var ob = document.getElementById("sup");
	//ob.style.visibility="hidden";	
 }); 

 $('#sup').click(function(e){ 
     //e.stopPropagation(); 
 });
 
function clearFilter(){
	document.forms['filter'].size.value="";
	document.forms['filter'].keywords.value="";
	document.forms['filter'].recycled.checked=false;
	document.forms['filter'].elements['new'].checked=false;
	document.forms['filter'].price.value="";
	document.forms['filter'].submit();
}


function signUp(){
	
	var bad=0;
	if(document.forms["sign_up_panel"].sname.value==""){bad=1;}
	if(document.forms["sign_up_panel"].semail.value==""){bad=1;}
	if(document.forms["sign_up_panel"].captcha_code.value==""){bad=1;}
	
	if(bad==1){
		alert("Please complete all fields.");
		return;
	}
	
	$.post("/ajax/check_captcha.php", {captcha_code:document.forms['sign_up_panel'].captcha_code.value}, function(data) {
		if(data=="bad"){
			alert("The word you entered did not match the one on screen.\n\Please try again.");
			return;
		}else{
			document.forms['sign_up_panel'].submit();	
		}
	});
	
}

function showHideOther(){

	var activity = document.getElementById("activity").value;
	if(activity == 7){
		document.getElementById("other_type").style.display = "block";			
	} else {
		document.getElementById("other_type").value="";
		document.getElementById("other_type").style.display = "none";
	}
}


function sendEnquiry(){
	
	var bad=0;
	if(document.forms["enquiry"].f_name.value==""){bad=1;}
	if(document.forms["enquiry"].l_name.value==""){bad=1;}
	if(document.forms["enquiry"].email.value==""){bad=1;}
	if(document.forms["enquiry"].captcha_code.value==""){bad=1;}
	
	if(bad==1){
		alert("Please complete all fields marked with *.");
		return;
	}
	
	$.post("/ajax/check_captcha.php", {captcha_code:document.forms['enquiry'].captcha_code.value}, function(data) {
		if(data=="bad"){
			alert("The word you entered did not match the one on screen.\n\Please try again.");
			return;
		}else{
			document.forms['enquiry'].submit();	
		}
	});
	
}








