function funcvalidateRegistration()
{
	var strFirstName 	      = document.frmRegistration.txtFirstname.value;
	var strLastname 		  = document.frmRegistration.txtLastname.value;
	var strEmail 			  = document.frmRegistration.txtEmail.value;
	var strUsername 		  = document.frmRegistration.txtUsername.value;
	var strPassword 		  = document.frmRegistration.txtPassword.value;
	var strConfirmPassword 	  = document.frmRegistration.txtConfirmPassword.value;
	var strCardName 		  = document.frmRegistration.txtCardName.value;
	var strCardType 		  = document.frmRegistration.cboCardType.value;
	var strCardNumber 		  = document.frmRegistration.txtCardNumber.value;
	var strMonth 			  = document.frmRegistration.cboMonth.value;
	var strYear 			  = document.frmRegistration.cboYear.value;
	var strVerificationNumber = document.frmRegistration.txtVerificationNumber.value;
	var strFirstAddress 	  = document.frmRegistration.txtFirstAddress.value;
	var strCity               = document.frmRegistration.txtCity.value;
	var strState 			  = document.frmRegistration.txtState.value;
	var strPinCode 			  = document.frmRegistration.txtPinCode.value;
	var strCountry 			  = document.frmRegistration.txtCountry.value;
	var strPhone 			  = document.frmRegistration.txtPhone.value;
	var strCheck 			  = document.frmRegistration.chkAgree;
	var bReturn               = true;
	if(bReturn && strFirstName == "")
	{
		alert("Please give first name");
		document.frmRegistration.txtFirstname.focus();
		bReturn = false;
	}
	if(bReturn && strLastname == "")
	{
		alert("Please give last name");
		document.frmRegistration.txtLastname.focus();
		bReturn = false;
	}
	if(bReturn && strEmail == "")
	{
		alert("Please give email");
		document.frmRegistration.txtEmail.focus();
		bReturn = false;
	}
	if(bReturn && !funcIsEmail(strEmail))
	{
		alert("Please give valid  email");
		document.frmRegistration.txtEmail.focus();
		bReturn = false;
	}
	if(bReturn && strUsername == "")
	{
		alert("Please give username");
		document.frmRegistration.txtUsername.focus();
		bReturn = false;
	}
	if(bReturn && strPassword == "")
	{
		alert("Please give password");
		document.frmRegistration.txtPassword.focus();
		bReturn = false;
	}
	if(bReturn && strConfirmPassword == "")
	{
		alert("Please give confirm password");
		document.frmRegistration.txtConfirmPassword.focus();
		bReturn = false;
	}
	if(bReturn && strConfirmPassword != strPassword)
	{
		alert("Passwords mismatch");
		document.frmRegistration.txtConfirmPassword.focus();
		bReturn = false;
	}
	if(bReturn && strCardName == "")
	{
		alert("Please give name on card");
		document.frmRegistration.txtCardName.focus();
		bReturn = false;
	}
	if(bReturn && strCardType == "")
	{
		alert("Please select card type");
		document.frmRegistration.cboCardType.focus();
		bReturn = false;
	}
	if(bReturn && strCardNumber == "")
	{
		alert("Please give card number");
		document.frmRegistration.txtCardNumber.focus();
		bReturn = false;
	}
	if(bReturn && isNaN(strCardNumber) == true)
	{
		alert("Please give valid card number");
		document.frmRegistration.txtCardNumber.focus();
		bReturn = false;
	}
	if(bReturn && strMonth == "")
	{
		alert("Please select  month");
		document.frmRegistration.cboMonth.focus();
		bReturn = false;
	}
	if(bReturn && strYear == "")
	{
		alert("Please select year");
		document.frmRegistration.cboYear.focus();
		bReturn = false;
	}
	if(bReturn && strVerificationNumber == "")
	{
		alert("Please give card verification number");
		document.frmRegistration.txtVerificationNumber.focus();
		bReturn = false;
	}
	if(bReturn && isNaN(strVerificationNumber) == true)
	{
		alert("Please give valid card verification number");
		document.frmRegistration.txtVerificationNumber.focus();
		bReturn = false;
	}
	if(bReturn && strFirstAddress == "")
	{
		alert("Please give address");
		document.frmRegistration.txtFirstAddress.focus();
		bReturn = false;
	}
	if(bReturn && strCity == "")
	{
		alert("Please give city");
		document.frmRegistration.txtCity.focus();
		bReturn = false;
	}
	if(bReturn && strState == "")
	{
		alert("Please give state");
		document.frmRegistration.txtState.focus();
		bReturn = false;
	}
	if(bReturn && strPinCode == "")
	{
		alert("Please give pincode");
		document.frmRegistration.txtPinCode.focus();
		bReturn = false;
	}
	if(bReturn && isNaN(strPinCode) == true)
	{
		alert("Please give valid pincode");
		document.frmRegistration.txtPinCode.focus();
		bReturn = false;
	}
	if(bReturn && strPhone == "")
	{
		alert("Please give phone no");
		document.frmRegistration.txtPhone.focus();
		bReturn = false;
	}
	if(bReturn && isNaN(strPhone) == true)
	{
		alert("Please give valid phone no");
		document.frmRegistration.txtPhone.focus();
		bReturn = false;
	}
	if(bReturn && !strCheck.checked)
	{
		alert("Please check terms of agreement");
		document.frmRegistration.chkAgree.focus();
		bReturn = false;
	}
	return bReturn;
}
function funcIsEmail(paramEmail)
{
	var strCurrentCharacter;
	var bValidEmail,bPeriodPresent; 
	var iLastPositionOfPeriod,bCorrectLengthExtension;
	var iNumAtSymbol=0;
	var iPosAtSymbol;
	var iLengthOfServerName=1;
	var iPosConsecutiveDots;
	var strEmail=new String(functrim(paramEmail));
	iLength=strEmail.length;
	bPeriodPresent=1;
	bCorrectLengthExtension=1;
	iLastPositionOfPeriod=0;
	if(iLength==0)
	{
		return true;
	}
	for(iLoop=0; iLoop<iLength; iLoop++)
	{
		if(!((strEmail.charCodeAt(iLoop)>=65 && strEmail.charCodeAt(iLoop)<=90)
		  || (strEmail.charCodeAt(iLoop)>=97 && strEmail.charCodeAt(iLoop)<=122)
		  || (strEmail.charCodeAt(iLoop)>=48 && strEmail.charCodeAt(iLoop)<=57)
		  || (strEmail.charAt(iLoop)=="@")
		  || (strEmail.charAt(iLoop)=="_")
		  || (strEmail.charAt(iLoop)=="-")
		  || (strEmail.charAt(iLoop)==".")))
		{
			return false;
		}
	}
	iPosConsecutiveDots=strEmail.indexOf('..');
	if(iPosConsecutiveDots!=-1)
	{
		return false;
	}
	
	var iPosSpace;
	iPosSpace = strEmail.indexOf(' ');
	if(iPosSpace!=-1)
	{
		return false;
	}
	iLastPositionOfPeriod = strEmail.lastIndexOf('.');
	if(iLastPositionOfPeriod<=0)
	{
		bPeriodPresent=0;
	}
	if(((iLength-iLastPositionOfPeriod)>5) || ((iLength-iLastPositionOfPeriod)<3))
	{
		bCorrectLengthExtension=0;
	}
	for(iLoop=0;iLoop<=iLength;iLoop++)
	{
		strCurrentCharacter=strEmail.charAt(iLoop);
		if (strCurrentCharacter=='@')
		{
			iNumAtSymbol=iNumAtSymbol + 1;
		}
	}
	
	if(iNumAtSymbol!=1)
	{
		return false;
	}
	
	iPosAtSymbol = strEmail.indexOf('@');
	if(strEmail.charAt(iPosAtSymbol+1) == '.')
	{
		iLengthOfServerName=0;
	}
	
	if((iNumAtSymbol==1) && (bPeriodPresent==1) && (bCorrectLengthExtension==1) && (iLengthOfServerName==1))
	{
		bValidEmail=1;
	}
	else
	{
		 bValidEmail=0;
	}
	
	if(bValidEmail==0)
	{
		return false;
	}
	else
	{
		return true;
	}
}
function functrim(paramText)
{
	var strText=new String(paramText);
	var strReturnText;
	strReturnText="";
	bNonBlankStarted=false;
	bNonBlankEnded=false;
	strIntermediateBlankChunk="";
	var iLoop;
	for(iLoop=0;iLoop<strText.length;iLoop++)
	{
		if(strText.charCodeAt(iLoop)!=32)
		{
			if(!bNonBlankStarted)
			{
				bNonBlankStarted=true;
			}
			if(bNonBlankStarted && !bNonBlankEnded)
			{
				strReturnText+=strText.charAt(iLoop);
			}
			if(bNonBlankEnded)
			{
				strReturnText+=(strIntermediateBlankChunk+strText.charAt(iLoop));
				bNonBlankEnded=false;
				strIntermediateBlankChunk="";
			}
		}
		else
		{
			if(bNonBlankStarted)
			{
				bNonBlankEnded=true;
				strIntermediateBlankChunk+=" ";
			}
		}
	}
	return strReturnText;
}
function funcvalidateLogin()
{
	var strName       = document.frmLogin.txtName.value;
	var strPassword   = document.frmLogin.txtPassword.value;
	var bReturn       = true;
	if(bReturn && strName == "")
	{
		alert("Please give username");
		document.frmLogin.txtName.focus();
		bReturn = false;
	}
	if(bReturn && strPassword == "")
	{
		alert("Please give password");
		document.frmLogin.txtPassword.focus();
		bReturn = false;
	}
	return bReturn;
}
/*********************************************************************************************************
* OPEN THE MOVIE PREVIEW IN A NEW WINDOW
**********************************************************************************************************/
function funcRedirectForPreviewOrOrder(iMovieID, strAction, strBaseUrl)
{
	if(strAction == 'order')
	{
		window.location = strBaseUrl+'order/register';
	}
	else if(strAction == 'preview')
	{
		window.location = strBaseUrl+'category/previewMovie/'+iMovieID;
	}
} 



/*********************************************************************************************************
* SHOW THE FORGOT PASSWORD EMAIL TEXT FIELD AND SUBMIT BUTTON
**********************************************************************************************************/
function funcForgotPassword()
{
	Effect.Appear('divSendPasswordResult');
	Effect.Appear('divForgotPassword');
}

/*********************************************************************************************************
* HIDE FORGOT PASSWORD BLOCK
**********************************************************************************************************/
function funcHideForgotPassword()
{
	Effect.Fade('divSendPasswordResult');
	Effect.Fade('divForgotPassword');
}

/*********************************************************************************************************
* CLEAR FORGOT PASSWORD EMAIL TEXT FIELD
* @parameter Object EmailTextBox
**********************************************************************************************************/
function funcClearForgotPassword(objEmail)
{
	if(objEmail.value == 'Your Email here')
	{
		objEmail.value = '';
		objEmail.style.color = 'black';
	}
}

/*********************************************************************************************************
* AJAX CALL TO SEND PASSWORD FROM EMAIL ADDRESS USING PROTOTYPE LIBRARY
* @parameter String base_url set in the header
**********************************************************************************************************/
function funcAjaxSendPassword(strBaseUrl)
{
	var txtEmail = $('txtEmail');
	$('divSendPasswordResult').innerHTML = '';
	if(txtEmail.value != '')
	{
		var params = 'txtEmail=' + txtEmail.value;
		var ajax = new Ajax.Updater
		(
			{
				success: 'divSendPasswordResult'
			},
			strBaseUrl+'welcome/forgotPassword',
			{
				method: 'post', 
				parameters: params, 
				evalScripts:true,
				onLoading: function(){funcAjaxCreated('');},
				onComplete: function(){funcAjaxCompleted('');}
			}
		);
	}
}

function funcSelectMinisiteLanding(strBaseUrl, strValue)
{
	if(strValue == 'html')
	{
		$('optCategory1').value = 0;
		Element.hide('divCategory1');
		$('optCategory1').disabled = true;
		$('optCategory5').disabled = false;
	}
	else
	{
		$('optCategory5').value = 0;
		Element.hide('divCategory5');
		$('optCategory5').disabled = true;
		$('optCategory1').disabled = false;
	}
	funcAjaxMinisiteLanding(strBaseUrl, strValue);
}


function funcAjaxMinisiteLanding(strBaseUrl, strValue)
{
	
	var params = 'landing_type=' + strValue;
	var ajax = new Ajax.Request
	(
		strBaseUrl+'category/updateLandingFormSelection',
		{
			method: 'post', 
			parameters: params
		}
	);
}
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/*------------------------------------------------------------------------------------------------------------
 * AJAX CALL TO DISPLAY MOVIE DETAILS WHEN SELECTING A MOVIE FROM EACH CATEGORY FOR A MINISITE
 * USING PROTOTYPE LIBRARY
 *------------------------------------------------------------------------------------------------------------*/
function funcdisplayMovieDetails(iCategoryID, objCategoryCombo, strBaseUrl)
{
	Element.hide('divCategory'+iCategoryID);//hide the movie detail if so selected previously
	iMovieID 	 = document.getElementById(objCategoryCombo).value;
	//alert('categoryid='+iCategoryID+'   category combo '+ objCategoryCombo+'  movie id'+iMovieID);
	if(iMovieID != '0')
	{
		var params = 'movie_id=' + iMovieID + '&category_id=' + iCategoryID;
		var ajax = new Ajax.Request
		(
			
			strBaseUrl+'category/getMinisiteMovieDetails',
			{
				method: 'post', 
				parameters: params, 
				onLoading: function(){funcAjaxCreated(iCategoryID);},
				onComplete:
				function(transport)
				{
					funcAjaxCompleted(iCategoryID);
					$('divCategory'+iCategoryID).innerHTML = transport.responseText; 
					Effect.Appear('divCategory'+iCategoryID,{duration:0.5});
				}
			}
		);
	}
}



/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/*------------------------------------------------------------------------------------------------------------
 * AJAX CALL TO DISPLAY MOVIE DETAILS WHEN SELECTING A MOVIE FROM EACH CATEGORY FOR A MINISITE
 * USING PROTOTYPE LIBRARY
 *------------------------------------------------------------------------------------------------------------*/
function funcdisplayMovieProfileDetails(iCategoryID, objCategoryCombo, strBaseUrl)
{
	Element.hide('divCategory'+iCategoryID);//hide the movie detail if so selected previously
	iMovieID 	 = document.getElementById(objCategoryCombo).value;
	//alert('categoryid='+iCategoryID+'   category combo '+ objCategoryCombo+'  movie id'+iMovieID);
	if(iMovieID != '0')
	{
		var params = 'movie_id=' + iMovieID + '&category_id=' + iCategoryID;
		var ajax = new Ajax.Request
		(
			
			strBaseUrl+'members/getMovieDetails',
			{
				method: 'post', 
				parameters: params, 
				onLoading: function(){funcAjaxCreated(iCategoryID);},
				onComplete:
				function(transport)
				{
					funcAjaxCompleted(iCategoryID);
					$('divCategory'+iCategoryID).innerHTML = transport.responseText; 
					Effect.Appear('divCategory'+iCategoryID,{duration:0.5});
				}
			}
		);
	}
}





/*********************************************************************************************************
* SHOW AJAX LOADING SPINNER (GLOBAL HANDLER)
**********************************************************************************************************/
function funcAjaxCreated(SpinnerID)
{	
	Element.show('divSearchSpinner'+SpinnerID);
}
function funcAjaxCompleted(SpinnerID)
{
	Element.hide('divSearchSpinner'+SpinnerID);
}
/*--------------------------------------------------------------------------------------------------------------
 * AJAX CALL TO DISPLAY THE BILLING PLAN FOR A BILLING TYPE.
 *------------------------------------------------------------------------------------------------------------*/
function funcGetBillingPlan(strBillingType, strBaseUrl)
{
	Element.hide('divBillingPlan');//hide the billing plan combo
	if(strBillingType != '')
	{
		var params = 'billing_type=' + strBillingType;
		var ajax = new Ajax.Request
		(
			
			strBaseUrl+'order/getBillingPlan',
			{
				method: 'post', 
				parameters: params, 
				onLoading: function(){funcAjaxCreated('');},
				onComplete:
				function(transport)
				{
					funcAjaxCompleted('');
					$('divBillingPlan').innerHTML = transport.responseText; 
					Effect.Appear('divBillingPlan',{duration:1});
				}
			}
		);
	}
}

