

function cookiePopup(path, width, height, cookieName, numDays, maxShows) {
	var ct = getCookie(cookieName);
	if (typeof ct == "undefined") 
	    ct = 0;
	if (!numDays) 
	    numDays = 7;
	if (!maxShows) 
	    maxShows = 1;
	if (ct++ < maxShows) {
	    var today = new Date();
	    var exp = new Date(today.getFullYear(), today.getMonth(), today.getDate() + numDays);
	    setCookie(cookieName, ct, exp, "/");
	    var newWin = window.open(path, cookieName, 'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=auto,width='+width+',height='+height);        
	    if (newWin)
		    newWin.focus();
	}
}

function popup(path, width, height, feat, notcenter) {
	if (!width)
	    width = 300;
	if (!height)
	    height = 300;
	    
 	if (navigator.appName.indexOf('Microsoft') >= 0 && navigator.appVersion.indexOf('Mac') >= 0) {
	 width -= 10; height -= 0;
	}
 	if (navigator.appName.indexOf('Navigator') >= 0 && navigator.appVersion.indexOf('Mac') >= 0 && navigator.appVersion.indexOf('4.') >= 0) {
	  width -= 2;
	}	
	
	if (feat == "full")
		feat = "toolbar=1,location=1,status=1,menubar=1,resizable=1,scrollbars=1";
	else 
		feat = "width="+width+",height="+height+(feat ? ","+feat : "");
	if (!notcenter) 
		feat = "left="+(screen.width/2-width/2)+",top="+(screen.height/2-height/2) + ","+feat;
  	var win = window.open(path, width+"x"+height, feat);
	win.focus();
	return win;
}

function imgpop(path, width, height) {
	win = popup('', width, height, 'scrollbars=0, menubar=0, resizable=0, location=0, toolbar=0');
	win.document.writeln('<body style="bgcolor: white; margin: 0px; padding: 0px; text-align: center;">');
	win.document.writeln('<a href="javascript:window.close();"><img src="'+path+'" border=0></a>');
}

function preloadImages() { 
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function swapImgRestore() { 
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function swapImage() { 
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function setCookie(name, value, expire, path) {
    document.cookie = name + "=" + escape(value)
    + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
    + ((path == null) ? "" : ("; path=" + path));
}

function getCookie(name) {
    if (!name) {
        return document.cookie;
    }
    var c = document.cookie;
    var ix = c.indexOf(name+"=");
    if (ix == -1) return null;
    ix = c.indexOf("=", ix) +1;
    var end = c.indexOf(";", ix);
    if (end == -1) end = c.length;
    return (unescape(c.substring(ix, end)));
}	