/*
function showPic(pic,width,height) { 
	sDesrc = "width=" + width + ", height=" + height +	", status=no, toolbar=no, menubar=no, scrollbars=no";
	win=window.open("", "Image", sDesrc);
	win.document.write("<html><style>body{padding:0px;margin:0px;}</style><body>");
	win.document.write("<img src='"+pic+"' width='"+width+"' height='"+height+"'><br>");
	win.document.write("</body></html>");
	win.focus();
	win.document.close();
}
*/


function check_checkbox(elID) {
	document.getElementById(elID).checked = (document.getElementById(elID).checked == true)?false:true;
}

/*
function showHide_(winID, param) {
	// document.getElementById(div_id).style.display = (document.getElementById(div_id).style.display == 'none')?'block':'none';
	var timeOut	= 0; //msec
	
	if (param == 'block' || param == 'show') {
		document.getElementById(winID).style.display = 'block';
	}
	else if (param == 'none' || param == 'hide') {
			setTimeout(	function () { document.getElementById(winID).style.display = 'none'; },timeOut);
	}
	else if (param == 'auto' || param == '' || !param) {
		if (document.getElementById(winID).style.display == 'none') {
			document.getElementById(winID).style.display = 'block';
		}
		else {
			setTimeout(	function () { document.getElementById(winID).style.display = 'none'; },timeOut);
		}
	}
}
*/

// ### COOKIE
function writeCookie(cookieName, cookieContent, cookieExpireTime){
	var cookiePath = '/';
	if(cookieExpireTime>0){
		var expDate=new Date()
		expDate.setTime(expDate.getTime()+cookieExpireTime*1000*60*60*24)
		var expires=expDate.toGMTString()
		document.cookie=cookieName+"="+escape(cookieContent)+";path="+escape(cookiePath)+";expires="+expires+";";
	}
    else
		document.cookie=cookieName+"="+escape(cookieContent)+";path="+escape(cookiePath)+";";
}

function readCookie(cookieName){
	var ourCookie=document.cookie;
	if(!ourCookie || ourCookie=="")return ""
	ourCookie=ourCookie.split(";")
	var i=0;
	var Cookie;
	while(i<ourCookie.length){
		Cookie=ourCookie[i].split("=")[0];
		if(Cookie.charAt(0)==" ")
		Cookie=Cookie.substring(1);
		if(Cookie==cookieName){
			return unescape(ourCookie[i].split("=")[1])
		}
		i++;
	}
	return "";
}

// updated 2009.08.30
function deleteCookie(cookieName){
	cookiestring=cookieName+"="+escape('')+";EXPIRES="+this.GetExpiryDate(-1);
	document.cookie=cookiestring;
	/*var cookiePath = '/';
	document.cookie=cookieName+"="+readCookie(cookieName)+";path="+escape(cookiePath)+";expires=Thu, 01-Jan-1970 00:00:01 GMT;";*/
}

// added 2009.08.30
GetExpiryDate = function (nodays) {
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);
	UTCstring = Today.toUTCString();
	return UTCstring;
}

function showHide_elm(elmID,write) {
	write = write||false;
	if (write) {
		if (eval('dd.elements.'+elmID+'.visible'))
			eval('dd.elements.'+elmID+'.hide()')
		else
			eval('dd.elements.'+elmID+'.show()')
		elm_status_write(elmID);
	}
	else {
		elm_status(elmID);
		//elm_status_write(elmID);
	}
	//showHide(elmID);
}

/* FIX divs*/
function elm_status_write(elmID) {
	var live_time = 3600*24*365; //31104000
	writeCookie('sf_x',eval('dd.elements.'+elmID+'.x'),live_time);
	writeCookie('sf_y',eval('dd.elements.'+elmID+'.y'),live_time);
	writeCookie('sf_v',eval('dd.elements.'+elmID+'.visible'),live_time);
}

// onStartDrag
function elm_status(elmID) {
	sf_x = readCookie('sf_x');
	sf_y = readCookie('sf_y');
	sf_v = readCookie('sf_v');
	//alert(sf_v);
	if (sf_x && sf_y) {
		eval('dd.elements.'+elmID+'.moveTo(sf_x,sf_y)');
		eval('dd.elements.'+elmID+'.moveTo(sf_x,sf_y)');
		if (sf_v == 'true') {
			//alert('truuuuu');
			eval('dd.elements.'+elmID+'.show()');
		}
		else if (sf_v == 'false') {
			//alert('falseeee');
			eval('dd.elements.'+elmID+'.hide()');
		}
	}
}

function previewPic(table_id,pic){
	document.getElementById(table_id).innerHTML = '<img src="'+pic+'">';
}

function openMMR_(mmrUrl) {
	var mmrWindow = window.open(mmrUrl, 'InternetMMR', 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=yes,width=600,height=550,left=0,top=0,screenX=0,screenY=0');
	mmrWindow.focus();
}

