function clearthis(id,txt)
{
	if(document.getElementById(id).value == txt)
	{
		document.getElementById(id).value='';
	}
}
function checkthis(id,txt)
{
	if(document.getElementById(id).value == '')
	{
		document.getElementById(id).value = txt;
	}
}
function close_my_account()
{
	var error = "";
	if(document.getElementById('close_account').checked == false)
	{
		error="Please tick the box to confirm account cancellation";
	}
	if(error=="")
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}
function toggle_num_tickets()
{
	if(document.getElementById('unlimited_tickets').checked==true)
	{
		document.getElementById('num_tickets').disabled = true;
	}
	else
	{
		document.getElementById('num_tickets').disabled = false;
	}
}
function textCounter(field,maxlimit) 
{
	if(document.getElementById(field).value.length >= maxlimit) // if too long...trim it!
		document.getElementById(field).value = document.getElementById(field).value.substring(0,maxlimit);
	
		
}

function process_select_template()
{

	var template_error = true;
	var template_banner_error = true; 
	for(i=0;i<=3;i++)
	{
		
		if(document.getElementById('template_'+i).checked==true)
		{
			if(document.getElementById('file').value=="")
			{
			
				for(x=0;x<=3;x++)
				{
					if(document.getElementById('template_banner_'+i+'_'+x).checked==true)
					{
						template_banner_error = false;
					}
				}
			}
			else
			{
				template_banner_error = false;
			}
			template_error = false;
		}
	}
	
	
	if(template_banner_error == false && template_error== false)
	{
		return true;
	}
	else
	{
		alert("Please choose a template and banner");
		return false;
	}
}

function process_event_contact_us()
{
	var error = "";
	

	if(document.getElementById('contact_name').value=='')
	{
		error+="Please add a contact name\n";
	}
	if(document.getElementById('contact_company_name').value=='')
	{
		error+="Please add a company name\n";
	}
	if(document.getElementById('contact_address1').value=='')
	{
		error+="Please add the first line of the address\n";
	}
	
	if(document.getElementById('contact_address4').value=='')
	{
		error+="Please add the town or city\n";
	}
	if(document.getElementById('contact_address5').value=='')
	{
		error+="Please add the postcode\n";
	}
	
	if(document.getElementById('contact_email').value=='')
	{
		error+="Please add the contact email address\n";
	}
	
	if(error == "")
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}

function event_payment_model()
{
	var error = "";
	var ht = document.getElementById('external_url').value.substring(0,7);
	var ht = ht.toLowerCase(); 
	var RE_EMAIL = /^(\w+[\-\.])*\w+@(\w+[\-\.])+[A-Za-z]+$/;
	
	if(document.getElementById('event_payment_type').value=='')
	{
		error+="Please select an event payment type\n";
	}
	
	if(document.getElementById('booking_page').value=='')
	{
		error+="Please select a booking page\n";
	}
	
	if(document.getElementById('booking_page').value=='external_url' && document.getElementById('external_url').value=='')
	{
		error+="Please enter the url of your payment page\n";
	}
/*	else if(document.getElementById('booking_page').value=='external_url' && document.getElementById('external_url').value!='' && ht!="http://")
	{
		error+="Please enter thwe whole URL, including HTTP://\n";
	}
*/	
	if(document.getElementById('event_payment_type').value=='paid' && document.getElementById('ticket_price').value=='')
	{
		error+="Please enter the ticket price\n";
	}
	if(document.getElementById('event_payment_type').value=='paid' && document.getElementById('paypal_email').value=='' && document.getElementById('booking_page').value=='housevents')
	{
		error+="Please enter your PayPal email address\n";
	}
	
//	else if(document.getElementById('event_payment_type').value=='paid' && !RE_EMAIL.test(document.getElementById('paypal_email').value))
//	{
		//alert(document.getElementById('event_payment_type').value);
		//alert(document.getElementById('booking_page').value);
		
		//error+="Please enter a valid PayPal email address\n";
//	}
	
	/* The lines above are changed by pankaj on 04-06-10 to remove paypal email alert */
	
	else if(document.getElementById('event_payment_type').value=='paid' && document.getElementById('booking_page').value=='housevents' && !RE_EMAIL.test(document.getElementById('paypal_email').value))
	{
		error+="Please enter a valid PayPal email address\n";
	}
	
	if(error == "")
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}

function addamend_event_description()
{
	var error = "";
	
	if(document.getElementById('event_category_id').value=='')
	{
		error+="Please select an event category\n";
	}
	if(document.getElementById('num_tickets').value=='' && document.getElementById('unlimited_tickets').checked==false)
	{
		error+="Please enter the number of tickets available\n";
	}
	
	if(error == "")
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}

function addamend_event()
{
	var error = "";
	
	if((document.getElementById('title').value=='') || (document.getElementById('title').value==' '))
	{
		error+="Please enter an event title\n";
	}
	if(document.getElementById('event_organiser').value=='')
	{
		error+="Please enter an event organiser \n";
	}
	if(document.getElementById('address1').value=='')
	{
		error+="Please enter the first line of the address\n";
	}
	if(document.getElementById('city').value=='')
	{
		error+="Please enter the city\n";
	}
	if(document.getElementById('postcode').value=='')
	{
		error+="Please enter the postcode\n";
	}

	
	if(document.getElementById('date').value=='')
	{
		error+="Please enter the date of the event\n";
	}
	if(document.getElementById('end_date').value=='')
	{
		error+="Please enter the end date of the event\n";
	}
	if(document.getElementById('start_time_h').value=='')
	{
		error+="Please enter the start time hour of the event\n";
	}
	if(document.getElementById('start_time_m').value=='')
	{
		error+="Please enter the start time minute of the event\n";
	}
	
	if(document.getElementById('end_time_h').value=='')
	{
		error+="Please enter the end time hour of the event\n";
	}
	if(document.getElementById('end_time_m').value=='')
	{
		error+="Please enter the end time minute of the event\n";
	}
	
	if(error == "")
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}

function process_change_password()
{
	var error = "";
	
	if(document.getElementById('new_password').value=='')
	{
		error+="Please enter new password\n";
	}
	if(document.getElementById('confirm_password').value=='')
	{
		error+="Please confirm your password\n";
	}
	if(document.getElementById('new_password').value!='' && document.getElementById('confirm_password').value!='' && document.getElementById('new_password').value != document.getElementById('confirm_password').value)
	{
		error+="Your passwords do not match\n";
	}
	
	if(error == "")
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}
function toggle_event_booking_page_options(option)
{
	document.getElementById('external_url_field').style.display = 'none';
	document.getElementById('total_ppc_budget_field').style.display = 'none';
	document.getElementById('daily_ppc_budget_field').style.display = 'none';
	
	document.getElementById('paypal_email_field').style.display = 'none';

	document.getElementById('external_url').value='';
	document.getElementById('total_ppc_budget').value='';
	document.getElementById('daily_ppc_budget').value='';
	
	if(option.value=="housevents" && document.getElementById('event_payment_type').value=='paid')
	{
		document.getElementById('ticket_price_field').style.display = 'block';
		document.getElementById('paypal_email_field').style.display = 'block';
	
	}
	else if(option.value=="external_url")
	{
		document.getElementById('external_url_field').style.display = 'block';
		document.getElementById('total_ppc_budget_field').style.display = 'block';
		document.getElementById('daily_ppc_budget_field').style.display = 'block';
	
	}
}

function toggle_event_payment_options(option)
{

	document.getElementById('booking_page_field').style.display = 'none';
	document.getElementById('external_url_field').style.display = 'none';
	document.getElementById('ticket_price_field').style.display = 'none';
	document.getElementById('paypal_email_field').style.display = 'none';
	document.getElementById('total_ppc_budget_field').style.display = 'none';
	document.getElementById('daily_ppc_budget_field').style.display = 'none';
	
	document.getElementById('booking_page').value='';
	document.getElementById('paypal_email').value='';
	document.getElementById('external_url').value='';
	document.getElementById('ticket_price').value='';
	document.getElementById('total_ppc_budget').value='';
	document.getElementById('daily_ppc_budget').value='';

	if(option.value=="paid")
	{
		document.getElementById('booking_page_field').style.display = 'block';
		document.getElementById('ticket_price_field').style.display = 'block';
	}
	else if(option.value=="free")
	{
		document.getElementById('booking_page_field').style.display = 'block';
	}
}


function toggle_template_banners(to_show, dimensions)
{
	for(x=1;x<=3;x++)
	{
		document.getElementById('template_'+x+'_banners').style.display = 'none';
		document.getElementById('template_banner_'+x+'_1').checked = false;
		document.getElementById('template_banner_'+x+'_2').checked = false;
		document.getElementById('template_banner_'+x+'_3').checked = false;
	}
	document.getElementById('template_'+to_show+'_banners').style.display = 'block';
	document.getElementById('upload_banner_dimensions').innerHTML = dimensions;
}
var add_another_cnt_location= 0;	
var add_another_cnt_speaker= 0;
var add_another_cnt_sponsor= 0;
var add_another_cnt_category= 0;
var add_another_cnt_organiser= 0;

var add_another_cnt_document= 0;
var add_another_cnt_video= 0;
var add_another_cnt_image= 0;
var add_another_cnt_audio= 0;

var add_another_cnt = 0;
function add_another(li,basepath)
{
	
	
	switch(li)
	{
		case "user_event_speaker":
		
			add_another_cnt_speaker++;
			var new_li = add_another_cnt_speaker;
			
			$.ajax({
				type: "POST",
				url: basepath+"/process/get_user_event_speaker_options.php",
				data: "",
				success: function(html){
					var new_html = '<label for="'+li+'_'+new_li+'">Event speaker of interest</label>';
					new_html += '<select name="'+li+'[]" id="'+li+'_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\''+li+'_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\''+li+'_message_'+new_li+'\').style.display=\'none\';" >';
					new_html += '<option value=""></option>';
					new_html += html;
					new_html += '</select>';
					new_html += '<div class="input_message" id="'+li+'_message_'+new_li+'">Please select a speaker</div></li>';
					new_html += '<li id="add_another_'+li+'_'+new_li+'">';
					new_html += '<a class="add_another_link" href="javascript:add_another(\''+li+'\',\''+basepath+'\');">Add Another</a>';
							
					document.getElementById('add_another_'+li+'_'+(add_another_cnt_speaker-1)).innerHTML = new_html;
				}
			});
		break;
	
		case "user_event_sponsor":
			add_another_cnt_sponsor++;
			var new_li = add_another_cnt_sponsor;
			
			$.ajax({
				type: "POST",
				url: basepath+"/process/get_user_event_sponsor_options.php",
				data: "",
				success: function(html){
					var new_html = '<label for="'+li+'_'+new_li+'">Event sponsor of interest</label>';
					new_html += '<select name="'+li+'[]" id="'+li+'_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\''+li+'_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\''+li+'_message_'+new_li+'\').style.display=\'none\';" >';
					new_html += '<option value=""></option>';
					new_html += html;
					new_html += '</select>';
					new_html += '<div class="input_message" id="'+li+'_message_'+new_li+'">Please select a sponsor</div></li>';
					new_html += '<li id="add_another_'+li+'_'+new_li+'">';
					new_html += '<a href="javascript:add_another(\''+li+'\',\''+basepath+'\');">Add Another</a>';
							
					document.getElementById('add_another_'+li+'_'+(add_another_cnt_sponsor-1)).innerHTML = new_html;
				}
			});
		break;
	
		case "event_location":
			add_another_cnt_location++;
			var new_li = add_another_cnt_location;
			
			$.ajax({
				type: "POST",
				url: basepath+"/process/get_location_options.php",
				data: "",
				success: function(html){
					var new_html = '<label for="'+li+'_'+new_li+'">Event location of interest</label>';
					new_html += '<input type="text" name="'+li+'[]" id="'+li+'_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\''+li+'_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\''+li+'_message_'+new_li+'\').style.display=\'none\';" \>';
					new_html += '<div class="input_message" id="'+li+'_message_'+new_li+'">Please select a location</div></li>';
					new_html += '<li id="add_another_'+li+'_'+new_li+'">';
					new_html += '<a  class="add_another_link" href="javascript:add_another(\''+li+'\',\''+basepath+'\');">Add Another</a>';
							
					document.getElementById('add_another_'+li+'_'+(add_another_cnt_location-1)).innerHTML = new_html;
				}
			});
		break;
		case "category":
			add_another_cnt_category++;
			var new_li = add_another_cnt_category;
			
			$.ajax({
				type: "POST",
				url: basepath+"/process/get_category_options.php",
				data: "",
				success: function(html){
					var new_html = '<label for="'+li+'_'+new_li+'">Event categories of interest</label>';
					new_html += '<select name="'+li+'[]" id="'+li+'_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\''+li+'_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\''+li+'_message_'+new_li+'\').style.display=\'none\';" >';
					new_html += '<option value=""></option>';
					new_html += html;
					new_html += '</select>';
					new_html += '<div class="input_message" id="'+li+'_message_'+new_li+'">Please select a category</div></li>';
					new_html += '<li id="add_another_'+li+'_'+new_li+'">';
					new_html += '<a  class="add_another_link" href="javascript:add_another(\''+li+'\',\''+basepath+'\');">Add Another</a>';
							
					document.getElementById('add_another_'+li+'_'+(add_another_cnt_category-1)).innerHTML = new_html;
				}
			});
		break;
		case "organiser":
			add_another_cnt_organiser++;
			var new_li = add_another_cnt_organiser;
			
			$.ajax({
				type: "POST",
				url: basepath+"/process/get_organiser_options.php",
				data: "",
				success: function(html){
					var new_html = '<label for="'+li+'_'+new_li+'">Organisers of interest</label>';
					new_html += '<select name="'+li+'[]" id="'+li+'_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\''+li+'_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\''+li+'_message_'+new_li+'\').style.display=\'none\';" >';
					new_html += '<option value=""></option>';
					new_html += html;
					new_html += '</select>';
					new_html += '<div class="input_message" id="'+li+'_message_'+new_li+'">Please select an organiser</div></li>';
					new_html += '<li id="add_another_'+li+'_'+new_li+'">';
					new_html += '<a class="add_another_link" href="javascript:add_another(\''+li+'\',\''+basepath+'\');">Add Another</a>';
							
					document.getElementById('add_another_'+li+'_'+(add_another_cnt_organiser-1)).innerHTML = new_html;
				}
			});
		break;
		case "event_speaker":
			
			var new_html = '<label for="'+li+'_'+new_li+'">Full Name</label>';
			new_html +=	'<input type="text" name="event_speaker_name[]" id="event_speaker_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'event_speaker_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'event_speaker_message_'+new_li+'\').style.display=\'none\';" />';
			new_html +=	'<div class="input_message" id="event_speaker_message_'+new_li+'">Name of the speaker</div>';
			new_html +=	'</li>';
			new_html +=	'<li>';
			new_html +=	'<label for="biography_'+new_li+'">Biography</label>';
			new_html +=	'<textarea name="biography[]" id="biography_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'biography_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'biography_message_'+new_li+'\').style.display=\'none\';"></textarea>';
			new_html +=	'<div class="input_message" id="biography_message_'+new_li+'">Summary about the speaker</div>';
			new_html += '<li id="add_another_'+li+'_'+new_li+'">';
			new_html += '<a class="add_another_link" href="javascript:add_another(\''+li+'\');">Add Another</a>';
			document.getElementById('add_another_'+li+'_'+(add_another_cnt-1)).innerHTML = new_html;
		break;
		
		case "event_press":
			add_another_cnt++;
			var new_li = add_another_cnt;
			var new_html = '<label for="'+li+'_'+new_li+'">Title</label>';
			new_html +=	'<input type="text" name="title[]" id="title_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'title_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'title_message_'+new_li+'\').style.display=\'none\';" />';
			new_html +=	'<div class="input_message" id="title_message_'+new_li+'">Title of the product</div>';
			new_html +=	'</li>';
			new_html +=	'<li>';
			new_html +=	'<label for="description_'+new_li+'">Description</label>';
			new_html +=	'<textarea name="description[]" id="description_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'description_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'description_message_'+new_li+'\').style.display=\'none\';"></textarea>';
			new_html +=	'<div class="input_message" id="description_message_'+new_li+'">Summary about the product</div>';
			new_html +=	'</li>';
			new_html +=	'<li>';
			new_html +=	'<label for="url_'+new_li+'">URL</label>';
			new_html +=	'<input type="text" name="url[]" id="url_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'url_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'url_message_'+new_li+'\').style.display=\'none\';" />';
			new_html +=	'<div class="input_message" id="url_message_'+new_li+'">URL of the product</div>';
			new_html += '<li id="add_another_'+li+'_'+new_li+'">';
			new_html += '<a class="add_another_link" href="javascript:add_another(\''+li+'\');">Add Another</a>';
			document.getElementById('add_another_'+li+'_'+(add_another_cnt-1)).innerHTML = new_html;
		break;
		
		case "event_product":
		case "event_sponsor":
			add_another_cnt++;
			var new_li = add_another_cnt;
			var new_html = '<label for="'+li+'_'+new_li+'">Title '+add_another_cnt+'</label>';
			new_html +=	'<input type="text" name="title[]" id="title_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'title_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'title_message_'+new_li+'\').style.display=\'none\';" />';
			new_html +=	'<div class="input_message" id="title_message_'+new_li+'">Title of the product</div>';
			new_html +=	'</li>';
			new_html +=	'<li>';
			new_html +=	'<label for="description_'+new_li+'">Description '+add_another_cnt+'</label>';
			new_html +=	'<textarea name="description[]" id="description_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'description_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'description_message_'+new_li+'\').style.display=\'none\';"></textarea>';
			new_html +=	'<div class="input_message" id="description_message_'+new_li+'">Summary about the product</div>';
			new_html +=	'</li>';
			new_html +=	'<li>';
			new_html +=	'<label for="url_'+new_li+'">External product URL '+add_another_cnt+'</label>';
			new_html +=	'<input type="text" name="url[]" id="url_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'url_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'url_message_'+new_li+'\').style.display=\'none\';" />';
			new_html +=	'<div class="input_message" id="url_message_'+new_li+'">URL of the product</div>';
			new_html +=	'</li>';
			new_html +=	'<li>';
			new_html +=	'<label for="file">Product Image '+add_another_cnt+'</label>';
			new_html +=	'<input type="file" name="image[]" id="file_'+add_another_cnt+'" class="textbox"  />';
			new_html +=	'<div class="input_message" id="image_message_'+add_another_cnt+'">Image</div>';
			new_html +=	'</li>';
			new_html += '<li id="add_another_'+li+'_'+new_li+'">';
			new_html += '<a class="add_another_link" href="javascript:add_another(\''+li+'\');">Add Another</a>';
			document.getElementById('add_another_'+li+'_'+(add_another_cnt-1)).innerHTML = new_html;
		break;
			
		
		case "event_programme":
			add_another_cnt++;
			var new_li = add_another_cnt;
			var new_html = '<label for="'+li+'_'+new_li+'">Title</label>';
			new_html +=	'<input type="text" name="title[]" id="title_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'title_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'title_message_'+new_li+'\').style.display=\'none\';" />';
			new_html +=	'<div class="input_message" id="title_message_'+new_li+'">Title of the programme</div>';
			new_html +=	'</li>';
			new_html +=	'<li>';
			new_html +=	'<label for="start_time_'+new_li+'">Start Time</label>';
			new_html +=	'<select name="start_time_h_'+new_li+'" id="start_time_h_'+new_li+'" class="textbox time" onfocus="this.className=\'textbox active time\';document.getElementById(\'start_time_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox time\';document.getElementById(\'start_time_message_'+new_li+'\').style.display=\'none\';">';
			new_html +=	'<option value=""></option>';
						
			for(h=1;h<=24;h++)
			{
				var hour = h<10 ? "0"+h : h;
				new_html +=	'<option value="'+hour+'">'+hour+'</option>';
			}
			new_html +=	'</select>';
			new_html +=	'<select name="start_time_m_'+new_li+'" id="start_time_m_'+new_li+'" class="textbox time" onfocus="this.className=\'textbox active time\';document.getElementById(\'start_time_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox time\';document.getElementById(\'start_time_message_'+new_li+'\').style.display=\'none\';">';
			new_html +=	'<option value=""></option>';
						
			for(m=0;m<60;m=m+15)
			{
				var min = m<10 ? "0"+m : m;
				new_html +=	'<option value="'+m+'">'+min+'</option>';
			}
			new_html +=	'</select>';
			new_html +=	'<div class="input_message" id="start_time_message_'+new_li+'">Please enter the start time of the event</div>';
			new_html +=	'</li>';
			new_html +=	'<li>';
			new_html +=	'<label for="end_time_'+new_li+'">End Time</label>';
			new_html +=	'<select name="end_time_h_'+new_li+'" id="end_time_h_'+new_li+'" class="textbox time" onfocus="this.className=\'textbox active time\';document.getElementById(\'end_time_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox time\';document.getElementById(\'end_time_message_'+new_li+'\').style.display=\'none\';">';
			new_html +=	'<option value=""></option>';
						
			for(h=1;h<=24;h++)
			{
				var hour = h<10 ? "0"+h : h;
				new_html += '<option value="'+hour+'">'+hour+'</option>';
				
			}

			new_html +=	'</select>';
			new_html +=	'<select name="end_time_m_'+new_li+'" id="end_time_m_'+new_li+'" class="textbox time" onfocus="this.className=\'textbox active time\';document.getElementById(\'end_time_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox time\';document.getElementById(\'end_time_message_'+new_li+'\').style.display=\'none\';">';
			new_html +=	'<option value=""></option>';
						
			for(m=0;m<60;m=m+15)
			{
				var min = m<10 ? "0"+m : m;
				new_html +=	'<option value="'+min+'">'+min+'</option>';
			}
			new_html +=	'</select>';
			new_html +=	'<div class="input_message" id="end_time_message_'+new_li+'">Please enter the end time of the programme item</div>';
			new_html +=	'</li>';
			new_html +=	'<li>';
			new_html +=	'<label for="description_'+new_li+'">Description</label>';
			new_html +=	'<textarea name="description[]" id="description_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'description_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'description_message_'+new_li+'\').style.display=\'none\';"></textarea>';
			new_html +=	'<div class="input_message" id="description_message_'+new_li+'">Summary about the programme</div>';
			new_html +=	'</li>';
			//new_html +=	'<li>';
			//new_html +=	'<label for="url_'+new_li+'">URL</label>';
			//new_html +=	'<input type="text" name="url[]" id="url_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'url_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'url_message_'+new_li+'\').style.display=\'none\';" />';
			//new_html +=	'<div class="input_message" id="url_message_'+new_li+'">URL of the programme</div>';
			new_html += '<li id="add_another_'+li+'_'+new_li+'">';
			new_html += '<a class="add_another_link" href="javascript:add_another(\''+li+'\');">Add Another</a>';
			document.getElementById('add_another_'+li+'_'+(add_another_cnt-1)).innerHTML = new_html;
		break;
		
		case "event_document":
		
			add_another_cnt_document++;
			
			var new_li = add_another_cnt_document;
			var new_html = '';
			new_html += '<label for="file">Upload Event Document '+add_another_cnt_document+'</label>';
			new_html += '<input type="file" name="document[]" id="file_'+new_li+'" class="textbox"  />';
			new_html += '</li><li>';
			new_html += '<label for="document_description">Document Description</label>';
			new_html += '<textarea name="document_description[]" id="document_description_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'document_description_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'document_description_message_'+new_li+'\').style.display=\'none\';" ></textarea>';
			new_html += '<div class="input_message" id="document_description_message_'+new_li+'">Please add the document description</div>';
			new_html += '</li>';
			new_html += '<li id="add_another_'+li+'_'+new_li+'">';
			new_html += '<a class="add_another_link" href="javascript:add_another(\''+li+'\');">Add Another</a>';
			document.getElementById('add_another_'+li+'_'+(add_another_cnt_document-1)).innerHTML = new_html;
		break;
		
		case "event_video":
			add_another_cnt_video++;
			var new_li = add_another_cnt_video;
			var new_html = '';
			new_html += '<label for="file">Upload Event video '+add_another_cnt_video+'</label>';
			new_html += '<input type="file" name="video[]" id="file_'+new_li+'" class="textbox"  />';
			new_html += '</li>';
			new_html += '<li>';
			new_html += '<label for="video_description">Document Description</label>';
			new_html += '<textarea name="video_description[]" id="video_description_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'video_description_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'video_description_message_'+new_li+'\').style.display=\'none\';" ></textarea>';
			new_html += '<div class="input_message" id="video_description_message_'+new_li+'">Please add the video description</div>';
			new_html += '</li>';
			new_html += '<li id="add_another_'+li+'_'+new_li+'">';
			new_html += '<a class="add_another_link" href="javascript:add_another(\''+li+'\');">Add Another</a>';
			document.getElementById('add_another_'+li+'_'+(add_another_cnt_video-1)).innerHTML = new_html;
		break;
		case "event_image":
			add_another_cnt_image++;
			var new_li = add_another_cnt_image;
			var new_html = '';
			new_html += '<label for="file">Upload Event image '+add_another_cnt_image+'</label>';
			new_html += '<input type="file" name="image[]" id="file_'+new_li+'" class="textbox"  />';
			new_html += '</li>';
			new_html += '<li>';
			new_html += '<label for="image_description">Document Description</label>';
			new_html += '<textarea name="image_description[]" id="image_description_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'image_description_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'image_description_message_'+new_li+'\').style.display=\'none\';" ></textarea>';
			new_html += '<div class="input_message" id="image_description_message_'+new_li+'">Please add the image description</div>';
			new_html += '</li>';	
			new_html += '<li id="add_another_'+li+'_'+new_li+'">';
			new_html += '<a class="add_another_link" href="javascript:add_another(\''+li+'\');">Add Another</a>';
			document.getElementById('add_another_'+li+'_'+(add_another_cnt_image-1)).innerHTML = new_html;
		break;
		case "event_audio":
			add_another_cnt_audio++;
			var new_li = add_another_cnt_audio;
			var new_html = '';
			new_html += '<label for="file">Upload Event audio '+add_another_cnt_audio+'</label>';
			new_html += '<input type="file" name="audio[]" id="file_'+new_li+'" class="textbox"  />';
			new_html += '</li>';
			new_html += '<li>';
			new_html += '<label for="audio_description">Document Description</label>';
			new_html += '<textarea name="audio_description[]" id="audio_description_'+new_li+'" class="textbox" onfocus="this.className=\'textbox active\';document.getElementById(\'audio_description_message_'+new_li+'\').style.display=\'block\';" onblur="this.className=\'textbox\';document.getElementById(\'audio_description_message_'+new_li+'\').style.display=\'none\';" ></textarea>';
			new_html += '<div class="input_message" id="audio_description_message_'+new_li+'">Please add the audio description</div>';
			new_html += '</li>';
			new_html += '<li id="add_another_'+li+'_'+new_li+'">';
			new_html += '<a class="add_another_link" href="javascript:add_another(\''+li+'\');">Add Another</a>';
			document.getElementById('add_another_'+li+'_'+(add_another_cnt_audio-1)).innerHTML = new_html;
		break;
		
	}
	
	
	
}

function swapimage(src) 
{
   document.getElementById('p_image').src = src;
   return(false);
}


function generate_support_filters(basepath)
{

	$.ajax({
		type: "POST",
		url: basepath+"/process/generate_support_filters.php",
		data: $("#support_search_form").serialize(),
		success: function(html){
			document.getElementById('support_search_filter_container').innerHTML = html
		}
	});
}

function addamend_event_discounts()
{
	var error = "";
	var chk = /^\d.+$/.test(document.getElementById('ticket_discount_percentage').value);
	var chk_promo = /^\d.+$/.test(document.getElementById('promo_code_percentage').value);
	if(!chk && document.getElementById('ticket_discount_percentage').value!='')
	{	
		error+="Please enter numeric characters only for discount percentages\n";
	}
	if(!chk_promo && document.getElementById('promo_code_percentage').value!='')
	{	
		error+="Please enter numeric characters only for discount percentages\n";
	}
	
	if(error != "")
	{
		alert(error);
		return false;
	}
	else
	{
		return true;
	}
	
}
function process_my_details()
{
	var error = "";
	var RE_EMAIL = /^(\w+[\-\.])*\w+@(\w+[\-\.])+[A-Za-z]+$/;
	if(document.getElementById('first_name').value=='')
	{
		error+="Please enter your first name\n";
	}
	if(document.getElementById('last_name').value=='')
	{
		error+="Please enter your last name\n";
	}
	if(document.getElementById('email').value=='')
	{
		error+="Please enter your email address\n";
	}
	else if(!RE_EMAIL.test(document.getElementById('email').value)) 
	{
		error+="Please enter a valid email address\n";
	}
	var chk = /^\d+$/.test(document.getElementById('tel').value);
	
	if(!chk && document.getElementById('tel').value!='')
	{
	
		error+="Please enter numeric characters only";
	}
	
	if(document.getElementById('change_password').checked==true)
	{
		if(document.getElementById('create_password').value=='')
		{
			error+="Please enter your password\n";
		}
		if(document.getElementById('confirm_password').value=='')
		{
			error+="Please confirm your password\n";
		}
		if(document.getElementById('create_password').value!='' && document.getElementById('confirm_password').value!='' && document.getElementById('create_password').value != document.getElementById('confirm_password').value)
		{
			error+="Your passwords do not match\n";
		}
		
	}
	if(error == "")
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}
function process_register_form()
{
	var error = "";
	var RE_EMAIL = /^(\w+[\-\.])*\w+@(\w+[\-\.])+[A-Za-z]+$/;
	if(document.getElementById('first_name').value=='')
	{
		error+="Please enter your first name\n";
	}
	if(document.getElementById('last_name').value=='')
	{
		error+="Please enter your last name\n";
	}
	if(document.getElementById('email').value=='')
	{
		error+="Please enter your email address\n";
	}
	else if(!RE_EMAIL.test(document.getElementById('email').value)) 
	{
		error+="Please enter a valid email address\n";
	}
	if(document.getElementById('create_password').value=='')
	{
		error+="Please enter your password\n";
	}
	if(document.getElementById('confirm_password').value=='')
	{
		error+="Please confirm your password\n";
	}
	if(document.getElementById('create_password').value!='' && document.getElementById('confirm_password').value!='' && document.getElementById('create_password').value != document.getElementById('confirm_password').value)
	{
		error+="Your passwords do not match\n";
	}
	if(document.getElementById('tandc').checked==false)
	{
		error+="Please indicate you have understood and agree to the terms and conditions\n";
	}
	if(error == "")
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}


function process_change_password()
{
	var error = "";
	if(document.getElementById('new_password').value=='')
	{
		error+="Please enter your new password\n";
	}
	if(document.getElementById('confirm_password').value=='')
	{
		error+="Please confirm your new password\n";
	}
	if(document.getElementById('new_password').value!='' && document.getElementById('confirm_password').value!='' && document.getElementById('new_password').value != document.getElementById('confirm_password').value)
	{
		error+="Your passwords do not match\n";
	}
	if(error == "")
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}


function search_suggest(basepath,site_section_id)
{

	$.ajax({
		type: "POST",
		url: basepath+"/process/live_search.php",
		data: $("#search_text").serialize(),
		success: function(html){
			var a = new Array();
			a = html.split('|');
			if(a[0]==1)
			{		
				document.getElementById('live_search_results').style.display = 'block';
				document.getElementById('live_search_results').innerHTML = a[1]
			}
			else
			{
				document.getElementById('live_search_results').style.display = 'none';
			}
		}
	});
}
function open_login_form(basepath,site_section_name)
{
document.getElementById('login_btn').innerHTML="<a href=\"javascript:void(0);\" onclick=\"close_login_form('"+basepath+"','"+site_section_name+"');\"><img src=\""+basepath+"/image/login_close_"+site_section_name+".gif\" /></a>";
	
	
	$("#login_btn").click(function(){
      $("#login_form_drop_down").animate({ 
        height: "108px"
      }, 200 );
    });
    document.getElementById('login_form_drop_down').style.display = 'block';
    
}
function close_login_form(basepath,site_section_name)
{

document.getElementById('login_btn').innerHTML="<a href=\"javascript:void(0);\" onclick=\"open_login_form('"+basepath+"','"+site_section_name+"');\"><img src=\""+basepath+"/image/login_"+site_section_name+".gif\" /></a>";
    
	$("#login_btn").click(function(){
      $("#login_form_drop_down").slideUp("slow");
    });
    document.getElementById('login_form_drop_down').style.display = 'none';
    jQuery.fx.off = true;
}


function show_home_trans(dir)
{
	$("#home_trans_text_"+dir).slideDown("slow");
}
function hide_home_trans(dir)
{
	$("#home_trans_text_"+dir).slideUp("slow");
}
function get_object(id) {
			var object = null;
			if( document.layers )	{			
				object = document.layers[id];
			} else if( document.all ) {
				object = document.all[id];
			} else if( document.getElementById ) {
				object = document.getElementById(id);
			}
			return object;
		}
		function is_child_of(parent, child) {
			if( child != null ) {			
				while( child.parentNode ) {
					if( (child = child.parentNode) == parent ) {
						return true;
					}
				}
			}
			return false;
		}
		function fixOnMouseOut(element, event, JavaScript_code) {
			var current_mouse_target = null;
			if( event.toElement ) {				
				current_mouse_target 			 = event.toElement;
			} else if( event.relatedTarget ) {				
				current_mouse_target 			 = event.relatedTarget;
			}
			if( !is_child_of(element, current_mouse_target) && element != current_mouse_target ) {
				eval(JavaScript_code);
			}
		}
	/* below function is added by pankaj to set the textarea limit of character's to 150 */
		
		function ismaxlength(obj){
			var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
			if (obj.getAttribute && obj.value.length>mlength)
			obj.value=obj.value.substring(0,mlength)
			}	