// JavaScript Document// JavaScript Document

function friend_mail()
{	
	window.open("friend.php",'name','width='+545+',height='+300+',center, middle,resizable,autoSize=yes');
}

function changePassword()
{
	//alert(document.frmChangePass.txtNewPassword.value.length);
	if(document.frmChangePass.txtNewPassword.value == ""){
		alert('Please Enter Password');
		document.frmChangePass.txtNewPassword.focus();
		return false;
	}
	if (document.frmChangePass.txtNewPassword.value.length < 6) {
        alert('Password should contain minimum 6 character');
		document.frmChangePass.txtNewPassword.focus();
        return false;
    }
	var valid="1234567890";
	var upass_string = document.frmChangePass.txtNewPassword.value;
    for (var i=0; i<document.frmChangePass.txtNewPassword.value.length; i++) {
        if (valid.indexOf(upass_string.charAt(i)) < 0) {
			test = false;
        }else{
			test = true;
		}
    }
	if(test == false)
	{
		alert('Password should contain minimum 1 numeric value');
		document.frmChangePass.txtNewPassword.focus();
        return false;
	}
	if(document.frmChangePass.txtNewConPassword.value == ""){
		alert('Please Enter Retype Password');
		document.frmChangePass.txtNewConPassword.focus();
		return false;
	}
	
	
	if(document.frmChangePass.txtNewPassword.value != document.frmChangePass.txtNewConPassword.value){
		alert('Password and the re-type password value is not Same');
		document.frmChangePass.txtNewConPassword.focus();
		return false;
	}
	document.frmChangePass.action = "change_password_confirm.php";
	document.frmChangePass.submit();

}

function login_validate()
{	document.frm_login.action = "login_validate.php";	
	document.frm_login.submit();
}


function search_result()
{
	
	document.frmsearch.action = "search_result.php?page=s";
	document.frmsearch.submit();
}


function user_edit(id)
{
	document.frm_user_mgmt.user_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_user_mgmt.action = "user_add.php?user_id="+id;
	document.frm_user_mgmt.submit();
}

function user_delete(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	document.frm_user_mgmt.action = "user_delete.php?user_id="+id;
	document.frm_user_mgmt.submit();
}

function page_edit(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_page_mgmt.action = "page_add.php?page_id="+id;
	document.frm_page_mgmt.submit();
}
function page_delete(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	document.frm_page_mgmt.action = "page_delete.php?page_id="+id;
	document.frm_page_mgmt.submit();
}

function project_edit(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_project_mgmt.action = "project_add.php?project_id="+id;
	document.frm_project_mgmt.submit();
}
function project_delete(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	document.frm_project_mgmt.action = "project_delete.php?project_id="+id;
	document.frm_project_mgmt.submit();
}
function FAQ_edit(id)
{
	//alert("edit"+id);
	document.frm_faq_mgmt.action="faq_add.php?FAQ_id="+id;
	document.frm_faq_mgmt.submit();
}
function FAQ_delete(id)
{
	//alert("delete"+id);
	document.frm_faq_mgmt.action="faq_delete.php?FAQ_id="+id;
	document.frm_faq_mgmt.submit();
}
function case_edit(id)
{
	//alert("edit"+id);
	document.frm_case_mgmt.action="case_add.php?case_id="+id;
	document.frm_case_mgmt.submit();
}
function case_delete(id)
{
	//alert("delete"+id);
	document.frm_case_mgmt.action="case_delete.php?case_id="+id;
	document.frm_case_mgmt.submit();
}
function faq_cat_edit(id)
{	//alert("edit"+id);
	document.frm_faq_cat_mgmt.action="faq_cat_add.php?faq_cat_id="+id;
	document.frm_faq_cat_mgmt.submit();
}
function faq_cat_delete(id)
{
	//alert("delete"+id);
	document.frm_faq_cat_mgmt.action="faq_cat_delete.php?faq_cat_id="+id;
	document.frm_faq_cat_mgmt.submit();
}
function country_edit(country_id,page,limit)  
{  
document.frm_country_mgmt.action="country_add.php?country_id="+country_id+"&page="+page+"&limit="+limit;
	document.frm_country_mgmt.submit();
}
function country_delete(country_id,page,limit)
{    
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{  
		document.frm_country_mgmt.action="country_delete.php?country_id="+country_id+"&page="+page+"&limit="+limit;
		document.frm_country_mgmt.submit();	
	}
}

function country_save(page,limit)
{ 
	if(document.frm_country_add.country_name.value=='')
	{
		alert("Please Enter Country")
		document.frm_country_add.country_name.focus();
		return false;
	}
		document.frm_country_add.action="country_save.php?page="+page+"&limit="+limit;
		document.frm_country_add.submit();
}
function region_save(page,limit,catphoto)
{  
 if(document.frm_region_add.region_name.value=='')
	{
		alert("Please Enter Region Name")
		document.frm_region_add.region_name.focus();
		return false;
	}
document.frm_region_add.action="region_save.php?page="+page+"&limit="+limit;
		document.frm_region_add.submit();
}
function region_edit(region_id,page,limit)  
{  
document.frm_region_mgmt.action="region_add.php?region_id="+region_id+"&page="+page+"&limit="+limit;
	document.frm_region_mgmt.submit();
}
function region_delete(region_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{  
		document.frm_region_mgmt.action="region_delete.php?region_id="+region_id+"&page="+page+"&limit="+limit;
		document.frm_region_mgmt.submit();	
	}
}

function post_save(page,limit,catphoto)
{  
	if(document.frm_post_add.post_title.value=='')
	{
		alert("Please Enter Post Title")
		document.frm_post_add.post_title.focus();
		return false;
	}
	if(document.frm_post_add.post_contact_person.value=='')
	{
		alert("Please Enter Contact Person")
		document.frm_post_add.post_contact_person.focus();
		return false;
	}
	if(document.frm_post_add.post_telephone.value=='')
	{
		alert("Please Enter Telephone")
		document.frm_post_add.post_telephone.focus();
		return false;
	}
	
document.frm_post_add.action="post_save.php?page="+page+"&limit="+limit;
document.frm_post_add.submit();
}

function post_save_user(page,limit,catphoto)
{  
	if(document.frm_post_add.post_title.value=='')
	{
		alert("Please Enter Post Title")
		document.frm_post_add.post_title.focus();
		return false;
	}
	/*if(document.frm_post_add.post_desc.value=='')
	{
		alert("Please Enter Post Description")
		document.frm_post_add.post_desc.focus();
		return false;
	}*/
	if(document.frm_post_add.post_contact_person.value=='')
	{
		alert("Please Enter Contact Person")
		document.frm_post_add.post_contact_person.focus();
		return false;
	}
	if(document.frm_post_add.post_telephone.value=='')
	{
		alert("Please Enter Telephone")
		document.frm_post_add.post_telephone.focus();
		return false;
	}
	
document.frm_post_add.action="post_save.php";
document.frm_post_add.submit();
}


function information_save(page,limit)
{  	
document.frm_information_add.action="information_save.php?page="+page+"&limit="+limit;
document.frm_information_add.submit();
}

function event_save(page,limit)
{  	
document.frm_event_add.action="event_save.php?page="+page+"&limit="+limit;
document.frm_event_add.submit();
}

function post_edit(post_id,page,limit)  
{  
document.frm_post_mgmt.action="post_add.php?post_id="+post_id+"&page="+page+"&limit="+limit;
	document.frm_post_mgmt.submit();
}

function accommodation_edit(accommodation_id,page,limit)  
{  
document.frm_accommodation_mgmt.action="accommodation_add.php?accommodation_id="+accommodation_id+"&page="+page+"&limit="+limit;
	document.frm_accommodation_mgmt.submit();
}

function information_edit(information_id,page,limit)  
{  
document.frm_information_mgmt.action="information_add.php?information_id="+information_id+"&page="+page+"&limit="+limit;
	document.frm_information_mgmt.submit();
}

function event_edit(event_id,page,limit)  
{  
document.frm_event_mgmt.action="event_add.php?event_id="+event_id+"&page="+page+"&limit="+limit;
	document.frm_event_mgmt.submit();
}

function post_edit_user(post_id,page,limit,user_id)  
{  
document.frm_post_replay.action="add_post.php?post_id="+post_id+"&page="+page+"&limit="+limit+"&user_id="+user_id;
	document.frm_post_replay.submit();
}
function post_delete(post_id,page,limit,user_id)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{  
		document.frm_post_mgmt.action="post_delete.php?post_id="+post_id+"&page="+page+"&limit="+limit+"&user_id="+user_id;
		document.frm_post_mgmt.submit();	
	}
}

function post_delete_user_front(post_id,page,limit,user_id)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{   var f = 1;
		document.frm_post_user.action="admin/post_manager/post_delete.php?post_id="+post_id+"&page="+page+"&limit="+limit+"&user_id="+user_id+"&f="+f;		
		document.frm_post_user.submit();	
	}
}

function business_delete_user(business_id,page,limit,user_id)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{   var f = 1;
		document.frm_business_user.action="admin/business_manager/business_delete.php?business_id="+business_id+"&page="+page+"&limit="+limit+"&user_id="+user_id+"&f="+f;
		document.frm_business_user.submit();	
	}
}

function accommodation_delete(accommodation_id,page,limit,user_id)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{  
		document.frm_accommodation_mgmt.action="accommodation_delete.php?accommodation_id="+accommodation_id+"&page="+page+"&limit="+limit+"&user_id="+user_id;
		document.frm_accommodation_mgmt.submit();	
	}
}

function information_delete(information_id,page,limit,user_id)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{  
		document.frm_information_mgmt.action="information_delete.php?information_id="+information_id+"&page="+page+"&limit="+limit+"&user_id="+user_id;
		document.frm_information_mgmt.submit();	
	}
}

function information_delete_user(information_id,page,limit,user_id)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{   var f = 1;
		document.frm_information.action="admin/information_manager/information_delete.php?information_id="+information_id+"&page="+page+"&limit="+limit+"&user_id="+user_id+"&f="+f;
		document.frm_information.submit();	
	}
}

function event_delete(event_id,page,limit,user_id)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{  
		document.frm_event_mgmt.action="event_delete.php?event_id="+event_id+"&page="+page+"&limit="+limit+"&user_id="+user_id;
		document.frm_event_mgmt.submit();	
	}
}

function post_delete_user_(post_id,page,limit,user_id)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{   var f = 1;
	document.frm_post_replay.action="admin/post_manager/post_delete.php?post_id="+post_id+"&page="+page+"&limit="+limit+"&f="+f+"&user_id="+user_id;
		document.frm_post_replay.submit();	
	}
}
function post_replay_save(page,limit,catphoto,post_id,user_id)
{  
	document.frm_post_replay_add.action="post_replay_save.php?page="+page+"&limit="+limit+"&post_id="+post_id+"&user_id="+user_id;
	document.frm_post_replay_add.submit();
}

function post_replay_edit(post_replay_id,page,limit,post_id,user_id)  
{  
document.frm_post_replay_mgmt.action="post_replay_add.php?post_replay_id="+post_replay_id+"&page="+page+"&limit="+limit+"&post_id="+post_id+"&user_id="+user_id;
	document.frm_post_replay_mgmt.submit();
}

function post_replay_delete(post_replay_id,page,limit,post_id,user_id)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{  
		document.frm_post_replay_mgmt.action="post_replay_delete.php?post_replay_id="+post_replay_id+"&page="+page+"&limit="+limit+"&post_id="+post_id+"&user_id="+user_id;
		document.frm_post_replay_mgmt.submit();	
	}
}

function photo_edit(post_img_id,page,limit,post_id,post_by)
{
	document.frm_photo_mgmt.action="photo_add.php?post_img_id="+post_img_id+"&page="+page+"&limit="+limit+"&post_id="+post_id+"&post_by="+post_by;
	document.frm_photo_mgmt.submit();
}

function photo_accommodation_edit(accommodation_img_id,page,limit,accommodation_id,post_by)
{
	document.frm_photo_mgmt.action="photo_add.php?accommodation_img_id="+accommodation_img_id+"&page="+page+"&limit="+limit+"&accommodation_id="+accommodation_id+"&post_by="+post_by;
	document.frm_photo_mgmt.submit();
}

function photo_edit_user(post_img_id,page,limit,post_id)
{
	document.frm_photo.action="add_photo.php?post_img_id="+post_img_id+"&page="+page+"&limit="+limit+"&post_id="+post_id;
	document.frm_photo.submit();
}
function photo_delete(post_img_id,page,limit,post_id,post_by)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
	document.frm_photo_mgmt.action="photo_delete.php?post_img_id="+post_img_id+"&page="+page+"&limit="+limit+"&post_id="+post_id+"&post_by="+post_by;
		document.frm_photo_mgmt.submit();	
	}
}

function photo_delete_user_event(event_img_id)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
	document.frm_event_photo.action="event_photo_delete.php?event_img_id="+event_img_id;
		document.frm_event_photo.submit();	
	}
}

function photo_accommodation_delete(accommodation_img_id,page,limit,accommodation_id,post_by)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
	document.frm_photo_mgmt.action="photo_delete.php?accommodation_img_id="+accommodation_img_id+"&page="+page+"&limit="+limit+"&accommodation_id="+accommodation_id+"&post_by="+post_by;
		document.frm_photo_mgmt.submit();	
	}
}

function photo_delete_user(post_img_id,page,limit,post_id)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{	var f = 1;
		document.frm_photo.action="admin/photo_manager/photo_delete.php?post_img_id="+post_img_id+"&page="+page+"&limit="+limit+"&f="+f+"&post_id="+post_id;
		document.frm_photo.submit();	
	}
}

function photo_save(photo_id,photo_cat_id,page,limit,photo,photobig)
{
	if(document.frm_photo_add.photo_image_url.value=='' && photo=='')
	{
		alert("Please select photo")
		document.frm_photo_add.photo_image_url.focus();
		return false;
	}
	else if(document.frm_photo_add.photo_image_url_big.value=='' && photobig=='')
	{
		alert("Please select Big photo")
		document.frm_photo_add.photo_image_url_big.focus();
		return false;
	}
	else
	{
		document.frm_photo_add.action="photo_save.php?photo_id="+photo_id+"&photo_cat_id="+photo_cat_id+"&page="+page+"&limit="+limit;
		document.frm_photo_add.submit();
	}
}

function photo_save1(post_img_id,page,limit)
{
	
		document.frm_photo_add.action="photo_save.php?post_img_id="+post_img_id+"&page="+page+"&limit="+limit;
		document.frm_photo_add.submit();
	
}


function catPhoto_to_Photo(photo_cat_id)
{
	document.frm_FE_photo_cat.action="photo_details.php?photo_cat_id="+photo_cat_id;
	document.frm_FE_photo_cat.submit();
}
function photo_desc(photo_id)
{
	document.frm_FE_photo.action="photo_description.php?photo_id="+photo_id;
	document.frm_FE_photo.submit();
}
function favorite_delete(user_id)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_view_fav.action="favorite_delete.php?user_fav_id="+user_id;
		document.frm_view_fav.submit();	
	}
}

function check_login(form_name)
{    
	alert(form_name);
	var ans=confirm("First You have to Regiester? or If you have Register user Login First");
	if(ans==true)
	{  
		document.form_name.action="user_registration.php";
		document.form_name.submit();	
	}
	
	
}


/*--------------------------People Manger------------------------------------------------------------*/

function person_save(page,limit)
{
		document.frm_person_add.action="people_save.php?page="+page+"&limit="+limit;
		document.frm_person_add.submit();
}

function person_delete(person_id, page, limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_person_mgmt.action="people_delete.php?person_id="+person_id+"page="+page+"&limit="+limit;
		document.frm_person_mgmt.submit();	
	}
}

/*--------------------------Service Manger------------------------------------------------------------*/

function service_save(page,limit)
{
		document.frm_service_add.action="service_save.php?page="+page+"&limit="+limit;
		document.frm_service_add.submit();
}

function service_delete(service_id, page, limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_service_mgmt.action="service_delete.php?service_id="+service_id+"page="+page+"&limit="+limit;
		document.frm_service_mgmt.submit();	
	}
}
/*--------------------------Business Manger------------------------------------------------------------

function business_edit(id)
{
	document.frm_business_mgmt.business_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_business_mgmt.action = "business_mgmt.php?business_id="+id;
	document.frm_business_mgmt.submit();
}

function business_delete(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	document.frm_business_mgmt.action = "business_delete.php?business_id="+id;
	document.frm_business_mgmt.submit();
}*/
/*----------------------------------Government Manager------------------------------*/


function government_save(page,limit)
{
		document.frm_government_add.action="government_save.php?page="+page+"&limit="+limit;
		document.frm_government_add.submit();
}

function useful_number_save(page,limit)
{
		document.frm_useful_number_add.action="useful_number_save.php?page="+page+"&limit="+limit;
		document.frm_useful_number_add.submit();
}
function newsletter_save(page,limit)
{
		document.frm_newsletter_add.action="newsletter_save.php?page="+page+"&limit="+limit;
		document.frm_newsletter_add.submit();
}


function Inint_AJAX() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest(); } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
};
function get_news_type(id)
{  
	//alert("call javascript"+id+"iiouiouoiu"+property_id);
    var req = Inint_AJAX();
     //alert(src);alert(val);
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
					//alert(req.responseText);
                    document.getElementById("news_type").innerHTML=req.responseText; //retuen value
						//document.frmProperty.submit();
               } 
          }
     }; 
		 req.open("GET", "news_home_page.php?news_type="+id); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
	
}

function popup_form(post_img_id)
	{			
		window.open("popup_photo_view.php?post_img_id="+post_img_id);
	}
	

function printpreview()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 1 - open window
* 4 - Save As
*/
var PROMPT = 1; // 2 DONTPROMPTUSER
 var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';

window.print();
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
}

function friend_mail(urlname)
{	
	window.open("friend.php?url_name="+urlname,'name','width='+545+',height='+300+',center, middle,resizable,autoSize=yes');
}

function news_save(page,limit)
{ 
	if(document.frm_news_add.news_title.value=='')
	{
		alert("Please Enter News Title")
		document.frm_news_add.news_title.focus();
		return false;
	}
	

	
	if(document.frm_news_add.post_date.value=='')
	{
		alert("Please Enter News Date")
		document.frm_news_add.post_date.focus();
		return false;
	}

		document.frm_news_add.action="news_save.php?page="+page+"&limit="+limit;
		document.frm_news_add.submit();
		
}

function page_save(page,limit)
{	
	/*if(document.frm_page_add.page_desc.value=='')
	{
		alert("Please Enter Page Description")
		document.frm_page_add.page_desc.focus();
		return false;
	}*/
	if(document.frm_page_add.page_name.value=='')
	{
		alert("Please Enter Page Name")
		document.frm_page_add.page_name.focus();
		return false;
	}
	else
	{
		document.frm_page_add.action="page_save.php?page="+page+"&limit="+limit;
		document.frm_page_add.submit();
	}
}

function pdf_check()
{ 	
	if(document.frm_project_add.project_name.value=='')
	{
		alert("Please Enter Project Name")
		document.frm_project_add.project_name.focus();
		return false;
	}
	
	if(document.frm_project_add.project_pdf_url.value!='')
	{
	if((document.frm_project_add.project_pdf_url.value.lastIndexOf(".pdf")==-1)) {
	   alert("Please upload only .pdf extention file");
	   return false;
	}
	
	}
	
		document.frm_project_add.action="project_save.php";
		document.frm_project_add.submit();
	
}

