// JavaScript Document
//var message = "disabled"; 
//	function rtclickcheck(keyp){ if (navigator.appName == "Netscape" && keyp.which == 3){ 	alert("disabled"); return false; } 
//	if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) { 	alert("disabled");  return false; } } 
//	document.onmousedown = rtclickcheck; -->




function validate_addalbum(form) 
	{ 
		if (!document.frmAlbum.agree.checked) 
			{
	 			alert("Please Read the guidlines and check the box   ."); 
	 			return false; 
			} 
		if(document.frmAlbum.txtName.value.length ==0)
 			{
				alert("Please enter an album name..");
				document.frmAlbum.txtName.focus ();
				return false; 
			}
		if(document.frmAlbum.text.value.length < 1 )
					{
					  alert("Please enter security code.");
					  document.frmAlbum.text.focus();
					  return false; 
					}
		if(document.frmAlbum.fleImage.value.length ==0)
 			{
				alert("Please select an image for the album..");
				document.frmAlbum.fleImage.focus ();
				return false; 
			}
				return true;
	}
	
function validate_addimage(form) 
	{ 
		if (!document.frmAlbum.agree.checked) 
			{
	 			alert("Please Read the guidlines and check the box   ."); 
	 			return false; 
			}
		if(document.frmAlbum.txtTitle.value.length ==0)
 			{
				alert("Please enter image title..");
				document.frmAlbum.txtTitle.focus ();
				return false; 
			}
		if(document.frmAlbum.text.value.length < 1 )
					{
					  alert("Please enter security code.");
					  document.frmAlbum.text.focus();
					  return false; 
					}
		if(document.frmAlbum.fleImage.value.length ==0)
 			{
				alert("Please select an image..");
				document.frmAlbum.fleImage.focus ();
				return false; 
			} 
				return true;
	}
function validate_modifyimage(form) 
	{ 
		if(document.frmAlbum.fleImage.value.length !='')
		 {
			var pathLength1 = document.frmAlbum.fleImage.value.length;
			var lastDot1 = document.frmAlbum.fleImage.value.lastIndexOf(".");
			var fileType1 = document.frmAlbum.fleImage.value.substring(lastDot1,pathLength1);
			
			if((fileType1 != ".gif") && (fileType1 != ".jpg") && (fileType1 != ".png") && (fileType1 != ".GIF") && (fileType1 != ".JPG") && (fileType1 != ".PNG")) 
			{
				alert("Please enter valid image format.");
				document.frmAlbum.fleImage.focus ();
				return false;
			}
		}
		if(document.frmAlbum.txtTitle.value.length ==0)
 			{
				alert("Please enter a title for the image..");
				document.frmAlbum.txtTitle.focus ();
				return false; 
			}
		
				return true;
	}
	
function validate_modifyalbum(form) 
	{ 
		if(document.frmAlbum.fleImage.value.length !='')
		 {
			var pathLength1 = document.frmAlbum.fleImage.value.length;
			var lastDot1 = document.frmAlbum.fleImage.value.lastIndexOf(".");
			var fileType1 = document.frmAlbum.fleImage.value.substring(lastDot1,pathLength1);
			
			if((fileType1 != ".gif") && (fileType1 != ".jpg") && (fileType1 != ".png") && (fileType1 != ".GIF") && (fileType1 != ".JPG") && (fileType1 != ".PNG")) 
			{
				alert("Please enter valid image format.");
				document.frmAlbum.fleImage.focus ();
				return false;
			}
		}	
		if(document.frmAlbum.txtName.value.length ==0)
 			{
				alert("Please enter an album name..");
				document.frmAlbum.txtName.focus ();
				return false; 
			}
		
				return true;
	}
function im_admin_message(imgid,usr,al)
{
top.location = 'admin_image.php?imgid='+imgid+'&us='+usr+'&al='+al ;
}
function vid_admin_message(vidid,usr)
{
top.location = 'admin_video.php?vidid='+vidid+'&us='+usr ;
}
function validate_relations(form) 
	{
		if (document.rel.day.value.length ==0)
			{
				alert('Please enter day of birth ');
				document.rel.day.focus ();
				return false;
			}
		if (document.rel.year.value.length ==0)
			{
				alert('Please enter year of birth');
				document.rel.year.focus ();
				return false;
			}
		if (parseInt(document.rel.day.value) !=document.rel.day.value) 
			{
				alert('Please enter day, numbers only');
				document.rel.day.focus ();
				return false;
			}
		if (parseInt(document.rel.year.value) !=document.rel.year.value) 
			{
				alert('Please enter year, numbers only');
				document.rel.year.focus ();
				return false;
			}

				return true;
	}
function validate_music(form) 
	{ 
		if (!document.frmAlbum.agree.checked) 
			{
	 			alert("Please Read the guidlines and check the box   ."); 
	 			return false; 
			} 
		if(document.frmAlbum.txtTitle.value.length ==0)
 			{
				alert("Please enter music title..");
				document.frmAlbum.txtTitle.focus ();
				return false; 
			}
		if(document.frmAlbum.fleMusic.value.length ==0)
 			{
				alert("Please upload music file..");
				document.frmAlbum.fleMusic.focus ();
				return false; 
			}
				return true;
	}

function limitText(limitField, limitCount, limitNum) 
{
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}


function updateRecord(recordId,formname)
{
		window.location.href = formname+"?updateRecord&record=" + recordId;
}
function deleteRecord(recordId,formname)
{
	if (confirm('Delete this Record?')) 
	{	window.location.href = formname+"?deleteRecord&record=" + recordId;	}
}		
function deleteAlbum(albumId)
{
	if (confirm('Delete this album?')) {
		window.location.href = 'index.php?page=image_gallery/list&deleteAlbum&album=' + albumId;
	}
}
function viewImage(albumId) {
	if (albumId != '') {
		window.location.href = 'index.php?page=list-image&album=' + albumId;
	} else {
		window.location.href = 'index.php?page=list-image';
	}
}
function viewslide(albumId) {
	if (albumId != '') {
		window.location.href = 'index.php?page=image_gallery/image_slide&album=' + albumId;
	} else {
		window.location.href = 'index.php?page=image_gallery/image_slide';
	}
}
function deleteImage(albumId, imgId) 
{
	if (confirm('Delete this image?')) {
		window.location.href = 'index.php?page=list-image&delete&album=' + albumId + '&imgId=' + imgId;
	}
}
function deleteVideo(vidId) 
{
	if (confirm('Delete this video?')) {
		window.location.href = 'index.php?page=video_gallery/list-video&delete&vidId=' + vidId ;
	}
}

function viewLargeImage(imageName)
{
	imgWindow = window.open('', 'largeImage', "width=" + screen.availWidth + ",height="  + screen.availHeight + ",top=0,left=0,screenY=0,screenX=0,status=yes,scrollbars=yes,resizable=yes,menubar=no");
	imgWindow.focus();
	imgWindow.location.href = 'index.php?page=image_gallery/viewImage&type=glimage&name=' + imageName;
}



function valuevalidation(entered, min, max, alertbox, datatype)
{
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
  {smalldatatype=datatype.toLowerCase();
   if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
  }
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
function validate_shipayinfo() {
	var emailID=document.frm.email
	if (document.frm.firstname.value=="") 
	{    
		alert("Please enter first name  .");
		document.frm.firstname.focus();  
	 			return false;
	}
	if (document.frm.lastname.value=="") 
	{    
		alert("Please enter last name  ."); 
		document.frm.lastname.focus(); 
	 			return false; 
		
	}
	if ((document.frm.email.value==null)||(document.frm.email.value=="")){
		alert("Please Enter your Email ID")
		document.frm.email.focus()
		return false
	}
	if (echeck(document.frm.email.value)==false){
		document.frm.email.focus()
		return false
	}
	
	if (document.frm.phone3.value.length ==0)
			{
				alert('Please enter phone number');
				document.frm.phone3.focus ();
				return false;
			}
	if (parseInt(document.frm.phone3.value) !=document.frm.phone3.value) 
			{
				alert('Please enter  numbers only');
				document.frm.phone3.focus ();
				return false;
			}
	if (document.frm.phone2.value.length ==0)
			{
				alert('Please enter phone number');
				document.frm.phone2.focus ();
				return false;
			}
	if (parseInt(document.frm.phone2.value) !=document.frm.phone2.value) 
			{
				alert('Please enter  numbers only');
				document.frm.phone2.focus ();
				return false;
			}
	if (document.frm.phone1.value.length ==0)
			{
				alert('Please enter phone area code');
				document.frm.phone1.focus ();
				return false;
			}
	if (parseInt(document.frm.phone1.value) !=document.frm.phone1.value) 
			{
				alert('Please enter area code numbers only');
				document.frm.phone1.focus ();
				return false;
			}
	return true;
	}
