function load_prod_Image(image){
	imgString = 'imgTemp = document.getElementById("middle")';
	eval(imgString);
	imgTemp.src = image;
}

function ViewImage(ifile,ix,iy,ititle) {
	var win;
	var sWidth;
	var sHeight;
	var NS = (document.layers) ? 1 : 0;
	win = window.open("","imageviewer","width="+ix+",height="+iy+",menubar=no,toolbar=no");
	if (NS) {
		sWidth = win.innerWidth;
		sHeight = win.innerHeight;
	} else {
		sWidth = win.document.body.clientWidth;
		sHeight = win.document.body.clientHeight;
	}
	if(sWidth!=ix || sHeight!=iy) {
		win.close();
		setTimeout("ViewImage('"+ifile+"',"+ix+","+iy+",'"+ititle+"')", 250);
		return;
	}
	win.document.open();
	win.document.write("<html><head><title>"+ititle+"</title>");
	win.document.write("</head><body>");
	win.document.write('<div style="position:absolute;width:'+ix+'px;height:'+iy+'px;left:0px;top:0px">');
	win.document.write("<img src="+ifile+"></div></body></html>");
	win.document.close();
}


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();
     }
}

function PopAndBack()
{
  CurrencyWindow = window.open ('', 'CurrencyWindow', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,height=150,width=575')
  CurrencyWindow.focus()
  CurrencyWindow.location.href = 'http://www.xe.com/pca/input.cgi'
}

function empty_basket(){
	if(confirm("Do you really want to empty your basket?")){
		window.location = "/products/?action=empty";
	}	
}

function remove_from_basket(item,item_id){
	if(confirm("Do you really want to remove "+item+" from your basket?")){
		window.location = "/products/?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 check_prods(allItem){

	if(allItem.checked == false){
		setFlag = false;
	}else{
		setFlag = true;
	}
	
	entry_form = eval("document.items");
	
	entry_form.elements["_id[]"].checked = setFlag;
	
	for(x = 0;x < entry_form.elements["_id[]"].length; x++){
		entry_form.elements["_id[]"][x].checked = setFlag;
	}
}

function checkAllSet(allItem, items){
	
	entry_form = eval("document.checklist");
	
	
	if(entry_form.elements[allItem].checked == false){
		entry_form.elements[allItem].checked = true;
	}else{
		entry_form.elements[allItem].checked = false;
	}
	
	checkAll(allItem, items);
}

function checkAll(allItem, items){
	entry_form = eval("document.checklist");
	
	allItem = entry_form.elements[allItem];
	
	if(allItem.checked == false){
		setFlag = false;
		setOver = "out";	
	}else{
		setFlag = true;
		setOver = "over";
	}
	
	entry_form.elements["products[]"].checked = setFlag;
	
	for(x = 0;x < entry_form.elements["products[]"].length; x++){
		
		if(items.match(","+entry_form.elements["products[]"][x].value+",") != null)
			entry_form.elements["products[]"][x].checked = setFlag;
	}
}


//******************************************

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 agency_cmb_type(id){
	theform = document.register;
	
	if(id == "Other"){
		toggleTable('type_1',1);
		theform.elements["data[agency][0][type]"].value = "";
	}else{
		toggleTable('type_1',0);
		theform.elements["data[agency][0][type]"].value = id;
	}
}



function statusSetter(str) {
   window.defaultStatus = str;
   window.status = str;
}

function submitForm(theform, theaction){
	theform.action = theaction;
	theform.submit();
}

