function validatePhone(fld) {

	alert(fld);

    var error = "";

    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    



   if (fld.value == "") {

        error = "You didn't enter a phone number.\n";

        fld.style.background = 'Yellow';

    } else if (isNaN(parseInt(stripped))) {

        error = "The phone number contains illegal characters.\n";

        fld.style.background = 'Yellow';

    } else if (!(stripped.length == 10)) {

        error = "The phone number is the wrong length. Make sure you included an area code.\n";

        fld.style.background = 'Yellow';

    }

    return error;

}





function ValidPhone(aphone)

{

	var valid = "0123456789";



/*		if(aphone=="")

		{

		alert("Please Enter your phone number...")

		return false

		}*/

		

//		if(aphone.length != 10)



/*		if(aphone.length < 13)

		{

		alert("Invalid phone number! Please try again.")

		return false

		}*/

		

		if(aphone !="")	{		

		for (var i=0; i < aphone.length; i++)

		{

		temp = "" + aphone.substring(i, i+1);

		

		

			if (valid.indexOf(temp) == "-1") 

			{

			alert("Invalid characters in your phone.  Please try again.")

			return false;

			}

		}

	}	

	

		return true

}



function valid_date(field)

{

	if(field=="")

	{

	alert("Date of Birth required field!")

	return false;

	}





	var valid = "0123456789/";

	var slashcount = 0;



	if (field.length!=10) 

	{

	alert("Invalid date! The correct date format is like '01/01/2009'.   Please try again.")

	return false;

	}

		for (var i=0; i < field.length; i++)

		 {

		temp = "" + field.substring(i, i+1);

		if (temp == "/") 

		slashcount++;

			if (valid.indexOf(temp) == "-1") 

			{

			alert("Invalid characters in your date.  Please try again.")

			return false;

			}

		if (slashcount > 2) 

		{

		alert("Invalid Date!  The slash character should be used with a properly formatted 8 digits like  '01/01/2009'.   Please try again.")

		return false;

  		 }

		if((field.charAt(2)!= '/')||(field.charAt(5) != '/'))

		{

		alert("Invalid date! The slash character should be used with a properly formatted 8 digits like  '01/01/2009'.   Please try again.")

		return false;

		}

	}

	return true;





}



function valid_required(field)

{

	if(field=="") 

	{

	return false;

	}



	return true;

}



function nationality_required(field)

{

	if(field=="Select your nationality") 

	{

	return false;

	}



	return true;

}





function children_required(field)

{

	if(field=="") 

	{

	return false;

	}



	return true;

}



function title_required(field)

{

	if(field=="Select your title") 

	{

	return false;

	}



	return true;

}



function roomtype_required(field)

{

	if(field=="Room Type") 

	{

	return false;

	}



	return true;

}



function payment_required(field)

{

	if(field=="Form of Payment") 

	{

	return false;

	}



	return true;

}



function number_required(field)

{

	var valid = "0123456789";

		for (var i=0; i < field.length; i++)

		{

		temp = "" + field.substring(i, i+1);

		

		

			if (valid.indexOf(temp) == "-1") 

			{

//			alert("Invalid characters in your phone.  Please try again.")

			return false;

			}

		}

	return true;

}



function EmailValid(email)

	{

		if(email=="")

		{

		alert("Please Enter Email...")

		return false

		}

		len = email.length

		

		if((email.charAt(1)=='@')||(email.charAt(1)=='.'))

		{

		alert("Invalid Email Please try again!")

		return false

		}

		if((email.charAt(len-2)=='@')||(email.charAt(len-2)=='.'))

		{

		alert("Invalid Email Please try again!")

		return false

		}

		

				



		count=0

		dotcount=0

	for (i=0; i< email.length; i++)

		{

			if(email.charAt(i)=='@')

			count++

			if(email.charAt(i)=='.')

			dotcount++

		 }

		

			 if((count !=1)||(dotcount !=1))

			 	{

			 	alert("Invalid Email Please try again!")

			 	return false

			 	}

		

		

	return true

	}



function showChild(){

//			x = document.getElementById(child_num);



			x=document.frmHotelShow.child_num;

			alert(x);

			x.readonly;

			x1 = document.getElementById(child_age);

			x1.style.display = "block";



	return true;



}





/*function ValidatePhone(){

p=p1.value

if(p.length==3){

	//d10=p.indexOf('(')

	pp=p;

	d4=p.indexOf('(')

	d5=p.indexOf(')')

	if(d4==-1){

		pp="("+pp;

	}

	if(d5==-1){

		pp=pp+")";

	}

	//pp="("+pp+")";

	document.frmPhone.txtphone.value="";

	document.frmPhone.txtphone.value=pp;

}

if(p.length>3){

	d1=p.indexOf('(')

	d2=p.indexOf(')')

	if (d2==-1){

		l30=p.length;

		p30=p.substring(0,4);

		//alert(p30);

		p30=p30+")"

		p31=p.substring(4,l30);

		pp=p30+p31;

		//alert(p31);

		document.frmPhone.txtphone.value="";

		document.frmPhone.txtphone.value=pp;

	}

	}

if(p.length>5){

	p11=p.substring(d1+1,d2);

	if(p11.length>3){

	p12=p11;

	l12=p12.length;

	l15=p.length

	//l12=l12-3

	p13=p11.substring(0,3);

	p14=p11.substring(3,l12);

	p15=p.substring(d2+1,l15);

	document.frmPhone.txtphone.value="";

	pp="("+p13+")"+p14+p15;

	document.frmPhone.txtphone.value=pp;

	//obj1.value="";

	//obj1.value=pp;

	}

	l16=p.length;

	p16=p.substring(d2+1,l16);

	l17=p16.length;

	if(l17>3&&p16.indexOf('-')==-1){

		p17=p.substring(d2+1,d2+4);

		p18=p.substring(d2+4,l16);

		p19=p.substring(0,d2+1);

		//alert(p19);

	pp=p19+p17+"-"+p18;

	document.frmPhone.txtphone.value="";

	document.frmPhone.txtphone.value=pp;

	//obj1.value="";

	//obj1.value=pp;

	}

}

//}

setTimeout(ValidatePhone,100)

}





function getIt(m){



n=m.name;

//	alert(n);

//p1=document.forms[0].elements[n]

p1=m

//	alert(p1);



//ValidatePhone()

testphone(p1);

}



function testphone(obj1){

p=obj1.value

alert(p)

p=p.replace("(","")

p=p.replace(")","")

p=p.replace("-","")

p=p.replace("-","")

alert(isNaN(p))

if (isNaN(p)==true){

alert("Check phone");

return false;

}

}*/





// Banana Js Script New insert  ***************************************************************



function check_form_add2filed(){

   var dc=document.form_add;

   if(dc.name_ad.value==""){

	   alert('Filed empty');

	   dc.name_ad.focus();

       return false;

    }

	if(dc.name_ad_th.value==""){

	   alert('Filed empty');

	   dc.name_ad_th.focus();

       return false;

    }



}





var gFiles = 0;

function addstdFile2() {

var li = document.createElement('div');

var i ,n;

li.setAttribute('id', 'file-' + gFiles);

 li.innerHTML = '<input type="file" name="photo[]" id="photo[]" > Photo Title <input type="text" name="photo_alt[]" id="photo_alt[]" />&nbsp;<span onclick="removestdFile2(\'file-' + gFiles + '\')" style="cursor:pointer;">Remove</span>';

document.getElementById('files-root2').appendChild(li);

gFiles++;

}



 function removestdFile2(aId) {

	var obj = document.getElementById(aId);

	obj.parentNode.removeChild(obj);

}  





function validate_form_tour(){

  var dc=document.form_add_tour;

  mesage=""; 

  //dc.tour_code_name.focus(); 

  if(dc.tour_code_name.value==""){  dc.tour_code_name.className='border_color_error'; mesage +="Tour Code \r\n";   }

  if(dc.tour_name.value==""){  dc.tour_name.className='border_color_error'; mesage +="Error Tour Name \r\n"; }

  if(dc.tour_status.value==""){  dc.tour_status.className='border_color_error'; mesage +="Error Tour Status \r\n"; }

  if(dc.supplier.value==""){  dc.supplier.className='border_color_error'; mesage +="Error Supplier \r\n";}

  if(dc.tour_duration.value==""){  dc.tour_duration.className='border_color_error'; mesage +="Error Tour Duration \r\n";}

  if(dc.tour_location.value==""){  dc.tour_location.className='border_color_error'; mesage +="Error Tour location \r\n"; }

  if(dc.tour_start_location.value==""){  dc.tour_start_location.className='border_color_error'; mesage +="Error tour_start_location \r\n"; }

  if(mesage!=""){

   alert(mesage);

   return false;

}else{

   return true;

 }



 }

 function check_form_day_add(){

   var dc=document.day_add;

 mesage="";

  if(dc.day_name.value==""){  dc.day_name.className='border_color_error'; mesage +="Pease input day name  \r\n";   }
  
  if(dc.day_name_th.value==""){  dc.day_name_th.className='border_color_error'; mesage +="Pease input day name TH \r\n";   }

  if(dc.hotel_code.value==""){  dc.hotel_code.className='border_color_error'; mesage +="Pease Select hotel \r\n";   }





	 if(mesage!=""){

	   alert(mesage);

	   return false;

	}else{

	   return true;

	 }

}