
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function foc(element){
this.focus();
}

function resetForm(){
document.login.user.value = "";
document.login.pass.value = "";
}

function openImageWindow(imageSrc,imageTitle, code) {
    fileName = 'image_view.htm?' + escape(imageSrc) + '~' + escape(imageTitle)+ '~' + escape(code);
    myWindowHandle = window.open(fileName,'windowName','directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
}

function windowOpen(name) {
    //myWindow = window.open(name,"windowRef","width=800,height=600,top=0,left=0,screenX=0,screenY=0");
    myWindow = window.open(name,"windowRef","directories=no,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes");
    //myWindow.location.href = "apage.html";
    if (!myWindow.opener) myWindow.opener = self;
}

function max(){
    window.moveTo(0,0);
    if (IE) {
        window.resizeTo(screen.availWidth,screen.availHeight);
    }
    if (NS) {
       window.outerHeight = screen.availHeight;
       window.outerWidth = screen.availWidth;
    }
}

function changeBack(srcElement) {
  if(srcElement.bgColor == "#ffffff")
  {
      srcElement.bgColor = "#CAE1F9";
  }else{
      srcElement.bgColor = "#ffffff";
  }
}

var lastTab, newTab;

function setLast(lastOne){
	newTab = lastOne;
}

function openPhoto() {
    if (newTab){
	    if (lastTab) {
		lastTab.bgColor = "#FFFFFF"
	    }
		//newTab.bgColor = "#FF0000";
		//newTab.bgColor = "#D4ECFB";
		//"#F0FFFF";
		newTab.bgColor = "#F0F8FF";
		lastTab = newTab;
	}
}

function saveOrder(){
	document.frmorder.action = 'order_save.asp';
	document.frmorder.submit();
}

function clearFunc(){
	var s = "Are you sure that you want to clear this order?";
	var answer = confirm(s);
	if (answer){
		document.location.href = "order_clear.asp?answer=yes";
	}
}

function recalOrder(){
	document.frmorder.action = 'order_recalc.asp';
	document.frmorder.submit();
}

var changed;
changed = false;

function checkSubmit(){
	document.frmorder.action = 'order_finalise.asp';
	document.frmorder.submit();
}

function checkSubmit2(){
	if (changed == false) {
		document.frmorder.action = 'order_finalise.asp';
		document.frmorder.submit();
	}
	else{
		var txt;
		txt = 'You have changed a quantity on this order.';
		txt = txt + "\n" + 'Please click on the Update Qty button to make the changes effective.';
		alert(txt)
		//if (confirm(txt)) {
		//	recalOrder();
		//}
	}
}

function checkChanged(first, second){

	if (first != second){
		//document.getElementById("subButton").disabled = "disabled";
		changed = true;
		//alert(changed);
	}

}

//required for old versions of netcape that wont let you call two functions in a href
function loadImage(first, second, third){
	openPhoto();
	openImageWindow(first, second, third);
}


/* Image popup CSS */
var hover_Xpos = 210;
var hover_Ypos = 190;

function img_hover_on(img_url)
{
	popup_div = document.getElementById('hover_popup');
	popup_div.innerHTML = '<img src="' + img_url + '">';
	popup_div.style.display = 'block';
	popup_div.style.left = hover_Xpos + document.body.scrollLeft + 'px';
	popup_div.style.top = hover_Ypos + document.body.scrollTop + 'px';
}


function img_hover_off()
{
	popup_div = document.getElementById('hover_popup');
	popup_div.innerHTML = '&nbsp';
	popup_div.style.display = 'none';
}
