﻿var SendEmailWindow = null;
var intervalTime = 0;
var DomYes = document.getElementById?1:0;
var CatStart = new Array(0,1,9, 19, 23); // where do the sub cats start for each category
var PosXtoAdd = -20;  // to be added on the position X of the ommahate_rouge image
var PosYtoAdd = 90; // to be added on the position Y of the ommahate_rouge image
var ObjectCat; 
var newX;
var newY;

function SendToFriend(sURL)
{
	// if SendEmail was already opened
	if(SendEmailWindow != null) 
	{
		SendEmailWindow.focus() ;
		return ;
	}

	// open SendEmail window	
	SendEmailWindow = window.open('articles/html/send-to-Friend.htm','','width=350; height=250; scrollbars=0');
}

function openSendMail() {	
	window.open('../../articles/html/send-to-Friend.htm','','width=350,height=250,menubar=no,location=no,resizable=no,scrollbars=no,status=no');
}

function PrintFile(fileName)
{
	window.open(fileName,'','');
}

function ShowPicsSlideShow()
{ 	
	window.open("Articles/html/YO_Slideshow.htm","YO_Slide_Show","scrollbars=no,height=400,width=560");
}

function ShowPicsSlideShow2(picsUrl)
{ 	
	window.open(picsUrl,"YO_Slide_Show","scrollbars=no,height=450,width=560,resizable=no");
}

function ShowPicsSlideShow3(picsUrl)
{ 	
	window.open(picsUrl,"YO_Slide_Show","scrollbars=no,height=550,width=560,resizable=no");
}

function OpenKeyboard(FocValue) 
{
	document.all('txtSearch').focus();
	param = FocValue;
	win1=window.open('Keyb.htm','ArabicKeyboard',"scrollbars=0, width=409, height=174");
}

function submitPage(idBook, isActive, idCategorie) 
{
		document.Form1.toRedirect.value = "no";
		document.Form1.BookID.value = idBook;
		document.Form1.CategoryID.value = idCategorie;
		document.Form1.action = "YOBooksListByCategoryPage.aspx";
		document.Form1.submit();			
}

function viewChapters() 
{
	document.Form1.toRedirect.value = "yes";
}

function displayContent(field, on)
{
	var itemObj;
	itemObj =  field;
	
	if(on)
	{
		document.all.item(itemObj).style.display = "";
	}
	else
	{
		document.all.item(itemObj).style.display = "none";
		if (intervalTime != 0)
			window.clearInterval(intervalTime);
	}
}

function setIntervalDelay(field,on)
{
	if (on)
		intervalTime = window.setInterval("displayContent('" + field + "', " + on +")",500);
	else
		displayContent(field,on);
}

function popLive(urlstr)
{
	window.open(urlstr,"player","scrollbars=no,height=330,width=230");
}

function popLiveWasait(urlstr)
{
	window.open(urlstr,"player","scrollbars=no,height=300,width=400,left=200,top=120,resizable=no");
}

function popSend(urlstr)
{
window.open(urlstr,"player","scrollbars=no,height=500,width=700,left=200,top=120,resizable=no");
}

function news_onclick() {
	if (document.news.uemail.value =="")
	{ 
		alert("أدخل بريدك الإلكتروني");
		return false;
	}
	else if (document.news.uemail.value.search("@")<1)
	{
		alert("أدخل بريدك الإلكتروني بالشكل الصحيح username@email.");
		return false;
	}
	else
	{
		window.open("Subscribe.aspx?email="+document.news.uemail.value,"video","status=1,scrollbars=1,menubar=0,directory=0,width=250,height=50,resize=1");
		return false;
	}
} 

function findPosX(obj)
	{
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
		
function setDivPosition(){
	var newX = document.body.clientWidth;
	var newY = findPosY(document.getElementById("imgCategory"));
	var objDivStyle = document.getElementById("couverture").style;
	
	newX = newX/2;
	newY = newY+20;
	
	objDivStyle.position = "absolute";
	objDivStyle.left = newX - 320;
	objDivStyle.top = newY;
}

function OpenKeyboardSearch(FocValue) 
{
	document.all('txtSearch').focus();
	param = FocValue;
	win1=window.open('Keyb.htm','ArabicKeyboard',"scrollbars=0,width=409,height=174");
}

function mouseOver(name)
{
	var imagesPath = "../images/";
	var category;
	var image;

	switch(name)
	{
	case "omahat_alkotob":

		HidAll();
		
		document.omahat_alkotob.src = imagesPath + "ommahate_rouge.gif";
		document.omahat_eteind.src = imagesPath + "categori_alumer.gif";
		
		document.syasya.src = imagesPath + "syasya_bleu.gif";
		document.syasya_eteind.src = imagesPath + "categori_eteind.gif";
		
		document.dawlate.src = imagesPath + "dawlate_bleu.gif";
		document.dawlate_eteind.src = imagesPath + "categori_eteind.gif";	
		
		document.dawawine.src = imagesPath + "dawawine_bleu.gif";
		document.dawawine_eteind.src = imagesPath + "categori_eteind.gif";
		
		document.autres.src = imagesPath + "autres_bleu.gif";
		document.autres_eteind.src = imagesPath + "categori_eteind.gif";
		
		//ShowImages(0);
		ShowCategory(0);
		
		
											
		break;
	case "syasya":
		
		HidAll();
		
		document.syasya.src = imagesPath + "syasya_rouge.gif";
		document.syasya_eteind.src = imagesPath + "categori_alumer.gif";
		
		document.omahat_alkotob.src = imagesPath + "ommahate_bleu.gif";
		document.omahat_eteind.src = imagesPath + "categori_eteind.gif";
		
		document.dawlate.src = imagesPath + "dawlate_bleu.gif";
		document.dawlate_eteind.src = imagesPath + "categori_eteind.gif";
		
		document.dawawine.src = imagesPath + "dawawine_bleu.gif";
		document.dawawine_eteind.src = imagesPath + "categori_eteind.gif";
		
		document.autres.src = imagesPath + "autres_bleu.gif";
		document.autres_eteind.src = imagesPath + "categori_eteind.gif";
		
		ShowCategory(1);
		
		break;
	case "dawawine":
		
		HidAll();
		document.dawawine.src = imagesPath + "dawawine_rouge.gif";
		document.dawawine_eteind.src = imagesPath + "categori_alumer.gif";
		
		document.omahat_alkotob.src = imagesPath + "ommahate_bleu.gif";
		document.omahat_eteind.src = imagesPath + "categori_eteind.gif";
		
		document.syasya.src = imagesPath + "syasya_bleu.gif";
		document.syasya_eteind.src = imagesPath + "categori_eteind.gif";
		
		document.dawlate.src = imagesPath + "dawlate_bleu.gif";
		document.dawlate_eteind.src = imagesPath + "categori_eteind.gif";
		
		
		document.autres.src = imagesPath + "autres_bleu.gif";
		document.autres_eteind.src = imagesPath + "categori_eteind.gif";
		
		ShowCategory(2);
		
		break;

	case "dawlate":
		HidAll();
		
		document.dawlate.src = imagesPath + "dawlate_rouge.gif";
		document.dawlate_eteind.src = imagesPath + "categori_alumer.gif";
		
		document.omahat_alkotob.src = imagesPath + "ommahate_bleu.gif";
		document.omahat_eteind.src = imagesPath + "categori_eteind.gif";
		
		document.syasya.src = imagesPath + "syasya_bleu.gif";
		document.syasya_eteind.src = imagesPath + "categori_eteind.gif";
		
		document.dawawine.src = imagesPath + "dawawine_bleu.gif";
		document.dawawine_eteind.src = imagesPath + "categori_eteind.gif";
		
		document.autres.src = imagesPath + "autres_bleu.gif";
		document.autres_eteind.src = imagesPath + "categori_eteind.gif";
		
		ShowCategory(3);

		break;
	case "autres":
		HidAll();
		
		document.autres.src = imagesPath + "autres_rouge.gif";
		document.autres_eteind.src = imagesPath + "categori_alumer.gif";
		
		document.omahat_alkotob.src = imagesPath + "ommahate_bleu.gif";
		document.omahat_eteind.src = imagesPath + "categori_eteind.gif";
		
		document.syasya.src = imagesPath + "syasya_bleu.gif";
		document.syasya_eteind.src = imagesPath + "categori_eteind.gif";
		
		document.dawlate.src = imagesPath + "dawlate_bleu.gif";
		document.dawlate_eteind.src = imagesPath + "categori_eteind.gif";
		
		document.dawawine.src = imagesPath + "dawawine_bleu.gif";
		
		document.dawawine_eteind.src = imagesPath + "categori_eteind.gif";
		ShowCategory(4);
		
		break;
	}
}
						
function mouseOut(name)
{			
	var imagesPath = "../images/";
	switch(name)
	{
		case "omahat_alkotob":
			HidAll();
			break;
		case "syasya":
			HidAll();
			break;
		case "dawawine":
			HidAll();
			break;
		case "dawlate":
			HidAll();
			break;
		/*case "autre":
			document.autre_eteind.src = imagesPath + "categori_eteind.gif";
			break;*/
	}
}
						
function ShowCategory(catIndex)
{
	var category;				
	if(document.layers){
		category = document.layers["category" + catIndex].style;
		category.visibility="show";
	}
	if (document.all) {
		category = document.all["category" + catIndex].style;
		category.visibility = "visible";							
	}
	if (document.getElementById) {
		category = document.getElementById("category" + catIndex).style;
		category.visibility = "visible";
	}
}
						
function HidAll(indexCategory)
{  
	var category;
	var CategoryCount = 5;
	
	for(var i= 0; i<CategoryCount; i++)
	{
		if ( i != indexCategory)
		{
			if(document.layers){
				category = document.layers["category" + i].style;
				glossaire.visibility = "hide";
			}
			if (document.all) {
				category = document.all["category" + i].style;
				category.visibility = "hidden";
			}
			if (document.getElementById) {
				category = document.getElementById("category" + i).style;
				category.visibility = "hidden";
			}		

		}
	}
}