/**
* @author Levon Naghashyan
* @site http://naghashyan.com
* @mail levon@naghashyan.com
* @year 2009-2010
*/


function createDisclaimer(){
	var objBody = document.body;
	var overlayElem = document.createElement('div');
	overlayElem.id = 'overlay';
	objBody.appendChild(overlayElem);
	var framElem = document.createElement('iframe');
	framElem.src = site_path+"/dyn/main/disclaimer/disclaimer.html";
	framElem.scrolling = "no";
	framElem.setAttribute("frameborder", "0");
	framElem.setAttribute("id", "disclaimer");
	framElem.style.width = 410+"px";
	framElem.style.height = 350+"px";
	overlayElem.appendChild(framElem);
	var overlayElem = document.createElement('div');
	overlayElem.id = 'f_overlay';
	overlayElem.style.height = 100+"%";
	objBody.appendChild(overlayElem);
	setWindow();
	document.body.style.visibility = "visible";
	
	setDisclamer();
}

function setDisclamer(){
	var _embed = document.getElementsByTagName("iframe");
	for(var i=0;i<_embed.length;i++){
		if(_embed[i].id != "disclaimer"){
			_embed[i].style.visibility = "hidden";
		}
		
	}
	setWindow();
	findDropdowns();
}

function setWindow(){
//set page resize event	
	window.onresize = setWindow; 
	//window.onload = setWindow;
	 // stretch overlay to fill page and fade in
    var arrayPageSize = _getPageSize();
    var overlay = document.getElementById('f_overlay');
    overlay.style.width = arrayPageSize[0] + 'px';
    overlay.style.height = arrayPageSize[1] + 'px';
    
    
}
   
function _getPageSize() {
       
     var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		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
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			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 = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}
function setCookie(){
	c_name = "disclaimer";
	value = 1;
	expiredays = 365;
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	
	var overlay = document.getElementById('f_overlay');
	overlay.style.display = "none";
	var overlay = document.getElementById('overlay');
	overlay.style.display = "none";
	var _embed = document.getElementsByTagName("iframe");
	for(var i=0;i<_embed.length;i++){
		if(_embed[i].id != "disclaimer"){
			_embed[i].style.visibility = "visible";
		}
		
	}
}
function disclaimerRedirect(url){
	window.location=url;
}
document.body.style.visibility = "hidden";
window.onload = setDisclamer;
var isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
if(!isIE6){
createDisclaimer();
}
else{
window.onload = createDisclaimer;
}

