function browser(){
	this.dom = (document.getElementById) ? true : false;
	this.ns4 = (document.layers) ? true : false;
	this.ie = (document.all) ? true : false;
	this.ns6 = this.dom && !this.ie
	this.ie4 = this.ie && !this.dom;
	this.opera = (navigator.userAgent.indexOf("Opera") != -1);
	this.mac = (navigator.appVersion.indexOf("Mac") != -1);
	this.macie4 = this.ie4 || this.mac;
	this.dhtml = (this.dom || this.ns4 || this.ie || this.ie4 || this.opera || !this.mac) ? true : false;
	this.dhtml = (this.mac)?false:true;
	return this;
}

var bw = new browser();

function toggleTable(el,st) {
	var myelement = document.getElementById(el);

	if(st == 1){
		if(bw.ie){
			myelement.style.display = "inline"
		}else{
			myelement.style.display = "table-cell"
		}
	}else{
		myelement.style.display = "none"
	}
}

function pop(url, name, w, h, rs, sb, mn, st, oth) {
var resize = ((rs) ? "resizable="+rs+"," : "");
var scroll = ((sb) ? "scrollbars="+sb+"," : "");
var menu = ((mn) ? "toolbar="+mn+",location="+mn+",menubar="+mn+"," : "");
var sts = ((st) ? "status="+st+"," : "");

     var popupWin = window.open(url, name, resize + scroll + menu + sts + "width=" + w + ",height=" + h + " " + oth);
     if (document.layers) {
          popupWin.focus();
     }
}

//shop
function empty_basket(){
	if(confirm("Do you really want to empty your Cart?")){
		window.location = "/order/?action=empty";
	}
}

function remove_from_basket(item,item_id){
	if(confirm("Do you really want to remove "+item+" from your Cart?")){
		window.location = "/order/?b="+item_id+"&action=remove";
	}
}

function delete_basket_Form(basketform, theaction){
	if(confirm("Do you really want to remove selected items?")){
		basketform.action = theaction;
		basketform.submit();
	}
}

function submitForm(theform, theaction){

	theform.action = theaction;
	theform.submit();
}


$(document).ready( function(){

	$(".rollover").hover(
		function () {
			var img_orig = $(this).attr("src");
			var img_replace = img_orig.replace(".jpg", "_on.jpg");
			$(this).attr( "src", img_replace )
		},
		function () {
			var img_orig = $(this).attr("src");
			var img_replace = img_orig.replace("_on.jpg", ".jpg");
			$(this).attr( "src", img_replace )
		}
	);

	$(".nav").hover(
		function () {
			var img_orig = $(this).attr("src");
			var img_replace = img_orig.replace("_off.gif", "_on.gif");
			$(this).attr( "src", img_replace )
		},
		function () {
			var img_orig = $(this).attr("src");
			var img_replace = img_orig.replace("_on.gif", "_off.gif");
			$(this).attr( "src", img_replace )
		}
	);

	$(".button").hover(
		function () {
			var img_orig = $(this).attr("src");
			var img_replace = img_orig.replace("_off.gif", "_on.gif");
			$(this).attr( "src", img_replace )
		},
		function () {
			var img_orig = $(this).attr("src");
			var img_replace = img_orig.replace("_on.gif", "_off.gif");
			$(this).attr( "src", img_replace )
		}
	);

});


function submitEnter(myfield,e){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13){
	   myfield.form.submit();
	   return false;
	}else{
	   return true;
	}
}