
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function validate_search_zipcode(frm){
	/*if(!isValidZipcode(frm.zipcode,'yes'))
	return false;*/
}

function validate_newsletter_member(frm){
	if(!isValidEntry(frm.name, "Name"))
	return false;
	if(!isValidEmail(frm.email, 'yes'))
	return false;
	if(!validateCanadaZip(frm.zipcode) && !validUSZip(frm.zipcode)){
		alert("Invalid zipcode");
		frm.zipcode.focus();
	return false;
	}
}
function validate_memadd(frm){
	
	
	

	if(!isValidEntry(frm.userid, "Unique ID"))
	return false;
	if(!isValidEntry(frm.Name, "Name"))
	return false;
	
	if(!isValidTextarea(frm.address,"Address",500))
	return false;
	
	if(!validateCanadaZip(frm.zipcode) && !validUSZip(frm.zipcode)){
		alert("Invalid zipcode");
		frm.zipcode.focus();
	return false;
	}
	
	/*if(frm.country.value=="Select Country Name" || frm.country.value==0 ){
		alert("Select Country Name");
		frm.country.focus();
		return false;
	}
	if(frm.state.style.display=="block"){
			if(frm.state.value==""){
				alert("Select State from the list");
				frm.state.focus();
				return false;
			}
	}else{
			if(!isValidEntry(frm.state_txt,"State/Province"))
			return false;
			}
	
	if(frm.city.style.display=="block"){
			if(frm.city.value==""){
				alert("Select city from the list");
				frm.city.focus();
				return false;
			}
	}else{
			if(!isValidEntry(frm.city_txt,"City"))
			return false;
			}		*/
	/*if(!isValidZipcode(frm.zipcode, 'yes'))
	return false;*/
	if(!isValidPhone(frm.phone, "Phone", 'yes'))
	return false;
	
	if(!isValidEmail(frm.email, "yes"))
	return false;
	
	
	
	frm.kw.value="addnewmember";
	
	if(frm.id.value)
	frm.action="provider_register_edit.php";
	else 
	frm.action="member_add.php";
	
	
}

function validate_listadd(frm){
	var j=0;
	
	if(!isValidEntry(frm.name, "Cemetery Name"))
	return false;
	if(!isValidTextarea(frm.address,"Cemetery Address", 300))
	return false;
	//if(frm.country.value=="Select Country Name" || frm.country.value==0 ){
//		alert("Select Country Name");
//		frm.country.focus();
//		return false;
//	}
//	if(frm.state.style.display=="block"){
//			if(frm.state.value==""){
//				alert("Select State from the list");
//				frm.state.focus();
//				return false;
//			}
//	}else{
//			if(!isValidEntry(frm.state_txt,"State/Province"))
//			return false;
//			}
//	
//	if(frm.city.style.display=="block"){
//			if(frm.city.value==""){
//				alert("Select city from the list");
//				frm.city.focus();
//				return false;
//			}
//	}else{
//			if(!isValidEntry(frm.city_txt,"City"))
//			return false;
//			}
	/*if(!isValidZipcode(frm.zip, 'yes'))
	return false;*/
	if(!validateCanadaZip(frm.zip) && !validUSZip(frm.zip)){
		alert("Invalid zipcode");
		frm.zip.focus();
	return false;
	}
	if(!isValidEntry(frm.email, "Email"))
	return false;
	if(!isValidEntry(frm.phone, "Phone Number"))
	return false;
	
	if(!isValidEntry(frm.listingId, "Listing Id (CPLS)"))
	return false;
	if(!isValidTextarea(frm.l_desc,"Legal Description", 300))
	return false;
	
	/*if(!isValidEntry(frm.b_space, "Number of Burial Space"))
	return false;*/
	
	if(frm.type.value=="Others" && frm.type_txt.value==""){
		alert("Select Type From The List or Enter New Type");
		frm.type_txt.focus();
		return false;
	}
	if(frm.internment.value=="Others" && frm.internment_txt.value==""){
		alert("Select Internment From The List or Enter New Internment");
		frm.internment_txt.focus();
		return false;
	}
	if(frm.transfer.value=="Others" && frm.transfer_txt.value==""){
		alert("Select Transfer From The List or Enter New Transfer");
		frm.transfer_txt.focus();
		return false;
	}
	if(frm.payment.value=="Others" && frm.payment_txt.value==""){
		alert("Select Payment From The List or Enter New Payment");
		frm.payment_txt.focus();
		return false;
	}
	
	/*for(var i=0;i<frm.radiobutton.length;i++){
		if(frm.radiobutton[i].checked==true)
		j=1;
	}
	
	if(j==0){
		alert("Select Package");
		return false;
	}
	*/
	frm.kw.value="addcemeterylisting_nw";
	frm.action="addlisting.php";
	
}
function sel_country(obj){
	//alert(obj.value);
	var linkname="sel_country.php?zip="+obj.value;
	show_page(linkname,"sel_county");
	
}
function sel_userid(){
	var obj=document.getElementById("userid");
	if(obj.value!=""){
	var linkname="check_user.php?id="+obj.value;
	show_page(linkname,"usercheckspan");
	}
	else{
		alert ("Please Enter Unique Id");
		obj.focus();
		return false;
	}
}


function show_hide_logo(obj){
	var target=document.getElementById("logotable");
	if(obj.checked==true)
		target.style.display="block";
	else
		target.style.display="none";
	
}
function show_other(obj, tar_obj){
	var element=document.getElementById(tar_obj);
	if(obj[obj.selectedIndex].value=="Others"){
		element.style.display="block";
		element.focus();
	}
	else
		element.style.display="none";
}

function select_list(obj, val){
	obj_id=document.getElementById(obj);
	var ind;
	alert(val);
	for(i=0;i<obj_id.length;i++){
		
		if(obj_id[i].value==val)
		ind=i;
	}
	obj_id.selectedIndex=ind;
	
					if(obj_id.id=="country")
					listboxItemSelected('country','state');
					if(obj_id.id=="state")
					listboxItemSelected('state','city');
	
}

function submit_innerpage(linkname){

	var agt    = navigator.userAgent.toLowerCase();
	var is_ie  = (agt.indexOf('msie') !=-1);
	var is_ie5 = (agt.indexOf('msie 5') != -1);
	var xmlhttp =null;
	
	 function handle_do_search ()
	 {
		if (xmlhttp.readyState == 4)//request completed
		{
				element = document.getElementById("content");
				element.innerHTML = xmlhttp.responseText;
		}
	}
	if (is_ie)
	{
		var control = (is_ie5) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP";
		try
		{
				xmlhttp = new ActiveXObject(control);
				xmlhttp.onreadystatechange = handle_do_search;
		} catch(e)
		{
				alert("You Need To Enable Active Scripting and ActiveX Controls");
		}
	}
	else
	{
		xmlhttp = new XMLHttpRequest();
		xmlhttp.onload = handle_do_search;
		xmlhttp.onerror = handle_do_search;
	}
	xmlhttp.open('GET',linkname, true);
	xmlhttp.send(null);
	
}

function show_page(linkname, obj){

	var agt    = navigator.userAgent.toLowerCase();
	var is_ie  = (agt.indexOf('msie') !=-1);
	var is_ie5 = (agt.indexOf('msie 5') != -1);
	var xmlhttp =null;
	
	 function handle_do_search ()
	 {
		if (xmlhttp.readyState == 4)//request completed
		{
				element = document.getElementById(obj);
				element.innerHTML = xmlhttp.responseText;
		}
	}
	if (is_ie)
	{
		var control = (is_ie5) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP";
		try
		{
				xmlhttp = new ActiveXObject(control);
				xmlhttp.onreadystatechange = handle_do_search;
		} catch(e)
		{
				alert("You Need To Enable Active Scripting and ActiveX Controls");
		}
	}
	else
	{
		xmlhttp = new XMLHttpRequest();
		xmlhttp.onload = handle_do_search;
		xmlhttp.onerror = handle_do_search;
	}
	xmlhttp.open('GET',linkname, true);
	xmlhttp.send(null);
	
}

function take2pay(paytype){
	
	var frm=document.listing_fetatures;
	
	if(paytype=="paypal"){
		
		frm.kw.value=paytype;	
		
	}
	else if(paytype=="linkpt"){
			frm.kw.value=paytype;
	}
	else{
		alert("Invalid Payment Option");
		return false;
	}
	frm.action="paymentpage.php";
	frm.submit();
	
}



function validate_contact(frm){


if(!isValidEntry(frm.username, "User Name"))
return false;
if(!isValidEmail(frm.emaiaddress,'yes'))
return false;
if(!isValidEntry(frm.comments, "Comments"))
return false;

frm.kw.value="sendmail";
frm.action="contactus.php";

}
function select_list(obj, val){
	obj_id=document.getElementById(obj);
	var ind;
	
	for(i=0;i<obj_id.length;i++){
		
		if(obj_id[i].value==val)
		ind=i;
	}
	obj_id.selectedIndex=ind;
	
					if(obj_id.id=="country")
					listboxItemSelected('country','state');
					if(obj_id.id=="state")
					listboxItemSelected('state','city');
	
}
function validate_login(frm){
	if(!isValidEntry(frm.username,"Username"))
	return false;
	if(!isValidEntry(frm.password,"Password"))
	return false;

}

function user_registration(frm){
	var check=0;
	var dir="";
	for(i=0;i<frm.user_type.length;i++){
		if(frm.user_type[i].checked==true){
			check=1;
			if(frm.user_type[i].value=="user")
				dir="user_register.php";
			if(frm.user_type[i].value=="provider")
				dir="provider_register.php";
		}
			
	}
	if(check==0 || !dir){
		alert("Select User or Provider");
		return false;
	}
	frm.action=dir;
	frm.submit();
	//provider_register.php
}


function validate_useradd(frm){
	
	
	if(!isValidEntry(frm.userid, "Unique ID"))
	return false;
	
	if(!isValidEntry(frm.Name, "Name"))
	return false;
	
	if(!isValidTextarea(frm.address,"Address",500))
	return false;

	
	//if(frm.country.value=="Select Country Name" || frm.country.value==0 ){
//		alert("Select Country Name");
//		frm.country.focus();
//		return false;
//	}
//	if(frm.state.style.display=="block"){
//			if(frm.state.value==""){
//				alert("Select State from the list");
//				frm.state.focus();
//				return false;
//			}
//	}else{
//			if(!isValidEntry(frm.state_txt,"State/Province"))
//			return false;
//			}
//	
//	if(frm.city.style.display=="block"){
//			if(frm.city.value==""){
//				alert("Select city from the list");
//				frm.city.focus();
//				return false;
//			}
//	}else{
//			if(!isValidEntry(frm.city_txt,"City"))
//			return false;
//			}		
	/*if(!isValidZipcode(frm.zipcode, 'yes'))
	return false;*/
	
	if(!isValidPhone(frm.phone, "Phone", 'yes'))
	return false;
	
	if(!isValidEmail(frm.email, "yes"))
	return false;
	
	
	
	frm.kw.value="addnewmember";
	//frm.action="user_register.php";
	
	
	
	if(frm.id.value)
	frm.action="user_mesg.php";
	else 
	frm.action="user_register.php";
	
	
}

function add2cart(frm){
	frm.action="payment_recurring.php";
	frm.kw.value="add2thecart";
	frm.submit();
}
function renewal_list(frm){
	var i=-1;
	for(j=0;j<frm.packages.length;j++){
		if(frm.packages[j].checked==true){
		i=j;
		
		}
	}

	if(i==-1){
		alert("Select any packages from the list");
		return false;
	}
	else{
		
	
	
	frm.action="renewal_pay.php";
	frm.submit();
	}
}


function regpro(val){

	var frm=document.mem_add;
	frm.kw.value="add2thecart";
	
	if(val=="bold")
	frm.che_bold.value=1;
	else if(val=="email")
	frm.che_email.value=1;
	else if(val=="url")
	frm.che_url.value=1;
	else if(val=="logo")
	frm.che_logo.value=1;
	/*window.open("logo_sel.php?id="+id+),"My Window",
					'width=400,height=200,resizable=no,status=no,toolbar=no,status=no,menubar=no,scrollbars=no');*/
	
	
	frm.action="provider_registercom.php";
	frm.submit();
	
}




function validate_changepwd (frm){
	//alert(frm.name);
	if(!isValidEntry(frm.Old_pwd,"Old Password"))
	return false;
	
	if(!isValidEntry(frm.New_pwd,"New Password"))
	return false;
	
	if(!isValidConfirmPassword(frm.New_pwd, frm.confirm_pwd))
	return false;
	//alert(frm.name);
	frm.kw.value="ch_password";
	
	//frm.action="change_pwd_user.php";
//	frm.action="change_pwd_provider.php";
}

function validate_messpost(frm){
	if(!isValidEntry(frm.mess_name,"Name"))
	return false;
	if(!isValidEmail(frm.mess_email))
	return false;
	if(!isValidTextarea(frm.message,"Message",2000))
	return false;
	frm.kw.value="sendmessage";
	frm.action="list_details.php";
	
}
function addwish(id){
	var frm=document.list_details;
	frm.id.value=id;
	frm.kw.value="add2wishlist";
	frm.submit();
	
	
}

function delwish(id){
	var frm=document.watch_list;
	
	var con=confirm("Do You Want To Delete Selected Listing(s) From Watch List");
	if(con){
	frm.id.value=id;
	frm.kw.value="del4wishlist";
	
	frm.submit();
	}
	
}


function addlist(id){
	var frm=document.mem_add;
	frm.id.value=id;
	frm.kw.value="addlist";
	
	frm.submit();
	}
	
	
	function del_wish(id){
	var frm=document.mem_add;
	
	var con=confirm("Do You Want To Delete Selected Record(s)");
	if(con){
			
	frm.id.value=id;
	frm.kw.value="del_wish";
	
	frm.action="provider_manageplots.php";
	frm.submit();
	}
	else{
		return false;
	}
	

	}
	
	function ch_image(photo,id){
		
		window.open("popup_window.php?id="+id+"&photo="+photo,"My Window",'width=400,height=200,resizable=no,status=no,toolbar=no,status=no,menubar=no,scrollbars=no');
		
	
	}
		
	function ch_logo(id){
		
		window.open("logo_popup_window.php?id="+id,"",'width=400,height=200,resizable=no,status=no,toolbar=no,status=no,menubar=no,scrollbars=no');
		
	
	}
		
	
function pg_redirect(pg){
	window.location=pg;
}


function show_map(id){
	window.open("mapquest.php?id="+id,'',"width=620,height=450,resizable=no,status=no,toolbar=no,menubar=no,scrollbars=yes");
}
function show_googlemap(id){
	window.open("maps.php?id="+id,'',"width=650,height=500,resizable=no,status=no,toolbar=no,menubar=no,scrollbars=yes");
}
function show_googlemap4provider(id){
	window.open("maps_providers.php?id="+id,'',"width=650,height=500,resizable=no,status=no,toolbar=no,menubar=no,scrollbars=yes");
}

function view_videopopup(id){
	window.open("video.php?id="+id,'',"width=620,height=450,resizable=yes,status=no,toolbar=no,menubar=no,scrollbars=no");
}

function ch_video(video,id){
		
		window.open("change_video.php?id="+id+"&video="+video,"My Window",'width=400,height=200,resizable=no,status=no,toolbar=no,status=no,menubar=no,scrollbars=no');
		
	
	}
function preloader(){
		alert("0000000000000000011111111");
}


function purchase_ebook(bk){
	var frm=document.ebook;
	frm.kw.value="purchasenow";
	frm.ebook.value=bk;
	frm.action="purchase_now.php";
	frm.submit();
}

function sendemail(bck){
	var frm=document.ebook;
	if(!isValidEntry(frm.name,"Name")) return false;
	if(!isValidEmail(frm.email, 'yes')) return false;
	frm.kw.value="emailebook";
	frm.ebook.value=bck;
	frm.action="sendemail_ebook.php";
	frm.submit();
	
}

function valid(site){
	frm=document.ebook;
	if(!isValidEntry(frm.fname,"Name")) return false;
	if(!isValidEmail(frm.email, 'yes')) return false;
	/*frm.kw.value="sendadd";
	frm.submit();*/
	var linkname="freeend.php?fname="+frm.fname.value+"&email="+frm.email.value+"&site="+site;
	show_page(linkname,"usercheckspan");
}