ns = (document.layers)? true:false 
ie = (document.all)? true:false 

function openw(html, scroll, width, height) {
    obj=open("","width" + width + "height" + height + "","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + scroll + ",resizable=no,copyhistory=no,width=" + width + ",height=" + height + ",left=0,top=0");
    obj.location = html;
    obj.focus();
}

if (ns) document.captureEvents(Event.MOUSEMOVE | Event.MOUSEDOWN) 

document.onmouseover = winStatus; 
document.onmousedown = mouseDown; 
document.oncontextmenu = mouseDown; 

function winStatus(ev){
	window.status='© 2010 Datalogica inspired eCommerce'; 
	return true;
}

function mouseDown(ev){
    if (ie) { 
        if (event.button != 1) { 
            return false; 
        }
    }
    if (ns) { 
        if (ev.which == 3) { 
            return false; 
        }
    }
}


function toUp(field) {
    var result = "";
    var str = field.value.split('');
    for(i = 0; i < str.length; i++) {
        if(i == 0) {
            result += str[i].toUpperCase();
        } else {
            result += str[i];
        }
    }
    field.value = result;
}
function popitup5(purl, title, iwidth, iheight, colour) {
	var newwindow = null;
	var wheight = 0, wwidth = 0;
	var pwidth, pheight;

	if ( !newwindow || newwindow.closed ) {
		pwidth=iwidth+30;
		pheight=iheight+30;
		newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=0,top=50,left=10');
		wheight=iheight;
		wwidth=iwidth;
	}

	if (wheight!=iheight || wwidth!=iwidth ) {
		pwidth=iwidth+30;
		pheight=iheight+90;
		newwindow.resizeTo(pwidth, pheight);
		wheight=iheight;
		wwidth=iwidth;
	}

	if (newwindow != null) {
		newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>');
		newwindow.document.writeln('<a href=\"javascript:window.close();\">');
		newwindow.document.writeln('<img src=' + purl + ' title=\"' + title + '\" alt=\"' + title + '\" border=\"0\">');
		newwindow.document.writeln('</a>');
		newwindow.document.writeln('<\/center> <\/body> <\/html>');
		newwindow.document.close();
		newwindow.focus();
	}
}
/* Call function as setCookie("cookiename" , cookievalue, lifetime, cookiepath)
with the lifetime required in days, -1 to delete a cookie or zero
for a temporary cookie. The Cookie Path is optional.*/

function setCookie(cookie_name, cookie_value, cookie_life, cookie_path) {
  var today = new Date()
  var expiry = new Date(today.getTime() + cookie_life * 24*60*60*1000)
  if (cookie_value != null && cookie_value != ""){
    var cookie_string =cookie_name + "=" + escape(cookie_value)
    if(cookie_life){ cookie_string += "; expires=" + expiry.toGMTString()}
    if(cookie_path){ cookie_string += "; path=" + cookie_path}
 	document.cookie = cookie_string
  }
} 

/* Call function as getCookie("cookiename") It returns the value of a cookie
if set or null. Beware of potential ambiguities in names of cookies -
getCookie is simple and will match the end of a string so xyname 
will also be matched by yname and ame. */
 
function getCookie(name) {
  var index = document.cookie.indexOf(name + "=")
  if (index == -1) { return null}
  index = document.cookie.indexOf("=", index) + 1
  var end_string = document.cookie.indexOf(";", index)
  if (end_string == -1) { end_string = document.cookie.length }
  return unescape(document.cookie.substring(index, end_string))
}

function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left=100,top=100" '+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
function openwin(url,width,height) {
	win = window.open(url,"popup_w" + width + "h_" + height,"left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width="+width+",height="+height);
	if (!win.opener) win.opener = self;
}

function openwinscroll(url,width,height) {
	win = window.open(url,"popup_scroll_w" + width + "h_" + height,"left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width="+width+",height="+height);
	if (!win.opener) win.opener = self;
}
function MM_swapImgRestore() {
  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_preloadImages() { 
  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_findObj(n, d) { 
  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() {
  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];}
}
