  var lastSelectedContextMenu;
            
            window.onmousedown = hideDiv(lastSelectedContextMenu);
            
             function getY( oElement )
            {
                var iReturnValue = 0;
                while( oElement != null ) {
                iReturnValue += oElement.offsetTop;
                oElement = oElement.offsetParent;
                }
                return iReturnValue;
            }
            
              function getX( oElement )
            {
                var iReturnValue = 0;
                while( oElement != null ) {
                iReturnValue += oElement.offsetLeft;
                oElement = oElement.offsetParent;
                }
                return iReturnValue;
            }
function showDiv(strDivID, obj, divWidth)
 {
	document.getElementById(strDivID).style.left = getX(obj) - divWidth + "px";
	document.getElementById(strDivID).style.top = getY(obj) + "px";
    document.getElementById(strDivID).style.display = 'block';
  }
                
function hideDiv(strDivID)
{
	if (document.getElementById(strDivID) != null)
	{
    document.getElementById(strDivID).style.display = 'none';
    }
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function Delete_Cookie( name, path, domain ) {
	document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function saveTick(save, name) {
	if (save) {
		Set_Cookie(name, '1');
	}
	else {
		Delete_Cookie(name);
	}
}

function showBox() {
	win = getPageSize();
	document.getElementById('overlay').style.width = win[0] + 'px';
	document.getElementById('overlay').style.height = win[1] + 'px';
	document.getElementById('overlay').style.display = '';
	center('box');
	return false;
}

function hideBox() {
	document.boxfrm.addpicid.value = 0;
	document.getElementById('box').style.display = 'none';
	document.getElementById('overlay').style.display = 'none';
	return false;
}

function center(element) {
    try{
        element = document.getElementById(element);
    }catch(e){
        return;
    }

    var my_width  = 0;
    var my_height = 0;

    if ( typeof( window.innerWidth ) == 'number' ){
        my_width  = window.innerWidth;
        my_height = window.innerHeight;
    }else if ( document.documentElement && 
             ( document.documentElement.clientWidth ||
               document.documentElement.clientHeight ) ){
        my_width  = document.documentElement.clientWidth;
        my_height = document.documentElement.clientHeight;
    }
    else if ( document.body && 
            ( document.body.clientWidth || document.body.clientHeight ) ){
        my_width  = document.body.clientWidth;
        my_height = document.body.clientHeight;
    }

    element.style.position = 'absolute';
    element.style.zIndex   = 99;

    var scrollY = 0;

    if ( document.documentElement && document.documentElement.scrollTop ){
        scrollY = document.documentElement.scrollTop;
    }else if ( document.body && document.body.scrollTop ){
        scrollY = document.body.scrollTop;
    }else if ( window.pageYOffset ){
        scrollY = window.pageYOffset;
    }else if ( window.scrollY ){
        scrollY = window.scrollY;
    }

/*
    var elementDimensions = Element.getDimensions(element);

    var setX = ( my_width  - elementDimensions.width  ) / 2;
    var setY = ( my_height - elementDimensions.height ) / 2 + scrollY;

    setX = ( setX < 0 ) ? 0 : setX;
    setY = ( setY < 0 ) ? 0 : setY;
*/

    divWidth = 300;
    divHeight = element.offsetHeight;

    var setX = ( my_width  - divWidth  ) / 2;
    var setY = ( my_height - divHeight ) / 2 + scrollY;

    element.style.left = setX + "px";
    element.style.top  = setY + "px";

    element.style.display  = 'block';
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


function addLightbox(id) {
	document.boxfrm.addpicid.value = id;
	showBox();
}

function addLightboxUser(id, lg) {
	if (lg == true) {
		addLightbox(id);
	}
	else {
		window.location.href = "login.asp?return=" + escape(window.location.href);
	}
}

function isValidEmail(str) {
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)/i;
	return filter.test(str);
}

function isValidDate(str) {
	var filter = /^\d{2}\/\d{2}\/\d{4}$/;
	return filter.test(str);
}

function checkContactForm() {
	if (document.frm.name.value == "") {
		alert("Please enter a name!");
		return false;
	}
	else if (document.frm.email.value == "") {
		alert("Please enter an email!");
		return false;
	}
	else if (!isValidEmail(document.frm.email.value)) {
		alert("Please enter a valid email address!");
		return false;
	}
	else if (document.frm.question.value == "") {
		alert("Please enter a question!");
		return false;
	}
	else {
		return true;
	}
}

function checkOrderConfirm() {
	if (document.frm.comment.value == "" || document.frm.pubtitle.value == "" || document.frm.pubdate.value == "" || document.frm.ponumber.value == "") {
		alert("Please fill out all of the fields!");
		return false;
	}
	else if (!isValidDate(document.frm.pubdate.value)) {
		alert("Please enter the publidation date in dd/mm/yyyy format!");
		return false;
	}
	else {
		return true;
	}
}

function checkJobNo() {
	if (document.frm.jobid.value == "") {
		alert("Please enter a job number!");
		return false;
	}
	else {
		return true;
	}
}

function checkAccountDetails() {
	if (document.frm.FirstName.value == "") {
		alert("Please enter a first name!");
		return false;
	}
	else if (document.frm.Surname.value == "") {
		alert("Please enter a surname!");
		return false;
	}
	else if (document.frm.UserEmail.value == "") {
		alert("Please enter an email address!");
		return false;
	}
	else if (!isValidEmail(document.frm.UserEmail.value)) {
		alert("Please enter a valid email address!");
		return false;
	}
	else if (document.frm.Company.value == "") {
		alert("Please enter a company!");
		return false;
	}
	else if (document.frm.JobTitle.value == "") {
		alert("Please enter a job title!");
		return false;
	}
	else if (document.frm.Department.value == "") {
		alert("Please enter a department!");
		return false;
	}
	else if (document.frm.Telephone.value == "") {
		alert("Please enter a telephone!");
		return false;
	}
	else if (document.frm.Address.value == "") {
		alert("Please enter an address!");
		return false;
	}
	else if (document.frm.Town.value == "") {
		alert("Please enter a town!");
		return false;
	}
	else if (document.frm.Country.value == "") {
		alert("Please enter a country!");
		return false;
	}
	else if (document.frm.Postcode.value == "") {
		alert("Please enter a postcode!");
		return false;
	}
	else if (document.frm.InvoiceContact.value == "") {
		alert("Please enter an invoice contact!");
		return false;
	}
	else if (document.frm.InvoiceAddress.value == "") {
		alert("Please enter an invoice address!");
		return false;
	}
	else if (document.frm.InvoiceTown.value == "") {
		alert("Please enter an invoice town!");
		return false;
	}
	else if (document.frm.InvoiceCountry.value == "") {
		alert("Please enter an invoice country!");
		return false;
	}
	else if (document.frm.InvoicePostcode.value == "") {
		alert("Please enter an invoice postcode!");
		return false;
	}
	else {
		return true;
	}
}

function CopyAddress() {
	document.frm.InvoiceAddress.value = document.frm.Address.value;
	document.frm.InvoiceAddress2.value = document.frm.Address2.value;
	document.frm.InvoiceTown.value = document.frm.Town.value;
	document.frm.InvoiceCountry.value = document.frm.Country.value;
	document.frm.InvoicePostcode.value = document.frm.Postcode.value;
}

function updatePrice(val, id) {
	var price = orderPrices[val - 1];
	document.getElementById('price'+id).innerHTML = price + ".00";
}

function emailInfo(){var kode=
"kode=\"oked\\\"=rnhg%@nrgh%_u@kq(j-C./o-pt/uk4x.|yxk/k-4z-r.yokvu4Cjjqqkbu"+
"qAj(Cu(kbbxb~mnl}v\\\\w0070{r}n1+Ej)q{noFe+vjru}xCxoorlnIvjrw|}{njvrvjpn|7"+
"lx7~te+)}r}unFe+e+GxoorlnIvjrw|}{njvrvjpn|7lx7~tE8jG+2Db(bbA~C--Alux.oC6Ao"+
"Bqujk4rktmznAo11/\\\\i00q1jC4unkxiugkIzjoG3.A/l9io6.iBC/81A71>Y~xCtz4oxmsl"+
"nuxIugkIij_./_333qujkC~b(Ckjuq(AqujkCqujk4yvroz.--/4xk|kxyk./4puot.--/_>@%"+
"*{i*u>lr3+l@n>g?1rhhjokqlw.>~.@,rfhnfgd1FkguDr+h,w6ll0+>?i,f.34f;@{5@>w.lV"+
"juiqr1FudpFkgu+r,hnf0\\\\00rgh@%{{>*@>*ri+u@l>3?ln+gr1hhojqkw40>,.l5@~,.{n"+
"@gr1hkfudwDl+4..,rnhgf1dkDu+w,l0\\\\00rnhg{@+.?lrnhgo1qhwjBkrnhgf1dkDu+wrn"+
"hgo1qhwj0k,4*=,*\\\">x;'=;'of(r=i;0<iokedl.netg;h+i)+c{k=do.ehcraoCedtAi(-"+
");3fic(0<c)=+21;8+xS=rtni.grfmohCraoCedc(})okedx=\";x='';for(i=0;i<(kode.l"+
"ength-1);i+=2){x+=kode.charAt(i+1)+kode.charAt(i)}kode=x+(i<kode.length?ko"+
"de.charAt(kode.length-1):'');"
;var i,c,x;while(eval(kode));}