function initialise() {
	
	if(typeof(DynamicCorners) == "object" && typeof(DynamicCorners.initialise) == "function") {
		DynamicCorners.initialise();
	}
}

$(document).ready(function() {
	initialise();	
	//For form validation - Added by prasad 14th September 2010
	checkForSubmit();
	
});


function checkValidation(radioRbsCustomerVal,sortCode,email,telephone,address,isComplain) {
	
	//Complain forms should force user to enter address/email/telephone even if rbs customer/not.					
	if (isComplain =='true' && sortCode=='')
	{
		alert('Please enter Sortcode!');
		return false;
	}	
	
	if(isComplain=='true' && email =='' && telephone =='' && address =='')
	{		
		alert('Please enter email or telephone or address!');
		return false;
	}
	if(isComplain=='false' && email =='' && telephone =='' && address =='')
	{		
		alert('Please enter email or telephone or address!');
		return false;
	}	
   if(isComplain=='true' && (email !='' || telephone !='' || address !=''))
	{		
		return true;
	}
	if(isComplain=='false' && (email !='' || telephone !='' || address !=''))
	{		
		return true;
	}
	//End of complaim forms conditions
	
	//Feedback,Nomination & Callback request  validation
	if (radioRbsCustomerVal =='true' && sortCode=='')
	{
		alert('Please enter Sortcode!');
		return false;
	}	
	
	if (radioRbsCustomerVal =='true' && email =='' && telephone =='' && address=='')
	{	
		alert('Please enter email or telephone or address!');
		return false;
	}
	else
	{
		return true;
	} 
	
 }
  
 function checkMultipleValidation(radioRbsCustomerVal,radioFeedBackVal,sortCode,email,telephone,address) {
	
	if (radioRbsCustomerVal =='true' && sortCode=='')
	{		
		alert('Please enter Sortcode!');
		return false;
	}		
	if (radioFeedBackVal =='true' && email =='' && telephone =='' && address=='')
	{	
		alert('Please enter email or telephone or address!');
		return false;
	}
	else
	{
		return true;
	} 	
 }
 
  
//Are you RBS Customer/Feedback radio buttons validation 
 function checkForSubmit() 
 {   
	$("input[class=submitButton]").click(function()
	{
		var email = $("input[name=Email]").val();
		var telephone = $("input[name=Telephone]").val();
		var sortCode = $("input[name=SortCode]").val();
		var address = $("textarea[name=Address]").val();
		var radioRbsCustomerVal=$('#formSubmit input:radio[name=rbsCustomerRadioVal]:checked').val();
		var radioFeedBackExists = $('#formSubmit input:radio[name=feedBackRadioVal]').length;
		var radioFeedBackVal = $('#formSubmit input:radio[name=feedBackRadioVal]:checked').val();
		var isComplain = $('#formSubmit input:radio[name=rbsComplainRadioVal]:checked').val();			
			
		if(radioFeedBackExists<1)
		{	
			if (checkValidation(radioRbsCustomerVal,sortCode,email,telephone,address,isComplain))			
			{return true;}
			else
			{return false;}
		}
		else
		{
			if (checkMultipleValidation(radioRbsCustomerVal,radioFeedBackVal,sortCode,email,telephone,address))
			{return true;}
			else
			{return false;}			
		}
		
	});
}
