function Validate_Email(theForm)
{


  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@.";
  var checkStr = theForm.email.value;
  var allValid = true;
  var bDotPresent = false;
  var bRatePresent = false;
  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;
    }

    if (j == checkOK.length - 1  )
	    {
	    	bDotPresent = true;

	    }

	    if (j == checkOK.length -2 )
	    {
	    	bRatePresent = true;
	    }

  }

  if (!allValid)
  {
    alert("Please enter only letter, digit and \"-_@.\" characters in the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  if ((!bDotPresent) || (!bRatePresent) )

    {
    	alert ("Please enter a valid email address");
    	theForm.email.focus();
    	return(false);
    }

	  return (true);
}

function openPopUp (winURL, winName, winFeatures){
	newWindow = window.open(winURL,winName,winFeatures);
	newWindow.focus();
}

function newGalleryWindow(galleryURL, galleryWinName, galleryFeatures){
	window.open(galleryURL, galleryWinName, galleryFeatures);
}

function displayWindow (url, width, height){
		var Win = window.open (url,"displayWindow",'width=' + width + ',height=' +
		height + ',resizable=0,scrollbars=no,menubar=no,status=yes');
		Win.focus();
	}

function validateIt(theForm)
 {
  if(theForm.categoryid.value != '')
	{
	theForm.submit()
	}
  else
     	{
     	return false
     	}
 }
 
function doClear(theText) {
	if (theText.value == theText.defaultValue) {
	  theText.value = ""
	}
}

function ValidateSong_AddEdit ( thisObj )
{
	if ( thisObj.strTitle.value == '' )
	{
		alert("Please enter a song title");
		thisObj.strTitle.focus();
		return false;
	}
	
	if ( thisObj.strFileURL.value == '' )
	{
		alert("Please enter a song url");
		thisObj.strFileURL.focus();
		return false;
	} 

	if ( thisObj.blnSingle.checked )
		if ( !thisObj.dblPrice[0].checked && !thisObj.dblPrice[1].checked && !thisObj.dblPrice[2].checked )
		{
			alert("Please select a price");
			return ( false );
		}

}

function ValidateAlbum_AddEdit ( thisObj )
{
	if ( thisObj.strTitle.value == '' )
	{
		alert("Please enter a album title");
		thisObj.strTitle.focus();
		return false;
	}
	

	
	if ( !thisObj.dblPrice[0].checked && !thisObj.dblPrice[1].checked && !thisObj.dblPrice[2].checked )
	{
		alert("Please select a price");
		return ( false );
	}
	
	var intCount = 0;
	for ( i = 0; i<thisObj.intDownloadGroup_Single_id.length ; i++ )
		if ( thisObj.intDownloadGroup_Single_id[i].checked ) 
			intCount++;
	
	if ( intCount < 5 || intCount > 20 ) 
	{
		alert("Albums must contain between 5 - 20 songs");
		return ( false );
	}

	
}

function submitEvent()
{
							
	var Mnth,Dth,Yer,Valid;
	Valid="TRUE";
	Mnth = document.EventProcessing.intMonth.value;
	Dth = document.EventProcessing.intDay.value;
	Yer = document.EventProcessing.intYear.value;
	if(Mnth == 2 || Mnth == 4 || Mnth == 6 || Mnth == 9 || Mnth == 11)
	{
		if(Mnth == 2 && (Yer%4)!=0 && Dth>28)
			{
				alert("Please select a valid Date/Month");
				Valid="FALSE";
			}
		else
			{
			if(Dth>30)
				{
				alert("Please select a valid Date/Month");
				Valid="FALSE";
				}
			}	
	}
	if(Valid == "TRUE")
	{
		document.EventProcessing.action="Reservation_Create_Proc.asp";
		document.EventProcessing.submit();
	}
}

function submitDeleteEvent(id)
{			
	var blnAsk;
	blnAsk = confirm("You are about to delete an Event. Would you like to proceed?");
	if (blnAsk)
	{
		document.location.href="Reservation_Delete_Proc.asp?intReservationItem_id=" +  id ;
	}
}

function validateIt(theForm)
 {
  if(theForm.categoryid.value != '')
	{
	theForm.submit()
	}
  else
     	{
     	return false
     	}
 }
function password(){
	self.name = "Parent_Window"; 
	window.open('/portal/user/send_pass.asp','EmailLoginInfo','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=350,height=300');
	}

function Email_Validator(theForm)
{


  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@.";
  var checkStr = theForm.email.value;
  var allValid = true;
  var bDotPresent = false;
  var bRatePresent = false;
  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;
    }

    if (j == checkOK.length - 1  )
	    {
	    	bDotPresent = true;

	    }

	    if (j == checkOK.length -2 )
	    {
	    	bRatePresent = true;
	    }

  }

  if (!allValid)
  {
    alert("Please enter only letter, digit and \"-_@.\" characters in the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  if ((!bDotPresent) || (!bRatePresent) )

    {
    	alert ("Please enter a valid email address");
    	theForm.email.focus();
    	return(false);
    }

	  return (true);
}

function ValidateEmail(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 RateReview_RateReview_Validate(objForm)
{
	var blnOutReturnVal;
	var blnInReturnVal;	
	blnOutReturnVal = RateReview_TextCheck(objForm.strRateDesc, "Comments");
	if (blnOutReturnVal)
	{		
		
		blnInReturnVal = RadioCheck(objForm, "rating");
			if (blnInReturnVal)	
			{
				return true;
			}
			else
			{
				return false;		
			}
	}
	else
	{
		return false;
	}
}
	

function RateReview_TextCheck(objTextBox, objName)
{
	if (objTextBox.value == "")
	{
		alert("Please Ensure that you have Entered data under " + objName )
		return false;
	}  
	else
	{
		return true;
	}
}
	
	
function RateReview_RadioCheck(objForm, objName)
{	
	
	var i=0;
	var obj;
	var intCheckCount=0;
	
	for (i=0;i<objForm.elements.length;i++)
	{
		obj = objForm.elements[i];
		if ((obj.type == "radio") && (obj.checked))
		{
			intCheckCount++;
		}		
	}
	
	if (intCheckCount>0)
	{
		return true;
	}
	else
	{
		alert("Please ensure you have selected " + objName + ".");
		return false;
	}	
}

function trimString(str)
{ 
	return str.replace(/^\s+/,'').replace(/\s+$/,'');
}

function checksports_selected()
	{
		var intcount,index,intSportCount;
		intcount=0;
		index=0;
		intSportCount = document.frmBio.intSportCount.value;
		if(intSportCount=="")
		{
			intSportCount = 0;
		}
		for(index=0;index<=document.frmBio.strSports.length-1;index++)
		{ 
			if (document.frmBio.strSports.item(index).selected==true)
			{
				intcount+=1;
			}
		}
		if(intcount>intSportCount)
		{
		alert('You can choose only upto '+intSportCount+' sport(s)');
		return false;
		}
		else
		{
			return true;
		}
	}
function validate_Bio(theForm)	
{
	if(theForm.strBio.value == "")
	{
		alert("Please enter your bio details.");
		theForm.strBio.focus();
		return false;
	}
	else
	{
		if(theForm.strInfluences.value=="")
		{
			alert("Please enter your work history details.");
			theForm.strInfluences.focus();
			return false;
		}
		else
		{
		return true;
		}
	}
}