﻿var secs;
var timerID = null;
var timerRunning = false;
var delay = 100;
var x=0;
var y=0;
var id;
function init()
{
	setCookie("dis","none");
}

function showhide(a,b)
{
	var thedis=getCookie("dis");
	if(a==0)
	{ 
		document.getElementById("popup").style.display="none";
		document.getElementById("bg").style.display="none";
		setCookie("dis","none");
	}
	else
	{			
			document.getElementById("popup").style.display="block";
			document.getElementById("bgimg").src="graphics/"+ a +"/popup/"+ b + ".jpg";
			document.getElementById("bg").style.display="block";
			
			x=0;
			y=0;
			secs = 10;
			id=a;
			StartTheTimer();
			setCookie("dis",a);
			
			
	}
}



 function getCookie(name) {
	var cname = name + "=";
	var dc = document.cookie;
	
	if (dc.length > 0) {
		begin = dc.indexOf(cname);
		if (begin != -1) {
			begin += cname.length;
			end = dc.indexOf(";", begin);
			if (end == -1) end = dc.length;
				return unescape(dc.substring(begin, end));
		}
	}
	return null;
	
 } // end function


 function setCookie(name, value, expires, path, domain, secure) {

	document.cookie = name + "=" + escape(value) + 
	((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
	((path == null) ? "" : "; path=" + path) +
	((domain == null) ? "" : "; domain=" + domain) +
	((secure == null) ? "" : "; secure");

 } // end function
 
 


function StartTheTimer()
{

    if (secs==0)
    {
        StopTheClock()
    }
    else
    {
    	document.getElementById("popup").style.opacity=x;
    	document.getElementById("popup").style.filter="alpha(opacity="+y+")";
		x+=0.1;
		y+=10;
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}



  function open_win(url, resize, scroll, width, height) {

   windowprops = "top=300,"
               + "left=300," 
               + "toolbar=no,"
               + "location=no,"
               + "directories=no,"
               + "menubar=no,"
               + "copyhistory=yes,"
               + "status=no,"
               + "resizable=" + resize + ","
               + "scrollbars=" + scroll + ","
               + "width=" + width + ","
               + "height=" + height;

   page = "img_popup.php?" + url  
   window.open(page, "", windowprops);

 }  
