// /////////// lightbox functions dont touch them /////////// //

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;
	}	
	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getTop(pageSizeH, pageSizeW){
	var pageSizeH,pageSizeW;
	var MyElement = document.getElementById("overlay");
	var docuSizeH = MyElement.offsetHeight;
	var docuSizeW = MyElement.offsetWidth;
	var newPositT = pageSizeH-docuSizeH;
	var newPositL = pageSizeW-docuSizeW;
	newPositT = (newPositT/pageSizeH*100)/2 ;
	newPositL = (newPositL/pageSizeW*100)/2 ;
	
	MyElement.style.top  = newPositT+"%";
	MyElement.style.left = newPositL+"%";
	MyElement.className = "";
}
/*///// opening window /////*/

function NewWindow(content) {
	var content, staticCont;
	var arrayPageSize = getPageSize();
	
	var t = document.createElement("DIV")
	var b = document.createElement("DIV");
	var bb = document.createElement("DIV");
	
	staticCont = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
	staticCont+= "<tr>";
	staticCont+= "	<td class=\"topLeft\"></td>";
	staticCont+= "	<td class=\"topCent\"></td>";
	staticCont+= "	<td class=\"topRight\"></td>";
	staticCont+= "</tr>";
	staticCont+= "<tr>";
	staticCont+= "	<td class=\"centLeft\"></td>";
	staticCont+= "	<td style=\"background-color:#ffffff;\">";
	
	staticCont+= "	<div class=\"closing\"><img src=\"images/icons/close.png\" onclick=\"bClose();\" alt=\"Kapat\"></div>";
	staticCont+= content;
	staticCont+= "	</td>";
	staticCont+= "	<td class=\"centRight\"></td>";
	staticCont+= "</tr>";
	staticCont+= "<tr>";
	staticCont+= "	<td class=\"botLeft\"></td>";
	staticCont+= "	<td class=\"botCent\"></td>";
	staticCont+= "	<td class=\"botRight\"></td>";
	staticCont+= "</tr>";
	staticCont+= "</table>";
	
	
	t.id		= "maininn";
	t.className = "alpha";
	
	
	b.id		= "overlay";
	b.innerHTML =  staticCont;
	
	bb.id		= "bigbang";
	//bb.style.height = arrayPageSize[1]+"px";
	
	
	document.body.appendChild(bb);
	document.body.appendChild(b);
	document.body.appendChild(t);
	
	getTop(arrayPageSize[3],arrayPageSize[2]);
}

/*///// closing window /////*/

function bClose(){
	
	document.body.removeChild(document.getElementById("bigbang"));
	document.body.removeChild(document.getElementById("overlay"));
	document.body.removeChild(document.getElementById("maininn"));

}

/* ********* */
function getMenus(page){
	post = "page="+page;
	req.open('post','actions/getContent.php',true);
	req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	req.send(post);
	req.onreadystatechange = function(){
			if(req.readyState == 4){
				NewWindow(req.responseText);
			}else{
				return false;
			}
		}
	
}

function getBook(bookID){
	var bookset = document.getElementById("bookset");
	var post = 'bookID=' + bookID;
	req.open('post','actions/getBook.php',true);
	req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	req.send(post);
	req.onreadystatechange = function(){
			if(req.readyState == 4){
				bookset.innerHTML = req.responseText;
			}else{
				return false;
			}
		}
		
}
function getNews(){
	post = "get=all";
	req.open('post','actions/getNews.php',true);
	req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	req.send(post);
	req.onreadystatechange = function(){
			if(req.readyState == 4){
				NewWindow(req.responseText);
			}else{
				return false;
			}
		}
	
}

function ajaxload(change){
	var change,object,bookset,cont; // global vars setted up
	var arr = document.myForm.getElementsByTagName("li");
	bookset = document.getElementById("bookset");
	
	cont = "<div style=\"text-align:center; padding:15px;\">";
	cont+= "<img src=\"images/tools/loading.gif\"><br>";
	cont+= "<font class=\"font\">içerik yükleniyor...</font>";
	cont+= "</div>";
	
	for(i=0; i<arr.length; i++){
		if(change != arr[i].id){
			object = document.myForm.getElementsByTagName("li").item([i]);
			object.setAttribute("class", "none");
			object.setAttribute("className", "");
		}else{
			object = document.getElementById(change);
			object.setAttribute("class", "selected");
			object.setAttribute("className", "selected");
			bookset.innerHTML = cont;
		}
	}
	setTimeout("getBook('"+change+"')",1000,"JavaScript");
}

function sendContactForm(){
	var posts = 'name=' + document.getElementById("isim").value + '&email=' + document.getElementById("mail").value + '&subject=' + document.getElementById("konu").value + '&message=' + document.getElementById("mess").value; 
	
	req.open('post','actions/sendContact.php',true);
	req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	req.send(posts);
	req.onreadystatechange = function(){
			if(req.readyState == 4){
				document.getElementById("sent").innerHTML = req.responseText;
			}else{
				return false;
			}
		}

}



