// JavaScript Document

function empty_field(txtbox,msg)
	{
str=txtbox.value
	if(str.charAt(0)==" " || str.length==0)
		{
		alert (msg)
		txtbox.focus()	
		return false
		}
	return true
	}
	
function empty_field_wv(txtbox,value,msg)
	{
str=txtbox.value;
	if(str.charAt(0)==" " || str.length==0 || str == value)
		{
		alert (msg)
		txtbox.focus()	
		return false
		}
	return true
	}	
	
function pwd_match(txtbox,txtbox1,msg)
	{
str=txtbox.value;
str1=txtbox1.value;
	if(str != str1)
		{
		alert (msg)
		txtbox.focus()	
		return false
		}
	return true
	}	
		
function check_email(txtbox,msg)
	{
	var e=txtbox.value
	var a=e.indexOf("@")
	var b=e.indexOf(".")
	
		if(a<0 || b<0)
		{
		alert (msg)
		txtbox.select()
		return false
		}
	return true
	}
	
	
	
	function empty_fieldchk(txtbox,msg,chk)
	{
		
		if (chk.checked==false) {
			str=txtbox.value
			if(str.charAt(0)==" " || str.length==0)
				{
				alert (msg)
				txtbox.focus()	
				return false;
				}
				return true;
			}
return true;
	}
	
/*	function empty_list(list,msg)
	{
				
			if( list.value==0)
				{
				alert (msg)
				list.focus()	
				return false;
				}
				return true;
			}
*/
function empty_listchk(list,msg,chk)
	{
			if (chk.checked==true) {	
			if( list.value==0)
				{
				alert (msg)
				list.focus()	
				return false;
				}
				return true;
			}
return true;
	}
	function empty_fieldchkrev(txtbox,msg,chk)
	{
		
		if (chk.checked==true) {
			str=txtbox.value
			if(str.charAt(0)==" " || str.length==0)
				{
				alert (msg)
				txtbox.focus()	
				return false;
				}
				return true;
			}
return true;
	}
	function fn_validateNumeric(thi)
{
   if (((event.keyCode < 48) || (event.keyCode > 57)) && (event.keyCode != 46))
      event.returnValue = false;
   if(event.keyCode == 46 && instr(thi.value,".")>=0)
      event.returnValue = false;
}
	
	function valid(f) {
			var re = /^[0-9-.]*$/;
			if (!re.test(f.value)) {
			alert("Only numbers allowed!");
			f.value = f.value.replace(/[^0-9-.]/g,"");
			}
			} 
	

	function validnodot(f) {
var re = /^[0-9]*$/;
if (!re.test(f.value)) {
alert("Only numbers allowed!");
f.value = f.value.replace(/[^0-9-.]/g,"");
}
} 

function empty_num_field(txtbox,msg)
	{
str=txtbox.value

	if( str.charAt(0)==" " || str.length==0  )
		{
		alert (msg)
		txtbox.focus()	
		return false
		}else if (txtbox.value==0){
		alert (msg)
		txtbox.focus()		
		return false	
			}	
	
	return true
	}

function empty_num_fieldchk(txtbox,msg,chk)
	{
		
		if (chk.checked==false) {
			str=txtbox.value
			
			if(str.charAt(0)==" " || str.length<=0  )
				{
				alert (msg)
				txtbox.focus()	
				return false;
				}
			else if (txtbox.value==0){
		alert (msg)
		txtbox.focus()		
		return false	
			}	
				return true;
			}
return true;
	}
	
	function empty_list(list,msg)
	{
				
			if( list.value==0)
				{
				alert (msg)
				list.focus()	
				return false;
				}
				return true;
			}
//email and form validation validation Function
function frmvalidation(formname)
{
 if(formname.fname.value=="")
   {
	alert("Enter Name:");
	formname.fname.focus();
	return (false);
   }
  else if(formname.cname.value=="")
   {
	alert("Enter Company:");
	formname.cname.focus();
	return (false);
   }
  else if(formname.address.value=="")
   {
	alert("Enter Address:");
	formname.address.focus();
	return (false);
   }
   else if(formname.town.value=="")
   {
	alert("Enter Town:");
	formname.town.focus();
	return (false);  
   }
   else if(formname.city.value=="")
   {
	alert("Enter City:");
	formname.city.focus();
	return (false);  
   }
   else if(formname.postcode.value=="")
   {
	alert("Enter postcode:");
	formname.postcode.focus();
	return (false);  
   }
   else if(!isPhone(formname))
   {
	   formname.telophone.focus();
	   return (false);
   }
    else if(!checkEmail(formname))
   {
	return (false);
   }
   else
	return(true);
}
function trimAll(field)
				{
					var rRes = '';
					for(i = 0; i < field.length; i++)
					{
						if(field.charAt(i) != ' ')
						{
							rRes = rRes + field.charAt(i);
						}
					}
					//alert('rRes = ' + rRes);
					 return rRes;
				} 
			 
			function checkEmail(formname)
				{
				   formname.email.value = trimAll(formname.email.value);
				  // alert(formname.cusEmail.value);
				if(formname.email.value=="")
				   {
				  	alert("Please don't leave E-mail field empty.");
				    formname.email.focus();
				    return (false);
				   }
				  else
				   {
				   	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(formname.email.value))
					   {
						   return (true);
					   }
					   else
					   {
					     alert("Please provide valid E-mail.");
					     formname.email.focus();
					     formname.email.select();
					     return (false);
					   }
				   }
				}
			 
			  
			function isEmail()
			 {
				if(!checkEmail(document.sendMailFrom))
					{
						return false;
					}
					return true;	
			 }
// function for telephone
function isPhone(formname)
 {
		var checkOK = "0123456789";
		var regExp = / /g;
		var str = formname.telophone.value;
//		
		str = str.replace(regExp,'');
		if (str.length <= 0) {
			alert("Please don't leave phone field empty.");
			formname.telophone.focus();
		return false;
		} else {
			var checkStr = formname.telophone.value;
			var allValid = true;
			
			for (i = 0;  i < checkStr.length;  i++) {
				ch = checkStr.charAt(i);
				for (j = 0;  j < checkOK.length;  j++)
					if (ch == checkOK.charAt(j))				
					break;
	
					if (j == checkOK.length){
						allValid = false;
					break;
					}
			}//for (i = 0;  i < checkStr.length;  i++) {
		
			if (!allValid){
				alert("Please provide valid value for Phone field.");
				formname.telophone.focus();
				formname.telophone.select();
			return false;
			}//if (!allValid){
		}//if ( str=="" ){			  
	return true;
 }
function forgot_popup()
{
var w=500;
var h=300;
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+'resizable=0';
 window.open("forgot-password.php","forgot",winprops);
	
}
function displayimg(val_img)
{
	var path="images/events/expired/"+val_img;
    if(document.getElementById("img_div").style.display=="none")
    {
		document.getElementById("img_div").style.display="block";
		document.getElementById("img").src=path;
	}
  else
    {
	    document.getElementById("img").src=path;
	}
}
function watch_video(id)
{
 window.open("watch_usr_video.php?vid="+id,"forgot","width=500,height=500,top=0,left=0");
}
function watch_img(id)
{
var w1=820;
var h1=620;
var winl1 = (screen.width - w1) / 2;
var wint1 = (screen.height - h1) / 2;
winprops1 = 'height='+h1+',width='+w1+',top='+wint1+',left='+winl1+'resizable=0';
window.open("wallpaper.php?id="+id,"mywindow",winprops1);
}
// for user uploaded wallpapers
function watch_img(id)
{
var w1=820;
var h1=620;
var winl1 = (screen.width - w1) / 2;
var wint1 = (screen.height - h1) / 2;
winprops1 = 'height='+h1+',width='+w1+',top='+wint1+',left='+winl1+'resizable=0';
window.open("wallpaperuser.php?id="+id,"mywindow",winprops1);
}
function watch_art(id, type)
{
var w1=700;
var h1=650;
var winl1 = (screen.width - w1) / 2;
var wint1 = (screen.height - h1) / 2;
winprops1 = 'height='+h1+',width='+w1+',top='+wint1+',left='+winl1+'resizable=0';	
window.open("artist_video.php?id="+id+"&type="+type,"mywindow",winprops1);
//window.open("artist_video.php?id="+id+"&type="+type,"mywindow","location=1,status=1,scrollbars=1,width=700,height=600"); 
}
function art_wallpapers(index, limit, id)
{
document.location="artist.php?id="+id+"&index="+index+"&limit="+limit;
}
function art_audios(index, limit, id)
{
document.location="artist.php?id="+id+"&indexA="+index+"&limitA="+limit;
}
function art_videos(index, limit, id)
{
document.location="artist.php?id="+id+"&indexV="+index+"&limitV="+limit;
}
/*function verifykw()
{
	if(document.getElementById("songs").checked==false && document.getElementById("artist").checked==false && document.getElementById("album").checked==false && document.getElementById("lyrics").checked==false)
	{
		alert("Please Select an Option for Search Criteria.");	
		document.getElementById("songs").focus();
		return false;
	}
return true;
}
*/
function verifylogin()
{
	if(document.getElementById("txtUserName").value=="")
	{
	alert("Please Enter Email as Login Name.");
	document.getElementById("txtUserName").focus();
	return false;
	}
	else if(document.getElementById("txtPassword").value=="")
	{
	alert("Please Enter Password.");
	document.getElementById("txtPassword").focus();
	return false;
	}
return true;
}
function regchk(formname)
{
document.frmsi.email.value = trimAll(document.frmsi.email.value);
			  // alert(formname.cusEmail.value);
			if(document.frmsi.email.value=="")
			   {
				alert("Please don't leave E-mail field empty.");
				document.frmsi.email.focus();
				return (false);
			   }
			  else
			   {
				if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frmsi.email.value))
				   {
					   return (true);
				   }
				   else
				   {
					 alert("Please provide valid E-mail.");
					 document.frmsi.email.focus();
					 document.frmsi.email.select();
					 return (false);
				   }
			   }

}
function funuploaded()
{
document.getElementById("divuploaddata").style.display="none";	
document.getElementById("divuploading").style.display="none";	
document.getElementById("divuploaded").style.display="block";	
}
function funuploadinerror()
{
document.getElementById("divuploaddata").style.display="none";	
document.getElementById("divuploading").style.display="none";	
document.getElementById("divuploadederror").style.display="block";	
}
function funsub()
{
	if(document.frmuploadingevents.txtname.value=="")
	{
		document.frmuploadingevents.txtname.focus();
		alert('Please Enter Video Name or Title');
		return false;
	}
	else if(document.frmuploadingevents.txtcode.value=="" && document.frmuploadingevents.vdofiles.value=="")
	{
		document.frmuploadingevents.txtcode.focus();
		alert('Please Enter Video Code or File to upload');
		return false;
	}
	else if(document.frmuploadingevents.vdesc.value=="")
	{
		document.frmuploadingevents.vdesc.focus();
		alert('Please Enter Some description');
		return false;
	}
	else 
	{
	document.getElementById("divuploaddata").style.display="none";	
	document.getElementById("divuploaddata").style.display="none";	
	document.getElementById("divuploading").style.display="block";	
	return true;
	}
}
function divuploadederrorfile()
{
document.getElementById("divuploaddata").style.display="none";	
document.getElementById("divuploading").style.display="none";	
document.getElementById("divuploadederrorfile").style.display="block";	
}

function watch_vdoclient(val)
{
window.open("watch_events_video.php?id="+val,"watch","width=450,height=410,top=50,left=150");
}
function showlargeimg(img)
{
 var w=730;
var h=650;
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+'resizable=0, scrollbars=1';
 window.open("enlargeimg.php?img="+img,"Enlarge",winprops);   	
}
