// JavaScript Document

function validatephone(xxxxx)
{
	var maintainplus = '';
 	var numval = xxxxx.value
 	if ( numval.charAt(0)=='+' ){ var maintainplus = '+';}
 	curphonevar = numval.replace(/[\\A-Za-z!"£$%^&*+_={};:'@#~,.¦\/<>?|`¬\]\[]/g,'');
 	xxxxx.value = maintainplus + curphonevar;
 	var maintainplus = '';
 	xxxxx.focus;
}

function checkBlankField (txt)
{
	var mint_txt = txt.length;
	var mstr_txt = txt;
	var mint_count = 0;
	for (var iloop = 0; iloop<mint_txt; iloop++)
	{
		if (mstr_txt.charAt(iloop) == " ")
		{
		   mint_count = mint_count+1;
		}
	 }    
	// if nothing entered in the field
	if (txt == "")
	{
		return false;
	}
	else if (mint_count == mint_txt)
	{
		return false;
	}
	return true;
}

function valid_email(eml)
{
	//declare the required variables
	var mint_len;
	var mstr_eml=eml;
	var mint_at=0;
	var mint_atnum=0;
	var mint_dot=0;
	var mint_dotnum=0;

	mint_len = eml.length; //takes the length of the email address entered
	//checking for the symbol single quote. If found replace it with its html code
	if (mstr_eml.indexOf("'")!=-1)
	{	
		mstr_eml=mstr_eml.replace("'","'");
	}
	//checking for the (@) & (.) symbol
	for(var iloop=0;iloop<mint_len;iloop++)
	{
		if(mstr_eml.charAt(iloop)=="@")
		{
			mint_at=iloop+1;
			mint_atnum=mint_atnum+1;
		}
		if(mstr_eml.charAt(iloop)==".")
		{
			mint_dot=iloop+1;
			mint_dotnum=mint_dotnum+1;
		}
	}
	//if nothing entered in the field
	if (mstr_eml=="")
	{
		return true;
	}
	//if @ entered more than once & dot (.) entered more than 4 times
	else if((mint_atnum!=1)||(mint_dotnum>4)||((mint_dot-mint_at)<2)||((mint_len-mint_dot)<2)||(mint_at<3))
	{
		return true;
	}
	//if any blank space is entered in the email address
	else if (mstr_eml.indexOf(" ")!=-1)
	{
		return true;
	}
	return false;
}

function sub_form_gallery(id)
{
	gid = id.substring(0, id.lastIndexOf('_'));
	var frm = "form_" + id;
	var esID = document.forms[frm].escortID.value;
	
	if (esID != "")
	{
		document.location.href = "update_escort.php?id="+gid+"&eID=" + esID;
	}
	else
	{
		document.location.href = "escort_editor.php?id="+gid;
	}
}

function submitOrder()
{
	//alert(document.London_Escorts.escType_id.value);
	if(document.getElementById("all_escID").value == 0)
	{
		alert("No Record Found !");
		return false;
	}
	else
	{
		document.London_Escorts.submit();
	}
}

function submitText()
{
	/*if (checkBlankField(document.gall_text.text_gallery.value) == false){
		alert("Please enter some text for gallery page");
		document.gall_text.text_gallery.select();
		return false;
	}*/
	document.gall_text.submit();
}

function submitProfile()
{
	//alert(document.form_profile.show_2[0].value);
	
	if (checkBlankField(document.form_profile.esc_desc.value) == false){
		alert("Please enter escort description");
		document.form_profile.esc_desc.select();
		return false;
	}
	
	if (checkBlankField(document.form_profile.esc_name.value) == false){
		alert("Please enter the name");
		document.form_profile.esc_name.select();
		return false;
	}
	
	if (checkBlankField(document.form_profile.esc_working_name.value) == false){
		alert("Please enter the working name");
		document.form_profile.esc_working_name.select();
		return false;
	}
	
	
	if (checkBlankField(document.form_profile.esc_dobYear.value) == false || document.form_profile.esc_dobYear.value == "yyyy"){
		alert("Please enter the year");
		document.form_profile.esc_dobYear.select();
		return false;
	}
	
	if (isNaN(document.form_profile.esc_dobYear.value) == true){
		alert("Please enter the numeric value ");
		document.form_profile.esc_dobYear.select();
		return false;
	}
	
	if (checkBlankField(document.form_profile.esc_dobMonth.value) == false || document.form_profile.esc_dobMonth.value == "mm"){
		alert("Please enter the birth month");
		document.form_profile.esc_dobMonth.select();
		return false;
	}	
	
	if (isNaN(document.form_profile.esc_dobMonth.value) == true){
		//if (document.form_profile.esc_dobMonth.value >12){
		alert("Please enter the numeric value ");
		document.form_profile.esc_dobMonth.select();
		return false;
		//}
	}
	
		if (document.form_profile.esc_dobMonth.value >12){
		alert("Please enter correct birth month ");
		document.form_profile.esc_dobMonth.select();
		return false;
		}
		
		
		
		if (checkBlankField(document.form_profile.esc_dobDate.value) == false || document.form_profile.esc_dobDate.value == "dd"){
		alert("Please enter the birth date");
		document.form_profile.esc_dobDate.select();
		return false;
	}
	
	if (isNaN(document.form_profile.esc_dobDate.value) == true){
		alert("Please enter the numeric value ");
		document.form_profile.esc_dobDate.select();
		return false;
	}
	
	if (document.form_profile.esc_dobDate.value >31){
		alert("Please enter correct birth date ");
		document.form_profile.esc_dobDate.select();
		return false;
		}
		
	
		
	if(checkBlankField(document.form_profile.Image_1.value) == true)
	{	var pic1 = document.form_profile.Image_1.value;
		if(pic1!="")
		{	var new_pic1 = pic1.substring(pic1.lastIndexOf('.'),pic1.length);
			if(new_pic1!=".jpg" && new_pic1!=".JPG" && new_pic1!=".jpeg" && new_pic1!=".JPEG" && new_pic1!=".gif" && new_pic1!=".GIF" && new_pic1!=".png" && new_pic1!=".PNG" && new_pic1!=".tiff" && new_pic1!=".TIFF")
			{	alert("Please Upload Only Image Files.");
				document.form_profile.Image_1.select();
				return false;
			}
		}
	}
	document.form_profile.submit();
}

function updateProfile()
{
	/*alert(document.form_profile.show_2[0].value);
	if(checkBlankField(document.form_profile.Image_1.value) == true)
	{	var pic1 = document.form_profile.Image_1.value;
		if(pic1!="")
		{	var new_pic1 = pic1.substring(pic1.lastIndexOf('.'),pic1.length);
			if(new_pic1!=".jpg" && new_pic1!=".JPG" && new_pic1!=".jpeg" && new_pic1!=".JPEG" && new_pic1!=".gif" && new_pic1!=".GIF" && new_pic1!=".png" && new_pic1!=".PNG" && new_pic1!=".tiff" && new_pic1!=".TIFF")
			{	alert("Please Upload Only Image Files.");
				document.form_profile.Image_1.select();
				return false;
			}
		}
	}*/
	if (checkBlankField(document.form_profile.esc_name.value) == false){
		alert("Please enter the escort name");
		document.form_profile.esc_name.select();
		return false;
	}
	if (checkBlankField(document.form_profile.esc_desc.value) == false){
		alert("Please enter escort description");
		document.form_profile.esc_desc.select();
		return false;
	}
	
	
	if (checkBlankField(document.form_profile.esc_working_name.value) == false){
		alert("Please enter the working name");
		document.form_profile.esc_working_name.select();
		return false;
	}
	
	
	if (checkBlankField(document.form_profile.esc_dobYear.value) == false || document.form_profile.esc_dobYear.value == "yyyy"){
		alert("Please enter the year");
		document.form_profile.esc_dobYear.select();
		return false;
	}
	
	if (isNaN(document.form_profile.esc_dobYear.value) == true){
		alert("Please enter the numeric value ");
		document.form_profile.esc_dobYear.select();
		return false;
	}
	
	if (checkBlankField(document.form_profile.esc_dobMonth.value) == false || document.form_profile.esc_dobMonth.value == "mm"){
		alert("Please enter the birth month");
		document.form_profile.esc_dobMonth.select();
		return false;
	}	
	
	if (isNaN(document.form_profile.esc_dobMonth.value) == true){
		//if (document.form_profile.esc_dobMonth.value >12){
		alert("Please enter the numeric value ");
		document.form_profile.esc_dobMonth.select();
		return false;
		//}
	}
	
		if (document.form_profile.esc_dobMonth.value >12){
		alert("Please enter correct birth month ");
		document.form_profile.esc_dobMonth.select();
		return false;
		}
		
		
		
		if (checkBlankField(document.form_profile.esc_dobDate.value) == false || document.form_profile.esc_dobDate.value == "dd"){
		alert("Please enter the birth date");
		document.form_profile.esc_dobDate.select();
		return false;
	}
	
	if (isNaN(document.form_profile.esc_dobDate.value) == true){
		alert("Please enter the numeric value ");
		document.form_profile.esc_dobDate.select();
		return false;
	}
	
	if (document.form_profile.esc_dobDate.value >31){
		alert("Please enter correct birth date ");
		document.form_profile.esc_dobDate.select();
		return false;
	}
	
	//##################################################
	if (document.form_profile.esc_city.value == "Other")
	{
		//alert(document.form_profile.esc_incallPlace.value);
		/*if(checkBlankField(document.form_profile.esc_city_other.value)==false)
		{
			document.form_profile.esc_incallMode.value = "outcall only";
			
		}
		if (document.form_profile.esc_incallMode.value=="outcall only")
		{*/
			document.form_profile.esc_incallPlace.value = "";
			document.form_profile.esc_incallPlaceText.value = "";
		//}
	}
	//##################################################
	
	document.form_profile.submit();
}

function show_addForm()
{
	if(document.getElementById("news_img").style.display == "none")
	{
		document.getElementById("news_img").style.display = "block";
	}
	else if(document.getElementById("news_img").style.display == "block")
	{
		document.getElementById("news_img").style.display = "none";
	}
}

function showImgDiv(div_id)
{
	if(eval(document.getElementById(div_id)).style.display == "none")
	{
		eval(document.getElementById(div_id)).style.display = "block";
	}
	else if(eval(document.getElementById(div_id)).style.display == "block")
	{
		eval(document.getElementById(div_id)).style.display = "none";
	}
}

function del_escPic(picID, escID, id)
{
	if (confirm("Are you sure to delete this pic ?"))
	{
		var url = "update_escort.php?do=delpic&id=" + id + "&eID=" + escID + "&pID=" + picID;
		//alert(url);
		document.location.href = url;
	}
}

function showPics(pic)
{
	var new_pic = pic.substring(pic.lastIndexOf('#~#'), pic.length);
	new_pic = new_pic.substring(3, new_pic.length);
	if(new_pic!="") {
		document.getElementById("picID").src = new_pic;
	} else {
		document.getElementById("picID").src = "../images/comingSoon.jpg";
	}
}

function showPics_new(pic)
{
	var new_pic = pic.substring(pic.lastIndexOf('#~#'), pic.length);
	new_pic = new_pic.substring(3, new_pic.length);
	if(new_pic!="") {
		document.getElementById("picID_new").src = new_pic;
	} else {
		document.getElementById("picID_new").src = "../images/comingSoon.jpg";
	}
}

function deleteProfile(escID)
{
	if (confirm("Are you sure to delete this escort ?"))
	{
		var url = "update_escort.php?do=delesc&eID=" + escID;
		//alert(url);
		document.location.href = url;
	}
}

function sub_form_gallery_hidden()
{

if(document.frm_hidden.esc_hidden.value == ""){
	alert("please select the escorts name");
	document.frm_hidden.esc_hidden.focus();
	return false
	}
	
	var esID = document.frm_hidden.esc_hidden.value;
	//alert(esID);
	//return false;
	if (esID != "")
	{
		document.location.href = "update_escort.php?id=10000&eID=" + esID;
	}
	else
	{
		document.location.href = "escort_editor.php?id=10000";
	}
}
