// JavaScript Document
//Alert message for deleting admin user

function deleteAdmin(id) {
	if(confirm("Are you sure you want to delete the Admin?")) {
	    document.form1.action="admin.php?action=delete&id="+id;
		document.form1.submit();
 	}  
}

// redirect patient
function redirectpatientss(id,name)
{
	window.parent.location.href= "patient_details.php?patid="+id+"&patname="+name;
}

// Req field
function WebValidate(txtCtrl, val) 
{
	//alert(txtCtrl);
	var ctrName = val;
 	if (txtCtrl.value.indexOf("www") < 0 || txtCtrl.value.indexOf(".") < 0) 
	{ 
		alert("Please enter valid " + ctrName + ".\t\n eg: www.domainname.com");
		txtCtrl.focus();	   	
		return false;
	}		
	if(txtCtrl.value.indexOf("'") > -1)
	{
		alert("Please Don't enter ' in " + ctrName + ".");		
		txtCtrl.focus();   	
		return false;
	}			
}

function movieValidate() {
	if(SelectValidate(document.frmmovie.language, "Language")==false) { return false; }
 	if(TextValidate(document.frmmovie.name,"Movie Name")==false) { return false; }
	if(TextValidate(document.frmmovie.folder,"Folder Name")==false) { return false; }
	/*
	if(TextValidate(document.frmmovie.banner,"Banner")==false) { return false; }
	if(TextValidate(document.frmmovie.cast,"Cast")==false) { return false; }
	if(TextValidate(document.frmmovie.direction,"Direction")==false) { return false; }
	if(TextValidate(document.frmmovie.production,"Production")==false) { return false; }
	if(TextValidate(document.frmmovie.music,"Music")==false) { return false; }
	*/
	if(document.frmmovie.action1.value == "Add"){
		document.frmmovie.action = "movie.php?status=submit";		
	}else{
		document.frmmovie.action = "movie.php?status=submit&action1=edit";
	}
	document.frmmovie.submit();
}

function previewValidate() {
	if(SelectValidate(document.frmpreview.movie, "Movie")==false) { return false; }
 	
	if(document.frmpreview.action1.value == "Add"){
		document.frmpreview.action = "preview.php?status=submit";		
	}else{
		document.frmpreview.action = "preview.php?status=submit&action1=edit";
	}
	document.frmpreview.submit();
}

function reviewValidate() {
	if(SelectValidate(document.frmreview.movie, "Movie")==false) { return false; }
 	
	if(document.frmreview.action1.value == "Add"){
		document.frmreview.action = "review.php?status=submit";		
	}else{
		document.frmreview.action = "review.php?status=submit&action1=edit";
	}
	document.frmreview.submit();
}

function newsValidate() {
	if(TextValidate(document.frmnews.news_heading,"Heading")==false) { return false; }
	if(TextValidate(document.frmnews.news_date,"Date")==false) { return false; }
 	
	if(document.frmnews.action1.value == "Add"){
		document.frmnews.action = "news.php?status=submit";		
	}else{
		document.frmnews.action = "news.php?status=submit&action1=edit";
	}
	document.frmnews.submit();
}

function musicValidate() {
	if(SelectValidate(document.frmmusic.movie, "Movie")==false) { return false; }
 	
	if(document.frmmusic.action1.value == "Add"){
		document.frmmusic.action = "music_review.php?status=submit";		
	}else{
		document.frmmusic.action = "music_review.php?status=submit&action1=edit";
	}
	document.frmmusic.submit();
}


function artistValidate() {
	if(SelectValidate(document.frmartist.language, "Language")==false) { return false; }
	if(SelectValidate(document.frmartist.artist, "Artist")==false) { return false; }
 	if(TextValidate(document.frmartist.name,"Artist Name")==false) { return false; }
	if(TextValidate(document.frmartist.folder,"Folder Name")==false) { return false; }
	
	if(document.frmartist.action1.value == "Add"){
		document.frmartist.action = "artist.php?status=submit";		
	}else{
		document.frmartist.action = "artist.php?status=submit&action1=edit";
	}
	document.frmartist.submit();
}

function eventsValidate() {
	if(SelectValidate(document.frmevents.language, "Language")==false) { return false; }
 	if(TextValidate(document.frmevents.name,"Event Name")==false) { return false; }
	if(TextValidate(document.frmevents.folder,"Folder Name")==false) { return false; }
	
	if(document.frmevents.action1.value == "Add"){
		document.frmevents.action = "events.php?status=submit";		
	}else{
		document.frmevents.action = "events.php?status=submit&action1=edit";
	}
	document.frmevents.submit();
}


function eventsVideoValidate() {
	if(SelectValidate(document.frmevents.event_id, "Event")==false) { return false; }
 	if(TextValidate(document.frmevents.name,"Event Title")==false) { return false; }
	
	if(document.frmevents.action1.value == "Add"){
		document.frmevents.action = "events_video.php?status=submit";		
	}else{
		document.frmevents.action = "events_video.php?status=submit&action1=edit";
	}
	document.frmevents.submit();
}

// Alert message for deleting Product

function productDelete(id) {
	if(confirm("Are you sure you want to delete?")) {
	    document.form1.action="products.php?action1=delete&status=submit&id="+id;
		document.form1.submit();
 	}  
}
function adminValidate() {
	if(SelectValidate(document.frmadmin.seladminsalutation," salutation")==false) { return false;	}
	if(TextValidate(document.frmadmin.txtadminname," Admin name")==false) { return false;	}
 	if(TextValidate(document.frmadmin.txtadminemail," email")==false) { return false;	}
	if(EmailValidate(document.frmadmin.txtadminemail," email")==false) { return false;	}
	if(TextValidate(document.frmadmin.txtadminusername," username")==false) { return false;	}
	if(TextValidate(document.frmadmin.pwdadminpassword," password")==false) { return false;	}
	if(TextValidate(document.frmadmin.pwdadminconfirmpassword," confrim password")==false) { return false;}
   	if(document.frmadmin.pwdadminconfirmpassword.value != document.frmadmin.pwdadminpassword.value){
		alert("Your password and confirm password does not match.");
		document.frmadmin.pwdadminconfirmpassword.focus();
		return false;
	}
	document.frmadmin.action = "admin.php";
	document.frmadmin.submit();
}


// To validate change password form fields

function changePwdvalidate()
{
	var form_name=document.frmpassword;
	if(TextValidate(form_name.old_password,"Old Password")==false){return false;}
	if(TextValidate(form_name.new_password,"New Password")==false){return false;}
	if(TextValidate(form_name.confirm_password,"Confirm Password")==false){return false;}
	if(Comparetextboxes(form_name.new_password,form_name.confirm_password)==false){return false;}
	//document.frmpassword.action = "admin_home.php";
	//document.frmpassword.submit();
}

var myWindow;

function popupWindow(url, width, height) {
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status,location=0,resizable,location=no,resizable=no,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    myWindow = window.open(url, "subWind", windowFeatures);
}

function feedbackValidation() {
 	if(TextValidate(document.feedback.name,"Movie Name")==false) { return false; }	
	if(EmailValidate(document.feedback.email,"Email")==false) { return false; }
	
	document.feedback.submit();
}

