function preLoadImage()
{
	imageMain			=	new Image();
	imageNews			=	new Image();
	imageAdvertise		=	new Image();
	imageAuction		=	new Image();
	imageAtoz			=	new Image();
	imageEmployment		=	new Image();
	imageContactus		=	new Image();
	imageMain.src		=	"images/but_over_14.gif";
	imageNews.src			=	"images/but_over_12.gif";
	imageAdvertise.src		=	"images/but_over_10.gif";
	imageAuction.src		=	"images/but_over_08.gif";
	imageAtoz.src			=	"images/but_over_06.gif";
	imageEmployment.src		=	"images/but_over_04.gif";
	imageContactus.src		=	"images/but_over_02.gif";
}
function mouseOver(id)
{
var	imageMain			=	"images/but_over_14.gif";
var	imageNews			=	"images/but_over_12.gif";
var	imageAdvertise		=	"images/but_over_10.gif";
var	imageAuction		=	"images/but_over_08.gif";
var	imageAtoz			=	"images/but_over_06.gif";
var	imageEmployment		=	"images/but_over_04.gif";
var	imageContactus		=	"images/but_over_02.gif";
	switch(id)
	{
		case 'main':
			document.getElementById(id).src = imageMain;
		break;	
		case 'news':
			document.getElementById(id).src = imageNews;
		break;
		case 'advertise':
			document.getElementById(id).src = imageAdvertise;
		break;
		case 'auction':
			document.getElementById(id).src = imageAuction;
		break;
		case 'atoz':
			document.getElementById(id).src = imageAtoz;
		break;
		case 'employment':
			document.getElementById(id).src = imageEmployment;
		break;
		case 'contactus':
			document.getElementById(id).src = imageContactus;
		break;	
	}
}
function mouseOut(id)
{
var	imageMain			=	"images/but_14.gif";
var	imageNews			=	"images/but_12.gif";
var	imageAdvertise		=	"images/but_10.gif";
var	imageAuction		=	"images/but_08.gif";
var	imageAtoz			=	"images/but_06.gif";
var	imageEmployment		=	"images/but_04.gif";
var	imageContactus		=	"images/but_02.gif";
	switch(id)
	{
		case 'main':
			document.getElementById(id).src = imageMain;
		break;	
		case 'news':
			document.getElementById(id).src = imageNews;
		break;
		case 'advertise':
			document.getElementById(id).src = imageAdvertise;
		break;
		case 'auction':
			document.getElementById(id).src = imageAuction;
		break;
		case 'atoz':
			document.getElementById(id).src = imageAtoz;
		break;
		case 'employment':
			document.getElementById(id).src = imageEmployment;
		break;
		case 'contactus':
			document.getElementById(id).src = imageContactus;
		break;	
	}
}
function IsNumeric(strString)
   //  check for valid numeric strings	
{
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;
   //  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
   return blnResult;
}
function validate_email(field)
{
	apos=field.indexOf("@");
	dotpos=field.lastIndexOf(".");
	if (apos<1||dotpos-apos<2)
	{
		return false;
	}
	else
	{
		return true;
	}
}
function check_contact_us_form(name,email,subject,address,phone,mobile,text)
{
	document.getElementById("contact_us_div").innerHTML="";
	if(name.value=='' || subject.value=='' || text.value==''|| address.value==''|| phone.value==''|| mobile.value=='')
	{
		document.getElementById("contact_us_div").innerHTML="يرجى ملئ جميع الحقول";
		return false;		
	}
	if(isNaN(phone.value)||isNaN(mobile.value))
	{
		document.getElementById("contact_us_div").innerHTML="يرجى إدخال أرقام الهواتف بشكل صحيح";
		return false;	
	}
	if(!validate_email(email.value))
	{
		document.getElementById("contact_us_div").innerHTML="البريد الإلكتروني خاطئ";
		return false;		
	}
	return true;
}

function check_add_classified(select_cls,select_dep,select_cit,select_adt,area,price,email,phone,mobile,description)
{
	document.getElementById("select_cls_div").innerHTML="";
	document.getElementById("select_dep_div").innerHTML="";
	document.getElementById("select_cit_div").innerHTML="";	
	document.getElementById("select_adt_div").innerHTML="";
	document.getElementById("area_div").innerHTML="";
	document.getElementById("price_div").innerHTML="";
	document.getElementById("email_div").innerHTML="";
	document.getElementById("phone_div").innerHTML="";
	document.getElementById("mobile_div").innerHTML="";
	if(select_cls.value=="-1")
	{
		document.getElementById("select_cls_div").innerHTML="<font color='#FF0000'>* يرجى إختيار التصنيف</font>";
		return false;
	}
	if(select_dep.value=="-1" && select_cls.value !=6)
	{
		document.getElementById("select_dep_div").innerHTML="<font color='#FF0000'>* يرجى إختيار القسم</font>";
		return false;
	}
	if(select_cit.value=="-1")
	{
		document.getElementById("select_cit_div").innerHTML="<font color='#FF0000'>* يرجى إختيار المدينة</font>";
		return false;
	}
	if(select_adt.value=="-1")
	{
		document.getElementById("select_adt_div").innerHTML="<font color='#FF0000'>* يرجى إختيار نوع الإعلان</font>";
		return false;
	}
	if(area.value=="")
	{
		document.getElementById("area_div").innerHTML="<font color='#FF0000'>* يرجى تحديد المساحة</font>";
		return false;
	}
	//IsNumeric function exist in js.js file	
	if(!IsNumeric(area.value))
	{
		document.getElementById("area_div").innerHTML="<font color='#FF0000'>* يرجى عدم كتابة أحرف</font>";
		return false;
	}
	if(price.value=="")
	{
		document.getElementById("price_div").innerHTML="<font color='#FF0000'>* يرجى تحديد السعر</font>";
		return false;
	}
	if(!IsNumeric(price.value))
	{
		document.getElementById("price_div").innerHTML="<font color='#FF0000'>* يرجى عدم كتابة أحرف</font>";
		return false;
	}
	if(email.value=="")
	{
		document.getElementById("email_div").innerHTML="<font color='#FF0000'>* يرجى كتابة البريد الإلكتروني</font>";
		return false;
	}
	//validate_email function exist in js.js file
	if(!validate_email(email.value))
	{
		document.getElementById("email_div").innerHTML="<font color='#FF0000'>* البريد الإلكتروني خاطئ</font>";
		return false;		
	}
	if(phone.value=="")
	{
		document.getElementById("phone_div").innerHTML="<font color='#FF0000'>* يرجى كتابة رقم الهاتف</font>";
		return false;		
	}
	if(!IsNumeric(phone.value))
	{
		document.getElementById("phone_div").innerHTML="<font color='#FF0000'>* يرجى عدم كتابة أحرف</font>";
		return false;		
	}
	if(mobile.value!="")
	{
		if(isNaN(mobile.value))
		{
			document.getElementById("mobile_div").innerHTML="<font color='#FF0000'>* يرجى عدم كتابة أحرف</font>";
			return false;	
		}
	}
	
	if(description.value=="")
	{
		document.getElementById("description_div").innerHTML="<font color='#FF0000'>* يرجى كتابة الوصف</font>";
		return false;		
	}
	return true;
}

function check_cls_search1(area_min,area_max,price_min,price_max)
{
	document.getElementById("area_div").innerHTML="";
	document.getElementById("price_div").innerHTML="";
	
	if(isNaN(area_min.value)&&area_min.value!="من")
	{
		document.getElementById("area_div").innerHTML="<font color='#FF0000'>* يرجى عدم كتابة أحرف</font>";
		return false;
	}
	if(isNaN(area_max.value)&&area_max.value!="الى")
	{
		document.getElementById("area_div").innerHTML="<font color='#FF0000'>* يرجى عدم كتابة أحرف</font>";
		return false;
	}
	if(isNaN(price_min.value)&&price_min.value!="من")
	{
		document.getElementById("price_div").innerHTML="<font color='#FF0000'>* يرجى عدم كتابة أحرف</font>";
		return false;
	}
	if(isNaN(price_max.value)&&price_max.value!="الى")
	{
		document.getElementById("price_div").innerHTML="<font color='#FF0000'>* يرجى عدم كتابة أحرف</font>";
		return false;
	}
	return true;
}
function check_cls_search2(price_min,price_max)
{
	document.getElementById("price_div").innerHTML="";
	if(isNaN(price_min.value)&&price_min.value!="من")
	{
		document.getElementById("price_div").innerHTML="<font color='#FF0000'>* يرجى عدم كتابة أحرف</font>";
		return false;
	}
	if(isNaN(price_max.value)&&price_max.value!="الى")
	{
		document.getElementById("price_div").innerHTML="<font color='#FF0000'>* يرجى عدم كتابة أحرف</font>";
		return false;
	}
	return true;
}
function check_add_new_user(username,email,name,last,phone,mobile)
{
	
	if(name.value=='')
	{
		document.getElementById("name_div").innerHTML="<font color='#FF0000'>* يرجى كتابة الاسم </font>";
		return false;
	}
	if(last.value=='')
	{
		document.getElementById("last_div").innerHTML="<font color='#FF0000'>* يرجى كتابة الكنية</font>";
		return false;
	}
	if(phone.value==''||isNaN(phone.value))
	{
		document.getElementById("phone_div").innerHTML="<font color='#FF0000'>* يرجى كتابة رقم الهاتف</font>";
		return false;
	}
	if(mobile.value==''||isNaN(mobile.value))
	{
		document.getElementById("mobile_div").innerHTML="<font color='#FF0000'>* يرجى كتابة رقم الجوال</font>";
		return false;
	}
	if(username.value=='')
	{
		document.getElementById("username_div").innerHTML="<font color='#FF0000'>* يرجى كتابة اسم المستخدم</font>";
		return false;
	}
	
	if(email.value=="")
	{
		document.getElementById("username_div").innerHTML="";
		//document.getElementById("password_div").innerHTML="";
		//document.getElementById("confirm_password_div").innerHTML="";		
		document.getElementById("email_div").innerHTML="<font color='#FF0000'>* يرجى كتابة البريد الإلكتروني</font>";
		return false;
	}
	if(!validate_email(email.value))
	{
		document.getElementById("username_div").innerHTML="";
		//document.getElementById("password_div").innerHTML="";	
		//document.getElementById("confirm_password_div").innerHTML="";		
		document.getElementById("email_div").innerHTML="<font color='#FF0000'>* البريد الإلكتروني خاطئ</font>";
		return false;		
	}
	
	
	return true;
	
}

function checkk(username,email)
{
if(username.value=='')	
	return false;
}
function check_nemployment(name,address,phone,email,position,date,cv)
{
	document.getElementById("name_div").innerHTML="";
	document.getElementById("address_div").innerHTML="";
	document.getElementById("phone_div").innerHTML="";	
	document.getElementById("email_div").innerHTML="";
	document.getElementById("position_div").innerHTML="";
	document.getElementById("date_div").innerHTML="";
	document.getElementById("cv_div").innerHTML="";
	if(name.value=="")
	{
		document.getElementById("name_div").innerHTML="* يرجى كتابة الاسم";
		return false;
	}
	if(address.value=="")
	{
		document.getElementById("address_div").innerHTML="* يرجى تحديد العنوان";
		return false;
	}
	if(phone.value=="")
	{
		document.getElementById("phone_div").innerHTML="* يرجى كتابة رقم الهاتف";
		return false;		
	}
	if(!IsNumeric(phone.value))
	{
		document.getElementById("phone_div").innerHTML="* يرجى عدم كتابة أحرف";
		return false;		
	}
	if(email.value=="")
	{
		document.getElementById("email_div").innerHTML="* يرجى كتابة البريد الإلكتروني";
		return false;
	}
	if(!validate_email(email.value))
	{
		document.getElementById("email_div").innerHTML="* البريد الإلكتروني خاطئ";
		return false;		
	}
	if(position.value=="-1")
	{
		document.getElementById("position_div").innerHTML="* يرجى تحديد الشهادة";
		return false;
	}
	if(date.value=="")
	{
		document.getElementById("date_div").innerHTML="* برجى تحديد تارخ الميلاد";
		return false;		
	}

	if(cv.value=="")
	{
		document.getElementById("cv_div").innerHTML="* يرجى ارفاق السيرة الذاتية";
		return false;		
	}
	return true;
}
function check_applicant(categories,sub_categories,name,last_name,birth_place,mobile)
{
	document.getElementById("categories_div").innerHTML="";
	document.getElementById("sub_categories_div").innerHTML="";
	document.getElementById("name_div").innerHTML="";	
	document.getElementById("last_name_div").innerHTML="";
	document.getElementById("birth_place_div").innerHTML="";
	document.getElementById("mobile_div").innerHTML="";
	if(categories.value=="-1")
	{
		document.getElementById("categories_div").innerHTML="<font color='#FF0000'>* يرجى إختيار الاختصاص الرئيسي</font>";
		return false;
	}
	if(sub_categories.value=="-1")
	{
		document.getElementById("sub_categories_div").innerHTML="<font color='#FF0000'>* يرجى إختيار الاختصاص الفرعي</font>";
		return false;
	}
	if(name.value=="")
	{
		document.getElementById("name_div").innerHTML="* برجى كتابة الاسم";
		return false;		
	}
	if(last_name.value=="")
	{
		document.getElementById("last_name_div").innerHTML="* برجى كتابة الكنية";
		return false;		
	}
	if(birth_place.value=="")
	{
		document.getElementById("birth_place_div").innerHTML="* برجى تحديد مكان الولادة";
		return false;		
	}
	if(mobile.value=="")
	{
		document.getElementById("mobile_div").innerHTML="* يرجى كتابة رقم الجوال";
		return false;		
	}
	if(!IsNumeric(mobile.value))
	{
		document.getElementById("mobile_div").innerHTML="* يرجى عدم كتابة أحرف";
		return false;		
	}
	return true;
	
}

function check_auction_subscribe(amount)
{
	if(isNaN(amount.value)||amount.value=="")
	{
		document.getElementById("amount_div").innerHTML="<font color='#FF0000'>* يرجى إدخال الرقم بشكل صحيح</font>";
		return false;
	}
	return true;
}

function check_auction_add(categories,scategories,title1,image,details)
{
	if(categories.value=='')
	{
		document.getElementById("cat_div").innerHTML="<font color='#FF0000'>* يرجى إدخال الصنف الأساسي  </font>";
		return false;
	}
	if(scategories.value=='')
	{
		document.getElementById("scat_div").innerHTML="<font color='#FF0000'>* يرجى إدخال الصنف الفرعي</font>";
		return false;
	}
	if(title1.value=='')
	{
		document.getElementById("title_div").innerHTML="<font color='#FF0000'>* يرجى إدخال العنوان </font>";
		return false;
	}
	if(image.value=='')
	{
		document.getElementById("image_div").innerHTML="<font color='#FF0000'>* يرجى إدخال الصورة </font>";
		return false;
	}
	if(details.value=='')
	{
		document.getElementById("details_div").innerHTML="<font color='#FF0000'>* يرجى إدخال التفاصيل </font>";
		return false;
	}
	return true;
}

function check_applicant_employers(categories,sub_categories,company_name,company_work,country,city,address,company_type,mobile,phone)
{
	document.getElementById("categories_div").innerHTML="";
	document.getElementById("sub_categories_div").innerHTML="";
	document.getElementById("company_name_div").innerHTML="";
	document.getElementById("company_work_div").innerHTML="";
	document.getElementById("country_div").innerHTML="";
	document.getElementById("city_div").innerHTML="";
	document.getElementById("address_div").innerHTML="";
	document.getElementById("company_type_div").innerHTML="";	
	document.getElementById("mobile_div").innerHTML="";
	document.getElementById("phone_div").innerHTML="";
	
	if(categories.value=="-1")
	{
		document.getElementById("categories_div").innerHTML="<font color='#FF0000'>* يرجى إختيار الاختصاص الرئيسي</font>";
		return false;
	}
	if(sub_categories.value=="-1")
	{
		document.getElementById("sub_categories_div").innerHTML="<font color='#FF0000'>* يرجى إختيار الاختصاص الفرعي</font>";
		return false;
	}
	if(company_name.value=="")
	{
		document.getElementById("company_name_div").innerHTML="* يرجى كتابة اسم الشركة";
		return false;
	}
	if(company_work.value=="")
	{
		document.getElementById("company_work_div").innerHTML="* برجى تحديد عمل الشركة";
		return false;		
	}
	if(country.value=="-1")
	{
		document.getElementById("country_div").innerHTML="* برجى تحديد مكان الدولة";
		return false;		
	}
	if(city.value=="")
	{
		document.getElementById("city_div").innerHTML="* برجى تحديد المدينة";
		return false;		
	}
	if(address.value=="")
	{
		document.getElementById("address_div").innerHTML="* برجى كتابة العنوان";
		return false;		
	}
	if(company_type.value=="-1")
	{
		document.getElementById("company_type_div").innerHTML="* برجى تحديد نوع الشركة";
		return false;		
	}
	if(mobile.value=="")
	{
		document.getElementById("mobile_div").innerHTML="* يرجى كتابة رقم الجوال";
		return false;		
	}
	if(!IsNumeric(mobile.value))
	{
		document.getElementById("mobile_div").innerHTML="* يرجى عدم كتابة أحرف";
		return false;		
	}
	if(phone.value=="")
	{
		document.getElementById("phone_div").innerHTML="* يرجى كتابة رقم الهاتف";
		return false;		
	}
	if(!IsNumeric(phone.value))
	{
		document.getElementById("phone_div").innerHTML="* يرجى عدم كتابة أحرف";
		return false;		
	}
	return true;
}
function loginFunc()
{
	var username	=	document.getElementById('username').value;
	var password	=	document.getElementById('password').value;
	var	url			=	"index.php?un="+username+"&password"+password;
	location.replace(url);
}
function check_email(participate_classified_email)
{
	document.getElementById("email_div").innerHTML="";
	if(participate_classified_email.value=="")
	{
		document.getElementById("email_div").innerHTML="<font color='#FF0000'>* يرجى كتابة البريد الإلكتروني</font>";
		return false;
	}
	if(!validate_email(participate_classified_email.value))
	{
		document.getElementById("email_div").innerHTML="<font color='#FF0000'>* البريد الإلكتروني خاطئ</font>";
		return false;		
	}
	
	return true;
}
function new_participation(name,last,email,phone,mobile)
{
	document.getElementById("name_div").innerHTML="";
	document.getElementById("last_div").innerHTML="";
	document.getElementById("email_div").innerHTML="";
	document.getElementById("phone_div").innerHTML="";
	document.getElementById("mobile_div").innerHTML="";
	if(name.value=="")
	{
		document.getElementById("name_div").innerHTML="<font color='#FF0000'>* يرجى كتابة الأسم</font>";
		return false;
	}
	if(last.value=="")
	{
		document.getElementById("last_div").innerHTML="<font color='#FF0000'>* يرجى كتابة الكنية</font>";
		return false;
	}
	if(phone.value=="")
	{
		document.getElementById("phone_div").innerHTML="<font color='#FF0000'>* يرجى كتابة الهاتف</font>";
		return false;
	}
	if(isNaN(phone.value))
	{
		document.getElementById("phone_div").innerHTML="<font color='#FF0000'>* يرجى عدم كتابة أحرف</font>";
		return false;
	}
	if(mobile.value=="")
	{
		document.getElementById("mobile_div").innerHTML="<font color='#FF0000'>* يرجى كتابة الجوال</font>";
		return false;
	}
	if(isNaN(mobile.value))
	{
		document.getElementById("mobile_div").innerHTML="<font color='#FF0000'>* يرجى عدم كتابة أحرف</font>";
		return false;
	}
	if(email.value=="")
	{
		document.getElementById("email_div").innerHTML="<font color='#FF0000'>* يرجى كتابة البريد الإلكتروني</font>";
		return false;
	}
	if(!validate_email(email.value))
	{
		document.getElementById("email_div").innerHTML="<font color='#FF0000'>* البريد الإلكتروني خاطئ</font>";
		return false;		
	}
	
	return true;
}
function delivery_feedback(name,email,subject,text)
{
	document.getElementById("name_div").innerHTML="";
	document.getElementById("email_div").innerHTML="";	
	document.getElementById("text_div").innerHTML="";		
	document.getElementById("subject_div").innerHTML="";
	if(name.value=="")
	{
		document.getElementById("name_div").innerHTML="<font color='#FF0000'>* يرجى كتابة الأسم</font>";
		return false;
	}
	if(email.value=="")
	{
		document.getElementById("email_div").innerHTML="<font color='#FF0000'>* يرجى كتابة البريد الإلكتروني</font>";
		return false;
	}
	if(!validate_email(email.value))
	{
		document.getElementById("email_div").innerHTML="<font color='#FF0000'>* البريد الإلكتروني خاطئ</font>";
		return false;		
	}
	if(subject.value=="")
	{
		document.getElementById("subject_div").innerHTML="<font color='#FF0000'>* يرجى كتابة عنوان الشكوى</font>";
		return false;
	}
	if(text.value=="")
	{
		document.getElementById("text_div").innerHTML="<font color='#FF0000'>* يرجى كتابة المشكلة</font>";
		return false;
	}
	return true;
}
/*___________________Hint Script___________________________________*/
/***********************************************
* Show Hint script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
		
var horizontal_offset="9px"; //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0"; //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all;
var ns6=document.getElementById&&!document.all;

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox
/*_____________________________________________________________*/

