﻿// Global Java Script Code
// © 2008 www.edreamer.ir, All Rights Reserved.

function fridge() {
	//if the browser is IE4+
	document.onselectstart=new Function ("return false")
	document.ondragstart=new Function ("return false")
	document.oncontextmenu=new Function ("return false")

	//if the browser is NS6
	if (window.sidebar || document.layer){
		document.onmousedown=disabletext
		document.onclick=reEnable
	}

}

function disabletext() {
	return false;
}
				
function reEnable(){
	return true;
}


// preloading and shadow parts

function preloading(div, flag)
{
    if (flag == 1)
    {
        document.getElementById(div).style.display = 'block';
        
		// stretch overlay to fill page
		var arrayPageSize = getPageSize();
		document.getElementById(div).style.height = arrayPageSize[1] + "px";
        //document.getElementById(div).style.top = document.body.scrollTop;
        
        window.onscroll = function()
	    {
	        //parent.document.getElementById(div).style.top = document.body.scrollTop;
	        arrayPageSize = getPageSize();
	        document.getElementById(div).style.height = arrayPageSize[1] + "px";
	    }
    }
    else if (flag == 0)
    {
        document.getElementById(div).style.display = 'none';
        window.onscroll = "";
    }
    //alert ("pause");
}

// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
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 shadowconfirm(message)
{
    document.getElementById('shadowDiv').style.visibility='visible';
        //document.getElementById('body').style.filter='gray';
        //document.body.style.filter='gray';
	var returnvar = confirm(message);
	document.getElementById('shadowDiv').style.visibility='hidden';
        //document.getElementById('body').style.filter='color';
        //document.body.style.filter='color';
	return returnvar;
}

function close(what)
{
    (document.getElementById(what)).style.display = 'none';
}