function salam(){
	alert("salam");
}
function start_new() {
	
		
		initialize();
		//loading the central div of the page called principal
		var xmlhttp = createHttpRequest();
		var objID = "01";
		//The page we are loading.
		//initialLocation will be used to know which page we are looking for
		//if it is the first page islamancient.php
		var initialLocation = dhtmlHistory.getCurrentLocation();
		// if no location specified, use the default
		if (initialLocation == null || initialLocation == "" ) {
			initialLocation = "principal::";
		}
		var params = initialLocation.split(":");
		if (initialLocation != "principal::") dhtmlHistory.add(initialLocation,params[1]+":"+params[2]);
		var serverPage="./include/"+params[0]+".php"; 
		//var serverPage="./include/principal.php";
		if (params[1].length != 0) {
			serverPage = serverPage + "?index=" + params[1];
			if (params[2].length != 0) serverPage = serverPage + "&id=" + params[2];
		} else if (params[2].length != 0) serverPage = serverPage + "?id=" + params[2];
		//Set the open close tracker variable.
		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			 obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	//} else 	{
	//			window.location = window.location + "index.php#principal::";
	//		}
}

function startold() {
  initialize();
  //ExecuteRequest("principal","","");
  //The location we are loading the page into.
  var xmlhttp = createHttpRequest();
  var objID = "01";
  //The page we are loading.
  var serverPage="./include/principal.php";
  //Set the open close tracker variable.
  var obj = document.getElementById(objID);
  xmlhttp.open("GET", serverPage);
  xmlhttp.onreadystatechange = function() {
  if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    //if (dhtmlHistory.hasHistory()==false) 
    dhtmlHistory.add("principal::",":");
	obj.innerHTML = xmlhttp.responseText;
  }
  }
  xmlhttp.send(null);
}


function start() {

	if (window.location != "http://localhost/alamralawal/" || window.location != "http://localhost/alamralawal/index.php" || window.location != "http://localhost/alamralawal") {
	          var initialLocation = dhtmlHistory.getCurrentLocation();
        } else {
				window.location = window.location + "index.php#principal::";
	}
		initialize();

		//loading the central div of the page called principal
		var xmlhttp = createHttpRequest();
		var objID = "01";
		//The page we are loading.
		//initialLocation will be used to know which page we are looking for
		//if it is the first page islamancient.php
		
	       var waitimg = '<img src = "../css/img/35.gif" align center />';

		// if no location specified, use the default
		if (initialLocation == null || initialLocation == "" ) {
			initialLocation = "principal::";
		}
		var params = initialLocation.split(":");
		//if (initialLocation != "principal::"){
		        dhtmlHistory.add(initialLocation,params[1]+":"+params[2]);
			//dhtmlHistory.add(initialLocation,params[1]+":"+params[2]);
		
			var serverPage="./include/"+params[0]+".php";
			//var serverPage="./include/principal.php";
			if (params[1].length != 0) {
				serverPage = serverPage + "?index=" + params[1];
				if (params[2].length != 0) serverPage = serverPage + "&id=" + params[2];
			} else if (params[2].length != 0) serverPage = serverPage + "?id=" + params[2];
			//Set the open close tracker variable.
			var obj = document.getElementById(objID);
			xmlhttp.open("GET", serverPage);
			if(xmlhttp.readyState == 1){
			    obj.innerHTML = '<div class="colonne-deux"> <div class="float-right"> <div class="bloc-contener"> <h3>جاري التحميل ، فضلا انتظر</h3> <div><!-- yy --> <div id="box"><div id="block_0"> <center>' + waitimg  + ' </center></div> </div> </div> </div>'
			}
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				 obj.innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(null);
}



function khotbapopup(url) 
{
	
 var width  = 997;
 var height = 600;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=yes';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'khotbapopup', params);
 if (window.focus) {newwin.focus()}
 return false;
}



function initialize() {
	// initialize the DHTML History framework
	dhtmlHistory.initialize();

	// subscribe to DHTML history change events
	dhtmlHistory.addListener(handleHistoryChange);
}

function handleHistoryChange(newLocation, historyData) {
	var params = newLocation.split(":");
	ExecuteRequest(params[0], params[1], params[2]);
}

function createHttpRequest (){
	var xmlhttp = false;
	
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
		xmlhttp = false;
			}
	}
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}


function ExecuteRequest(request, index, id) {
	//The location we are loading the page into.
	var xmlhttp = createHttpRequest();
	var $img = '<img src = "../css/img/35.gif" align center />';
	var objID = "01";
	//The page we are loading.
	var serverPage="./include/"+request+".php";
	if (index.length != 0) {
		serverPage = serverPage + "?index=" + index;
		if (id.length != 0) serverPage = serverPage + "&id=" + id;
	} else if (id.length != 0) serverPage = serverPage + "?id=" + id;
	//Set the open close tracker variable.
	var obj = document.getElementById(objID);
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 1){
	//obj.innerHTML = ' <div class="bloc-contener2"> <div dir=\"rtl\" style=\"padding-right:4px\"><table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"75%\"> <center>' + $img + '<br>&#1580;&#1575;&#1585;&#1610; &#1580;&#1604;&#1576; &#1575;&#1604;&#1576;&#1610;&#1575;&#1606;&#1575;&#1578;...</td></tr></table></div> </div>  ';
obj.innerHTML = '<div class="colonne-deux"> <div class="float-right"> <div class="bloc-contener"> <h3>جاري التحميل ، فضلا انتظر</h3> <div><!-- yy --> <div id="box"><div id="block_0"> <center>' + $img + ' </center></div> </div> </div> </div>'
	}

	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		dhtmlHistory.add(request+":"+index + ":" + id,index + ":" + id);

		obj.innerHTML = xmlhttp.responseText;
	}
	}
	xmlhttp.send(null);
}




function ExecuteRequestPost(request, msg, id) {
	//The location we are loading the page into.
	var xmlhttp = createHttpRequest();
	
	//The page we are loading.
	var serverPage="./include/"+request+".php";
	xmlhttp.open("POST",serverPage,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	var objID = "01";
	var obj = document.getElementById(objID);
	xmlhttp.onreadystatechange = function() {
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                //dhtmlHistory.add(request+":"+index + ":" + id,index + ":" + id);
		obj.innerHTML = xmlhttp.responseText;
	}
	}
	xmlhttp.send('msg='+msg+'&id='+id);
}

function ExecuteRequestPost2(request, msg, id) {
	//The location we are loading the page into.
	var xmlhttp = createHttpRequest();
	
	//The page we are loading.
	var serverPage=request;
	xmlhttp.open("POST",serverPage,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	var objID = "01";
	var obj = document.getElementById(objID);
	xmlhttp.onreadystatechange = function() {
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		obj.innerHTML = xmlhttp.responseText;
	}
	}
	xmlhttp.send('msg='+msg+'&id='+id);
}
function movingTextv(mes) {
	
		document.writeln('<marquee  id="hnews" behavior=\'scroll\' dir="rtl" direction=\'up\' scrollamount=\'1\' width=140 height=150 scrolldelay=\'20\' onmouseover=\'this.stop()\' onmouseout=\'this.start()\'>')
		document.writeln(mes)
		document.write('</marquee>')
	}

function movingTexthr(mes) {
	
		document.writeln('<marquee  id="hnews" behavior=\'scroll\' dir="rtl" direction=\'right\' scrollamount=\'3\' width=900 height=22  onmouseover=\'this.stop()\' onmouseout=\'this.start()\'>')

		document.writeln(mes)
		
		document.write('</marquee>')
	
}

function movingTexth(mes) {
	if (document.all){
		document.writeln('<marquee id="hnews" dir="rtl" scrollAmount=2 width=70 height=22 direction=right>')
		document.writeln(mes)
		hnews.onmouseover=new Function("hnews.scrollAmount=0")
		hnews.onmouseout=new Function("if (document.readyState=='complete') hnews.scrollAmount=2")
		document.write('</marquee>')
	} if (document.getElementById&&!document.all){
		document.write('<div style="position:absolute;overflow:hidden;width:70;height:22;" onMouseover="sspeed=0;" onMouseout="sspeed=2">')
		document.write('<div id="slider" style="position:absolute;width:&{swidth};">')
		document.write('</div></div>')
	}
}



function movingText(mes) {
	if (document.all){
		document.writeln('<marquee id="hnews" dir="rtl" scrollAmount=2 width=774 height=22 direction=up>')
		document.writeln(mes)
		hnews.onmouseover=new Function("hnews.scrollAmount=0")
		hnews.onmouseout=new Function("if (document.readyState=='complete') hnews.scrollAmount=2")
		document.write('</marquee>')
	} if (document.getElementById&&!document.all){
		document.write('<div style="position:absolute;overflow:hidden;width:770;height:22;" onMouseover="sspeed=0;" onMouseout="sspeed=2">')
		document.write('<div id="slider" style="position:absolute;width:&{swidth};">')
		document.write('</div></div>')
	}
}
//
// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}


function advancedSearch(pageNumber) {
	  q  = document.f1.q.value;
      st = getCheckedValue(document.f1.st);
      si = getCheckedValue(document.f1.si);
      
	//document.write (st);
	//The location we are loading the page into.
	var xmlhttp = createHttpRequest();
	//var serverPage="./include/advancedSearch.php?q="+q+"&st="+st+"&si="+si+"&pageNumber="+pageNumber;
	//xmlhttp.open("GET", serverPage);
	var serverPage='./include/advancedSearch.php';
	xmlhttp.open("POST",serverPage,true);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	//xmlhttp.send("name=" + name + "&email=" + email + "&comments=" + comments);
	//xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	var objID = "01";
	var obj = document.getElementById(objID);
	xmlhttp.onreadystatechange = function() {
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		obj.innerHTML = xmlhttp.responseText;
	}
	}
	//xmlhttp.send(null);
	xmlhttp.send('q='+q+'&st='+st+'&si='+si+'&pageNumber='+pageNumber);
}

function quickSearch(){
	var q  = document.quickSearchform.q.value;
	var st = 1;
	var si = 4;
	
	var xmlhttp = createHttpRequest();
	var serverPage='./include/advancedSearch.php';
	var $img = '<img src = "../css/img/35.gif" align center />';
	
	xmlhttp.open("POST",serverPage,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	
	var objID = "01";
	var obj = document.getElementById(objID);
	
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 1){
	obj.innerHTML = '<div class="colonne-deux"> <div class="float-right"> <div class="bloc-contener"> <h3>جاري التحميل ، فضلا انتظر</h3> <div><!-- yy --> <div id="box"><div id="block_0"> <center>' + $img + ' </center></div> </div> </div> </div>'
	}
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		//dhtmlHistory.add(serverPage.'::', 'q='+q+':st='+st+':si='+si+':pageNumber=0');
		obj.innerHTML = xmlhttp.responseText;
	}
	}
	xmlhttp.send('q='+q+'&st='+st+'&si='+si+'&pageNumber=0');
}


function printSpecialMakal()
{

var html = '<HTML>\n<HEAD>\n<title> friendly printing</title> </head><body>';
html += '<div style=\"text-align:right\">'

var printReadyElem = document.getElementById("block_0");

if (printReadyElem != null)
{
html += printReadyElem.innerHTML;
}
else
{
alert("Could not find the printReady function");
return;
}

html += '</div>\n</body>\n</html>';
var  disp_setting="toolbar=no,location=no,directories=no,menubar=no,";
 disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
var printWin = window.open("","printSpecial",disp_setting);
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
printWin.print();

} 
function printSpecialComment()
{

var html = '<HTML>\n<HEAD>\n<title>friendly printing</title> </head><body>';

html += '<div style=\"text-align:right\">'
var printReadyElem = document.getElementById("block_1");

if (printReadyElem != null)
{
html += printReadyElem.innerHTML;
}
else
{
alert("Could not find the printReady function");
return;
}

html += '</div>\n</body>\n</html>';
var  disp_setting="toolbar=no,location=no,directories=no,menubar=no,";
 disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
var printWin = window.open("","printSpecial",disp_setting);
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
printWin.print();

} 

function commentOfMakal(makalId,pageNumber) {
	//The location we are loading the page into.
	var xmlhttp = createHttpRequest();
	var objID = "02";
	//The page we are loading.
	var serverPage="./include/commentOfMakal.php?makalId="+makalId+"&pageNumber="+pageNumber;
	//Set the open close tracker variable.
	var obj = document.getElementById(objID);
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() {
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		obj.innerHTML = xmlhttp.responseText;
	}
	}
	xmlhttp.send(null);
}


function detailOfComment(commentId) {
	//The location we are loading the page into.
	var xmlhttp = createHttpRequest();
	var objID = "01";
	//The page we are loading.
	var serverPage="./include/detailOfComment.php?commentId="+commentId;
	//Set the open close tracker variable.
	var obj = document.getElementById(objID);
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() {
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		obj.innerHTML = xmlhttp.responseText;
	}
	}
	xmlhttp.send(null);
}

function detailOfGuestBook(Id) {
	//The location we are loading the page into.
	var xmlhttp = createHttpRequest();
	var objID = "01";
	//The page we are loading.
	var serverPage="./include/detailOfGuestBook.php?Id="+Id;
	//Set the open close tracker variable.
	var obj = document.getElementById(objID);
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() {
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		obj.innerHTML = xmlhttp.responseText;
	}
	}
	xmlhttp.send(null);
}

function classToggle(element,class1,class2) {
		if (element.className==class1) {
			element.className = class2;
		}
		else if (element.className==class2) {
			element.className = class1;
		}
	}
