var pCookie;

function setCookie(name, value)
{
	var MinMilli = 1000 * 60;
	var HrMilli = MinMilli * 60;
	var DyMilli = HrMilli * 24;

	var tomorrow = new Date();
	tomorrow.setTime(Math.round(tomorrow.getTime()/DyMilli + 1) * DyMilli);
	document.cookie = name + "=" + escape( value ) + "; path=/; domain=.ndolfin.com; expires=" + tomorrow.toGMTString() + ";"
}

function getCookie(name) {
	var Found = false
	var start, end
	var i = 0

	while(i <= document.cookie.length) {
		start = i
		end = start + name.length

		if(document.cookie.substring(start, end) == name) {
			Found = true
			break
		}
		i++ 
	}

	if(Found == true) {
		start = end + 1
		end = document.cookie.indexOf(";", start)
		if(end < start)
		end = document.cookie.length
		return document.cookie.substring(start, end)
	}
	return ""
}


function ck_pop()
{
	setCookie(pCookie, "no");
	window.close();
}


function popWindow(popNo, popFile, popTop, popLeft, popWidth, popHeight)
{
	if(getCookie(popNo) != "no")
	{
		popFile = popFile + '?pWidth='+ popWidth +'&pHeight='+ popHeight +'&pCookie='+ popNo
		window.open(popFile, popNo, 'top='+ popTop +',left='+ popLeft +',width='+ popWidth +',height='+ popHeight +',status=1,resizable=no,scrollbar=no');
	}
}


function openpop() {
	var popLeft	= 10;
	var popTop	= 10;
	var tmpLeft	= 10;

	for (var i=0; i<popFile.length; i++)
	{
		popWindow("pt1pop"+i, popFile[i], popTop, popLeft, popWidth[i], popHeight[i]);
		popLeft	= parseInt(popLeft) + parseInt(popWidth) + parseInt(tmpLeft);
	}
}
function openlayerpop_old() {
 
 
	for (var i=0; i<popFile.length; i++)
	{
		popLayerWindow("lpt1pop"+i, popFile[i]); 
	}
}

function openlayerpop() {
    for (var i = 0; i < popFile.length; i++) {
        if (getCookie(popFile[i]) != "done") {
            document.getElementById(popFile[i]).style.display = "block";
        }
	else
	    document.getElementById(popFile[i]).style.display = "none";
	
    }
}

function ck_Layer(no) {
    pCookie = "draggable" + no;
    setCookie(pCookie, "done");
    document.getElementById(pCookie).style.display = "none";
}

function close_Layer(no) {
    document.getElementById("draggable" + no).style.display = "none";
}

//---------


function popLayerWindow(popNo, popFile)
{   
	if(getCookie(popNo) != "no")
	{ 
	  var layername = document.getElementById(popNo);
	    
	  layername.style.display = "block";	
	}
}


function ck_Layerpop(popNo)
{
	setCookie(popNo, "no");
	
	var layername = document.getElementById(popNo);
	 
	layername.style.display = "none";
}



function reSizepop(loc)
{
	var pWidth;
	var pHeight;

	if(loc.indexOf('?') > 0) {
	var param = loc.split('?');

		if(param[1].indexOf('&')>0) {
		var req = param[1].split('&');

			if(req[0].indexOf('=')>0) {
			var query = req[0].split('=');
				pWidth = query[1];
			}

			if(req[1].indexOf('=')>0) {
			var query = req[1].split('=');
				pHeight = query[1];
			}

			if(req[2].indexOf('=')>0) {
			var query = req[2].split('=');
				pCookie = query[1];
			}
		}
	}

	if (pWidth != "" && pHeight != ""){

		window.resizeTo(pWidth, pHeight);
		with(document.body)
		{
			window.resizeTo(pWidth * 2 - clientWidth, pHeight * 2 - clientHeight);
		}
/*
		window.resizeTo(parseInt(pWidth) + 10, pHeight);

		if (window.document.body.offsetHeight < pHeight - 45)
		{
			pHeight = parseInt(pHeight) + parseInt(pHeight - window.document.body.offsetHeight - 45);
			window.resizeTo(pWidth, pHeight);
		}
*/
	}
}
