function search()
{
	var q= document.getElementById('search_txt').value;
	var type= document.getElementById('type').value;
	if(q =="")
	{
		alert ("الرجاء إدخال النص المراد  البحث عنه");
	}
	else
	{
		var url = base_url+"search?q="+decodeURI(q)+"&type="+type+"";
		window.open(url,"_self")	
	}
}
function MM_openPopupS(url)
{
	window.open(url,'popup','scrollbars=yes,status=yes,width=1000,height=750');
}
function MM_openPopup(url,width,height)
{
	window.open(url,'popup','scrollbars=no,status=no,width='+width+',height='+height);
}
function change_vedio(swf,prm,img,full) {
	if(full != 0 )
	{

	var FU = { 
			movie:swf,id:"flvplayer",name:"flvplayer",width:"318",height:"258",majorversion:"8",build:"0",bgcolor:"#FFFFFF",wmode:"opaque",flashvars:"file="+prm+"&image="+img+"&lightcolor=0x557722&backcolor=0x000000&frontcolor=0xCCCCCC&displaywidth=318&autostart=true&fsreturnpage="+full
	 };
	}
	else
	{
		var FU = { 
			movie:swf,id:"flvplayer",name:"flvplayer",width:"318",height:"258",majorversion:"8",build:"0",bgcolor:"#FFFFFF",wmode:"opaque",flashvars:"file="+prm+"&image="+img+"&lightcolor=0x557722&backcolor=0x000000&frontcolor=0xCCCCCC&displaywidth=318&autostart=true"
	 }
	}
	UFO.create(	FU, "player2");

	
};

function activateField(newVideosListID)
{
	document.getElementById('newVideosList1').style.backgroundColor='';
	document.getElementById('newVideosList2').style.backgroundColor='';
	document.getElementById('newVideosList3').style.backgroundColor='';
	document.getElementById('newVideosList4').style.backgroundColor='';
	document.getElementById(newVideosListID).style.backgroundColor='#f0f0f0';

}
function searchKey(evt)
{
	if(evt ==13)
	{
		search();
	}
}
String.prototype.trim = function() {
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
};
function logout(location){
	if (confirm('هل انت متاكد بانك تريد الخروج ؟')) {
		window.location= base_url+"logout.php?location="+page_out_1;
		//AJAXGet(base_url+"logout.php?location="+location,logoutHandler,false,false);
	}

}
function logout2(location){
	if (confirm('هل انت متاكد بانك تريد الخروج ؟')) {
		window.location= location;
		//AJAXGet(base_url+"logout.php?location="+location,logoutHandler,false,false);
	}

}
function logoutHandler(sText){
	window.location= page_out_1;
	
}
function checkDate(mnth,dy,yr1)
{
	
if(mnth > 12 || mnth < 1)	
{
	 return false;
}
maxdy = 30
 //if the month 22 isn't February...
 if (mnth != 2)
 {
 // then see if it's a month that only has 30 days...
 
 if (mnth == 4 || mnth == 6 || mnth == 9 || mnth == 11)
 {
 // if it is, and the day value is greater than 30, alert the user
 if (dy > maxdy)
 {
 
 return false;
 }
 }
 }
 else
 {
 //if it IS February , check if it's a leap year

 // (this is the modulus operation which returns the remainder of the selected year divided by 4
 leapYrTest = yr1 % 4
 // if the year divides evenly by 4, it is a leap year and the remainder will be 0...
 if (leapYrTest == 0)
 {
 // so our max day for february is 29
 maxdy = 29
 }
 else
 {
 maxdy = 28
 }
 // if the user selected a value greater than the max day AND the month is February
 if (dy > maxdy)
 {
 // Alert the user and set the day back to 1

	
 return false;
 }
 }
 return true;
} 
function validDate()
{
	
	if(document.felter.dob.value == "")
	{
		document.getElementById('error').innerHTML='<font color="#FF0000">الرجاء إختيار تاريخ بدء البحث </font>';
 		document.felter.dob.focus();
		return false;
	}
		
	if(document.felter.doe.value == "")
	{
		document.getElementById('error').innerHTML='<font color="#FF0000">الرجاء إختيار تاريخ إنتهاء البحث </font>';
 		document.felter.doe.focus();
		return false;
	}
	var dob =document.felter.dob.value;
	var doe =document.felter.doe.value;
	
	var dataOfB = dob.split("-");
	var bDate=new Date();
	bDate.setUTCFullYear(parseFloat(dataOfB[0]),(parseFloat(dataOfB[1])-1),parseFloat(dataOfB[2]));
	
	if( !checkDate(parseFloat(dataOfB[1]),parseFloat(dataOfB[2]),parseFloat(dataOfB[0])))
	{
		document.getElementById('error').innerHTML='<font color="#FF0000">هناك خلل في أختيار تاريخ البدء البحث </font>';
 		document.felter.dob.focus();
 		return false;
	}
	
			
	
	var dataOfE = doe.split("-");
	var eDate=new Date();
	eDate.setUTCFullYear(parseFloat(dataOfE[0]),(parseFloat(dataOfE[1])-1),parseFloat(dataOfE[2]));
	
	var today = new Date();

	if(bDate>today)
	{
		document.getElementById('error').innerHTML='<font color="#FF0000">هناك خلل في أختيار تاريخ البدء البحث</font>';
 		document.felter.dob.focus();
		return false;
	}
	if( !checkDate(parseFloat(dataOfE[1]),parseFloat(dataOfE[2]),parseFloat(dataOfE[0])))
	{
		document.getElementById('error').innerHTML='<font color="#FF0000">هناك خلل في أختيار تاريخ إنتهاء البحث </font>';
 		document.felter.doe.focus();
 		return false;
	}
	if(eDate>today)
	{
		document.getElementById('error').innerHTML='<font color="#FF0000">هناك خلل في أختيار تاريخ إنتهاء البحث</font>';
		document.felter.doe.focus();
		return false;
	}
	if(bDate>eDate)
	{
		document.getElementById('error').innerHTML='<font color="#FF0000">لا يمكن ان يكون تاريخ بدء البحث بعد تاريخ إنتهاء البحث</font>';
		document.felter.dob.focus();
		return false;
	}
	
}

function checkURL(url)
{
    var RegExp = /^((http:)\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url)){
        return true;
    }else{
        return false;
    }
} 
var actualSize = 12; //default stylesheet
function selectStyleSheet(delta) {
	
// Choix de la feuille de style
// actualSize doit أھtre dأ©fini auparavant
	var li; 

	if (9 < actualSize + delta && actualSize + delta < 15) {
		for (var i = 0 ; li = document.getElementsByTagName("link")[i] ; i++) {
			if(li.getAttribute("rel").indexOf("style") > -1 && li.getAttribute("title")) {
				if(li.getAttribute("title").indexOf("article") > -1)
				{
					
					li.disabled = true;
				}
				if(li.getAttribute("title").indexOf(actualSize + delta) > -1) 
				{
					li.disabled = false;
				}
			}
		}
		actualSize = actualSize + delta;
	}
}
function validWordLength(str) {
 	var mytool_arrayline=str.split("\n");
 	 for(var c = 0; c < mytool_arrayline.length; c++) {
	 	var mytool_array=mytool_arrayline[c].split(" ");
        for(var i = 0; i < mytool_array.length; i++) {
            if(mytool_array[i].length >150)
            {   
            	return mytool_array[i].substring(0, 20)+"...";
            
            }
        }//end for(var i = 0; i < mytool_array.length; i++)

       
 	 }
		return 0;	
}//end function valid