function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	var arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScroll, yScroll,pageHeight,pageWidth;
	
	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;
	}	
	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	var arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}

function showShadowBox(case_no) {
	// prep objects
	var i, content,boxh;
	var objShadow = document.getElementById('shadow');
	var objBox = document.getElementById('box');
	var objBoxCaption = document.getElementById('boxcaption');
	var objBoxContent = document.getElementById('boxcontent');
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	
	objShadow.style.height = (arrayPageSize[1] + 'px');
	objShadow.style.display = 'block';

	
	var selects = document.getElementsByTagName("select");
        for (i = 0; i != selects.length; i++) {
                selects[i].style.visibility = "hidden";
        }
	boxh = 120
	objBox.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - boxh) / 2) + 'px');
	objBox.style.left = (((arrayPageSize[0] - 20 - 300) / 2) + 'px');
	objBox.style.display = 'block';
	objBox.style.width = '290px';
	
	objBoxCaption.style.width = '290px';
	objBoxCaption.style.height = '23px';
	
	objBoxContent.style.width = '290px';
	
	if (case_no == '0'){
	   boxh=120
	   objBox.style.height = boxh + 'px';	
	   objBoxCaption.style.backgroundImage= 'url(../Resim/ajax/header-loading.png)';
	   objBoxContent.style.height = '97px';
       objBoxContent.style.textAlign='center';
	   objBoxContent.innerHTML = '<span class="loading">Yükleniyor...</span>';
	   objBoxContent.style.padding='20px 0 0 0px';

	}else if(case_no == '1'){
	   boxh=136;
	   objBox.style.height = boxh + 'px';
	   objBoxCaption.style.backgroundImage= 'url(../Resim/ajax/header-nuser.png)';
	   objBoxContent.style.height = '113px';
	   objBoxContent.style.padding='20px 0 0 5px';
	   content  = '<form id="frm_user"><span class="txt_uname"><label for="txt_uname">Kullanıcı Adı:</label></span><input type="text" name="txt_uname" id="txt_uname" /><span class="txt_upass"><label for="txt_upass">Sifre:</label></span><input type="text" name="txt_upass" id="txt_upass" /></f0rm>';
	   content += '<div id="okcancel"><div id="ok"><img src="../Resim/ajax/CheckMark.png" /></div><div ="cancel"><img src="../Resim/ajax/Cancel.png" /></div></div>'
	   objBoxContent.innerHTML  = content;
	}
	
}

function hideShadowBox(){
	
	// get objects
	var i,select;
	var objShadow = document.getElementById('shadow');
	var objBox = document.getElementById('box');
	var objBoxCaption = document.getElementById('boxcaption');
	// hide lightbox and overlay
	objShadow.style.display = 'none';
	objBox.style.display = 'none';
	objBoxCaption.display = 'none';
	// make select boxes visible
	var selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

function initShadowBox(){
var objBody = document.getElementsByTagName("body").item(0);
	
	// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
	var objShadow = document.createElement("div");
	objShadow.setAttribute('id','shadow');
	
	objShadow.style.display = 'none';
	objShadow.style.position = 'absolute';
	objShadow.style.top = '0';
	objShadow.style.left = '0';
	objShadow.style.zIndex = '100';
 	objShadow.style.width = '100%';
	objBody.insertBefore(objShadow, objBody.firstChild);
	
	var objBox = document.createElement("div");
	objBox.setAttribute('id','box');
	objBox.style.display = 'none';
	objBox.style.position = 'absolute';
	objBox.style.zIndex = '101';	
	objBody.insertBefore(objBox, objShadow.nextSibling);
	
	var objBoxCaption = document.createElement("div");
	objBoxCaption.setAttribute('id','boxcaption');
	objBoxCaption.display = 'none';
	objBoxCaption.position = 'absolute';
	objBoxCaption.zIndex = '102';
	objBox.appendChild(objBoxCaption);
	
	var objBoxContent = document.createElement("div");
	objBoxContent.setAttribute('id','boxcontent');
	objBoxContent.display = 'none';
	objBoxContent.position = 'absolute';
	objBoxContent.zIndex = '102';
	objBox.appendChild(objBoxContent);  

}

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}

addLoadEvent(initShadowBox);


