// END Menu builder
var w=screen.width;   
document.cookie = "resolution" + "=" + w;
document.write("<table height=\"1\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><img src=\"counter.php\" height=\"1\" width=\"1\"></td></tr></table>");

// Right click protection
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
var EnableRightClick = 1;
if(isNS) 
document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
function mischandler(){
  if(EnableRightClick==1){ return true; }
  else {return false; }
}
function mousehandler(e){
  if(EnableRightClick==1){ return true; }
  var myevent = (isNS) ? e : event;
  var eventbutton = (isNS) ? myevent.which : myevent.button;
  if((eventbutton==2)||(eventbutton==3)) return false;
}
function keyhandler(e) {
  var myevent = (isNS) ? e : window.event;
  if (myevent.keyCode==96)
    EnableRightClick = 1;
  return;
}
document.oncontextmenu = mischandler;
document.onkeypress = keyhandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
//-->

// Start of Floating DIV
isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;
isHotpop=false;

function ddInit(e){
  	topDog=isIE ? "BODY" : "HTML";
  	whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
  	hotDog=isIE ? event.srcElement : e.target; 
	/*
  	while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
  	  hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  	} 
	*/
  	if (hotDog.id=="titleBar"){
  	  offsetx=isIE ? event.clientX : e.clientX;
    	offsety=isIE ? event.clientY : e.clientY;
    	nowX=parseInt(whichDog.style.left);
    	nowY=parseInt(whichDog.style.top);
    	ddEnabled=true;
    	document.onmousemove=dd;
  	}
}

function dd(e){
  	if (!ddEnabled) {
  	  whichDog.style.clear="";
	  whichDog.style.filter="";
	  whichDog.style.opacity=0.0;
	  return;
  	}
  	whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  	whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  	whichDog.style.clear="both";
  	whichDog.style.filter="alpha(opacity=60)";
  	whichDog.style.opacity=1.0;
  	return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideDiv(){
  if (isIE||isNN) {
	  whichDog.style.visibility="hidden";
  } else if (isN4) {
	  document.theLayer.visibility="hide";
  }
}

function showDiv(width){
	var width;
	var floatY;
	var floatX;

	if (isIE||isNN) {
		floatX=Math.round((document.body.offsetWidth-20)/2)-Math.round(width/2);
		//floatY=Math.round(document.body.offsetHeight/2) - 300;
		floatY=200
		whichDog.style.visibility="visible";
		whichDog.style.top = floatY;
		whichDog.style.left = floatX;
  	} else if (isN4) { 
		//floatX=Math.round((window.innerWidth-20)/2)-Math.round(width/2)};
		floatX=100;
		document.theLayer.visibility="show";
		document.theLayer.posleft = floatX;
  	}
	
}
// Floating DIV Popup
function hideDivPop(){
  if (isIE||isNN) {
	  document.all.popupLayer.style.visibility="hidden";
  } else if (isN4) {
	  document.popupLayer.visibility="hide";
  }
}

function showDivPop(widthpop){
	var widthpop;
	var floatYpop;
	var floatXpop;
	
	if (isIE||isNN) {
		floatXpop=Math.round((document.body.offsetWidth-20)/2)-Math.round(widthpop/2);
		//floatYpop=Math.round(document.body.offsetHeight/2) - 300;
		floatYpop=100
		document.all.popupLayer.style.visibility="visible";
		document.all.popupLayer.style.top = floatYpop;
		document.all.popupLayer.style.left = floatXpop;
  	} else if (isN4) { 
		//floatX=Math.round((window.innerWidth-20)/2)-Math.round(width/2)};
		floatXpop=100;
		document.popupLayer.visibility="show";
		document.popupLayer.posleft = floatXpop;
  	}
	
}
// End floating div popup
document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");
// End of Floating DIV

// Validate number
// Declaring required variables
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function ValidateFieldHigher(){
	var Ammount=document.form_order.post_ammount

	if ((Ammount.value==null)||(Ammount.value=="")){
		Ammount.value = 1		
		Ammount.focus()
	} else if (isInteger(Ammount.value)) {
		Ammount.value = parseInt(Ammount.value) + 1
	} else {
		Ammount.value = 1		
		Ammount.focus()
	}
}

function ValidateFieldLower(){
	var Ammount=document.form_order.post_ammount

	if ((Ammount.value==null)||(Ammount.value=="")||(Ammount.value==0)){
		Ammount.value = 1		
		Ammount.focus()
	} else if ((isInteger(Ammount.value)) && (parseInt(Ammount.value) > 1)) {
		Ammount.value = parseInt(Ammount.value) - 1
	} else {
		Ammount.value = 1		
		Ammount.focus()
	}
}
// End validate numbers

// Submit forms on enter
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;
}

// Hide/show items
function showhide(id){
	var style = document.getElementById(id).style 
	
	if (style.display == "none"){ 
		style.display = "block";
	} else {
		style.display = "none";
	}
}

function cms_view(id){
	var id
	var winattributes='width=700,height=500,resizable=no,scrollbars=yes,toolbar=no,directories=no,location=no,menubar=no,copyhistory=no'
	window.open("information.php?id=" + id,"",winattributes)
}

function order_view(order_id){
	var order_id
	var winattributes='width=850,height=600,resizable=no,scrollbars=yes,toolbar=no,directories=no,location=no,menubar=no,copyhistory=no'
	window.open("order.php?act=view&id=" + order_id,"",winattributes)
}

// Function for image popups
function popupimage(imgpath, popwidth, popheight, textdescription){
	
	var popbackground="black" //specify backcolor or background image for pop window
	var windowtitle=textdescription  //pop window title
	var popwidth=popwidth+25
	var popheight=popheight+30

	function detectexist(obj){
		return (typeof obj !="undefined")
	}

	function getpos(){
		leftpos=(detectexist(window.screenLeft))? screenLeft+document.body.clientWidth/2-popwidth/2 : detectexist(window.screenX)? screenX+innerWidth/2-popwidth/2 : 0
		toppos=(detectexist(window.screenTop))? screenTop+document.body.clientHeight/2-popheight/2 : detectexist(window.screenY)? screenY+innerHeight/2-popheight/2 : 0
		if (window.opera){
			leftpos-=screenLeft
			toppos-=screenTop
		}
	}

	getpos();
	var winattributes='width='+popwidth+',height='+popheight+',resizable=no,left='+leftpos+',top='+toppos
	var bodyattribute=(popbackground.indexOf(".")!=-1)? 'background="'+popbackground+'"' : 'bgcolor="'+popbackground+'"'
	if (typeof popwin=="undefined" || popwin.closed)
		popwin=window.open("","",winattributes)
	else{
		//getpos() //uncomment these 2 lines if you wish subsequent popups to be centered too
		//popwin.moveTo(leftpos, toppos)
		popwin.resizeTo(popwidth, popheight)
	}
	popwin.document.open()
	popwin.document.write('<html><title>'+windowtitle+'</title><body '+bodyattribute+'><img src="'+imgpath+'" style="margin-bottom: 0.0em" onclick="window.close()"></body></html>')
	popwin.document.close()
	popwin.focus()
}
// End image popup

function set_option_cookie(id, value) {
	document.cookie = "option["+id+"]" + "=" + value;
}

function set_text_cookie(id, value) {
	if(value != "") {
		document.cookie = "text["+id+"]" + "=" + value;
	}
}

function changestyle(id) {
	var div = 'div_'+id;
	if(document.getElementById(div).style.display == "none") {
		document.getElementById(div).style.display = "";
	} else {
		document.getElementById(div).style.display = "none"
	}
}