function confirmLink(theLink, theSqlQuery)
{
   
    if (confirmMsg == '') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg + ' :\n' + theSqlQuery);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }

    return is_confirmed;
} 

function validSearch(searchForm)
{
	if(searchForm.ageFrom.value == "")
	{
		alert("يجب ان تختار العمر يبداء من اي سن");
		searchForm.ageFrom.focus();
		return false;
	}
	if(searchForm.ageTo.value == "")
	{
		alert("يجب ان تختار العمر ينتهي الى اي سن");
		searchForm.ageTo.focus();
		return false;
	}
	
	if(searchForm.ageTo.value < searchForm.ageFrom.value)
	{
		alert("يجب ان تبداء من سن اصغر الى سن اكبر");
		searchForm.ageTo.focus();
		searchForm.ageFrom.select();
		
		return false;
	}
	return true;
	
}

function openWindow(newURL){
	newWindow = window.open(newURL,"newWin","toolbar=no,location=no,scrollbars=yes, width=420, height=190")
}


function changeOrder(theLink)
{
	var theNewOrder = prompt("الترتيب المطلوب:","");
	if(theNewOrder)
	{
		theLink.href += '&newOrder='+theNewOrder;
	}
	else
	{
		return;
	}
}

function setStatusBar(msgStr) { self.status = msgStr; }


function jumpPage(theURL,gender,newLoc)
{

	newPage = newLoc.options[newLoc.selectedIndex].value
	if(newPage != "")
	{
		window.location = theURL+'?getByGender='+gender+'&countryIn='+newPage;
	}
	
}


function validEmail(email)
{
	re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	
	if(re.test(email))
	{
		return true;
	}
	return false;
}

function validUserForm(passForm)
{
	if(passForm.userName.value == "")
	{
		alert("يجب ان تدخل اسم مستخدم");
		passForm.userName.focus();
		return false;
	}
	if(passForm.userPass.value == "")
	{
		alert("يجب ان تدخل رمز سري");
		passForm.userPass.focus();
		return false;
	}
	if(passForm.userPass2.value == "")
	{
		alert("يجب ان تعيد ادخال الرمز السري");
		passForm.userPass2.focus();
		return false;
	}
	if(passForm.userPass.value != passForm.userPass2.value)
	{
		alert("تأكد ان الرموز السرية");
		passForm.userPass.focus();
		passForm.userPass2.select();
		
		return false;	
	}

	if(passForm.nickName.value == "")
	{
		alert("يجب ان تدخل اسم الشهرة");
		passForm.nickName.focus();
		return false;
	}

	if(!validEmail(passForm.email.value))
	{
		alert("تأكد من البريد الالكتروني");
		passForm.email.focus();
		
		return false;		
	}
	if(passForm.sex.selectedIndex == 0)
	{
		alert("يجب ان تحدد الجنس");
		passForm.sex.focus();
		return false;
	}

	if(passForm.nationalaty.selectedIndex == 0)
	{
		alert("يجب ان تحدد الجنسية");
		passForm.nationalaty.focus();
		return false;
	}
	
	if(passForm.socule.selectedIndex == 0)
	{
		alert("يجب ان تدخل الحالة الاجتماعية");
		passForm.socule.focus();
		return false;
	}

	if(passForm.age.selectedIndex == 0)
	{
		alert("يجب ان العمر");
		passForm.age.focus();
		return false;
	}

	if(passForm.degree.selectedIndex == 0)
	{
		alert("يجب ان تدخل المستوى الدراسي");
		passForm.degree.focus();
		return false;
	}
	
	
	if(passForm.countryLive.selectedIndex == 0)
	{
		alert("يجب ان تحدد دولة الاقامة");
		passForm.countryLive.focus();
		return false;
	}
	
	if(passForm.cityLive.value == "")
	{
		alert("يجب ان تدخل مدينة الاقامة");
		passForm.cityLive.focus();
		return false;
	}
	
	if(passForm.job.value == "")
	{
		alert("يجب ان تدخل المهنة");
		passForm.job.focus();
		return false;
	}
	
	if(passForm.moreAboutMe.value == "")
	{
		alert("يجب ان تدخل معلومات اخرى عنك");
		passForm.moreAboutMe.focus();
		return false;
	}
	
	if(passForm.moreAboutHim.value == "")
	{
		alert("يجب ان تدخل معلومات اخرى عن الطرف الاخر");
		passForm.moreAboutHim.focus();
		return false;
	}
	
	if(passForm.t3dd.selectedIndex == 0)
	{
		alert("يجب ان تحدد بالرغبة او عدم الرغبة في التعدد");
		passForm.t3dd.focus();
		return false;
	}

	if(passForm.msiar.selectedIndex == 0)
	{
		alert("يجب ان تحدد بالرغبة او عدم الرغبة في المسيار");
		passForm.msiar.focus();
		return false;
	}

	else{
		return true;	
	}
}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}





var xmlHttp
var loadstatustext="<img src='images/loading.gif' /> جاري التحميل..."

function showHint(str)
{ 
if (str.length > 0)
{ 
var url="gethint.php?sid=" + Math.random() + "&na=" + str
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 
else
{ 
document.getElementById("txtHint").innerHTML=""
} 
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
} 
} 

function GetXmlHttpObject(handler)
{ 
document.getElementById('txtHint').innerHTML=loadstatustext
var objXmlHttp=null

if (navigator.userAgent.indexOf("Opera")>=0)
{
alert("This example doesn't work in Opera") 
return 
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
} 
try
{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp
}
}


