var hideTime;
var unpanel_moreHideTime;
var unpanel_settingsHideTime;
function getPageSize(){

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
function unpanel_DeleteCookie (name) {
   var expt = new Date();
   expt.setTime (expt.getTime() - 1000000000);  // This cookie is history (changed -1 to make it previous time)
   var cval = unpanel_GetCookie (name);
   document.cookie = name + "=" + cval + "; expires=" + expt.toGMTString() + ";";
}

function unpanel_GetCookie(c_name) {
    if (document.cookie.length>0) {
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1) { 
            c_start=c_start + c_name.length+1; 
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        } 
    }
    return "";
}

var unpanel_clickonmore=false;
var unpanel_clickonsettings=false;
function selectSettings(wasclicked) {
	window.clearTimeout(unpanel_settingsHideTime);
    if (wasclicked) unpanel_clickonsettings=true;
	if (unpanel_clickonsettings) {
	document.getElementById('unpanel_logged-settings').style.display = 'block';
    }
}
function closeSettings() {
	unpanel_settingsHideTime=window.setTimeout(function(){document.getElementById('unpanel_logged-settings').style.display = 'none';unpanel_clickonsettings=false;},50);
}
function panel_windowModal(modalId) {
	globalmodal=document.getElementById('panel_modal-block');
	if (modalId == 'login_box')
		globalmodal.className = globalmodal.className.replace('modal-special', 'modal-wlogin');
	cfolder=0;
	cmodal=modalId;
	modaldiv=document.getElementById('panel_modal-'+modalId);
	modaltitlediv=document.getElementById('panel_modal_t-'+modalId);
	modalbg=document.getElementById('panel_modal_bg');
	var pageSizes=getPageSize();
	modalbg.style.height=pageSizes[1]+'px';
	globalmodal.className=globalmodal.className.replace('off','on');
	modaldiv.className=modaldiv.className.replace('off','on');
	modaltitlediv.className=modaltitlediv.className.replace('off','on');
	modalbg.style.display = 'block';
    document.getElementById('panel_modal-Login').focus();
}
function panel_CloseModal(modalId) {
	globalmodal=document.getElementById('panel_modal-block');
	if (modalId == 'login_box')
		globalmodal.className = globalmodal.className.replace('modal-wlogin', 'modal-special');
	modaldiv=document.getElementById('panel_modal-'+modalId);
	modaltitlediv=document.getElementById('panel_modal_t-'+modalId);
	modalbg=document.getElementById('panel_modal_bg');
	globalmodal.className=globalmodal.className.replace('on','off');
	modaldiv.className=modaldiv.className.replace('on','off');
	modaltitlediv.className=modaltitlediv.className.replace('on','off');
	modalbg.style.display = 'none';
	if (document.getElementById('panel_' + modalId+'-form'))
		document.getElementById('panel_' + modalId+'-form').reset();
	cfolder=0;
    unpanel_DeleteCookie('zakl_open_modal');
}
function panel_displayLang(status, id) {
    id = id || '';
    if(status) {
       document.getElementById('unpanel_lang'+id).className = 'panel-lang panel-lang_open';
       return
    }
    document.getElementById('unpanel_lang'+id).className = 'panel-lang'; 
}

function panel_mouseLeaves (element, evt) {
    if (typeof evt.toElement != 'undefined' && typeof element.contains !=
    'undefined') {
    return !element.contains(evt.toElement);
    }
    else if (typeof evt.relatedTarget != 'undefined' && evt.relatedTarget) {
    return !panel_contains(element, evt.relatedTarget);
    }
}

function panel_contains (container, containee) {
    while (containee) {
    if (container == containee) {
    return true;
    }
    containee = containee.parentNode;
    }
    return false;
}