var $selects = {};var scrollMin;var scrollMax;var scrollTimerId;var scp;$.fn.br2nl = function(){   return this.each(function(){     $(this).val($(this).val().replace(/(<br>)|(&lt;br&gt;)|(<br \/>)|(<p>)|(<\/p>)/g, "\r\n"));   });};function formTweak(){	if ($.browser.safari) {		$('#catalogue_div select').css({background:'none'});		$('#customize_div div.fieldset div.input select').css({background:'none'});		$('#login_div .form_box label.small').css({'vertical-align':'middle'});	}}function dateWidget(){	$('#project_deadline').datepicker({ dateFormat: 'dd/mm/yy' });	$('#cue_deadline').datepicker({ dateFormat: 'dd/mm/yy' });}function formCheckInit(){	$('#customize_form').validationEngine({promptPosition : "bottomLeft:+0,-20", scroll: false, validationEventTrigger: ''});}function listScroll(){	formTweak();	$('#titles').css({top:'0'});	if($('#titles_list').length > 0){		$('#arrow_down,#arrow_up').css({display:'none'});		if($('#titles').height() > $('#titles_box').height()){			$('#arrow_down').css({display:'block'});		}		scrollMin = $('#titles_box').height() - $('#titles').height();		scrollMax = 0;	}}function listScrollMove(dir){	speed = 5;	offset = dir * speed;	y = $('#titles').position().top;	$('#titles').css({top:y+offset});	if (dir < 0){		if ($('#titles').position().top < scrollMin){			$('#titles').css({top:scrollMin});			$('#arrow_down').css({display:'none'});		}	}	if (dir > 0){		if ($('#titles').position().top > scrollMax){			$('#titles').css({top:scrollMax});			$('#arrow_up').css({display:'none'});		}	}	if($('#titles').position().top < scrollMax){		$('#arrow_up').css({display:'block'});	}	if($('#titles').position().top > scrollMin){		$('#arrow_down').css({display:'block'});	}	f = "listScrollMove(" + dir + ")";	scrollTimerId = setTimeout( f, 20 );}function aboutAdmin(){	$html = $('#about_div').html();	$('#about_div').html('<form id="aboutform" accept-charset="utf-8" method="post" action="' + $baseurl + 'admin/about_submit.html"><textarea name="about_text" id="about_text" method="post" action="#"></textarea><button type="submit">Update</button></form>');	$('#about_text').val($html);	aboutArr = $('#about_text').rte({		base_url: $baseurl_nosl,		css: [$baseurl + 'css/default.css'],		controls_rte: rte_toolbar,		controls_html: html_toolbar,		width: 550,		height: 195	});}function customizeAdmin(){	$html = $('#customize_div .note_box').html();	$('#customize_div .note_box').html('<form id="customizeform" accept-charset="utf-8" method="post" action="' + $baseurl + 'admin/customize_submit.html"><textarea name="customize_text" id="customize_text" method="post" action="#"></textarea><button type="submit">Update</button></form>');	$('#customize_text').val($html);	customizeArr = $('#customize_text').rte({		base_url: $baseurl_nosl,		css: [$baseurl + 'css/default.css'],		controls_rte: rte_toolbar,		controls_html: html_toolbar,		width: 810,		height: 85	});}function contactAdmin(){	c_html1 = $('#contact_div .address1 span.country').html();	d_html1 = $('#contact_div .address1 span.details').html();	c_html2 = $('#contact_div .address2 span.country').html();	d_html2 = $('#contact_div .address2 span.details').html();	c_html3 = $('#contact_div .address3 span.country').html();	d_html3 = $('#contact_div .address3 span.details').html();	$('#contact_div .address1').html('<form class="contact_form" accept-charset="utf-8" method="post" action="' + $baseurl + 'admin/contact_submit/1.html"><input type="text" size="26" maxlength="50" value="' + c_html1 +'" name="country"><br/><textarea name="details" cols="26" rows="4">' + d_html1 + '</textarea><br/><button type="submit">Update</button></form>');	$('#contact_div .address2').html('<form class="contact_form" accept-charset="utf-8" method="post" action="' + $baseurl + 'admin/contact_submit/2.html"><input type="text" size="26" maxlength="50" value="' + c_html2 +'" name="country"><br/><textarea name="details" cols="26" rows="4">' + d_html2 + '</textarea><br/><button type="submit">Update</button></form>');	$('#contact_div .address3').html('<form class="contact_form" accept-charset="utf-8" method="post" action="' + $baseurl + 'admin/contact_submit/3.html"><input type="text" size="26" maxlength="50" value="' + c_html3 +'" name="country"><br/><textarea name="details" cols="26" rows="4">' + d_html3 + '</textarea><br/><button type="submit">Update</button></form>');	$('.contact_form textarea').br2nl();}function newsAdmin(){	newsArr = $('#ncontent').rte({		base_url: $baseurl_nosl,		css: [$baseurl + 'css/default.css'],		controls_rte: rte_toolbar,		controls_html: html_toolbar,		width: 340,		height: 85	});}function registerAdmin(){	regArr = $('#rcontent').rte({		base_url: $baseurl_nosl,		css: [$baseurl + 'css/default.css'],		controls_rte: rte_toolbar,		controls_html: html_toolbar,		width: 500,		height: 175	});}function billboardCycle(){	$('.slideshow').cycle({		fx: 'scrollUp'	});}function registerOpened(hash){	$('#register_form').validationEngine({promptPosition : "bottomRight:-80,-10", scroll: false, validationEventTrigger: ''});	hash.w.show();}$(document).ready(function(){	billboardCycle();	soundcloud.debug = true;		$(document).bind('soundcloud:onPlayerReady', function(event, data) {		console.log(event.target);		var mediaUri = data.mediaUri,		mediaId   = data.mediaId,		flashNode = event.target;		if (!$admin_login){			flashNode.api_stop();		}	});	formTweak();		dateWidget();		formCheckInit();		listScroll();	if(typeof jQuery.fn.rte == 'function') {		aboutAdmin();		customizeAdmin();	}		$('.cues a.cue').live('click',function(){		timecode = $(this).attr('alt');		sc = soundcloud.getPlayer('scPlayer');		sc.api_play();		sc.api_seekTo(timecode);	});		$('#titles a').live('click',function(event){		event.preventDefault();		$('#titles a').removeClass('active');		$(this).addClass('active');		$href = $(this).attr('href');				// "_trackEvent" is the pageview event, 		_gaq.push(['_trackPageview', $href]);				$('#title_details').html("");		$.post($href, function(data){			if (data.error == 'none'){				content = $(data.content).find('#title_details').html();				$('#title_details').html(content);				if(data.admin == 'true'){					$('span#admin').css({'display':'inline'});				}				else {					$('span#admin').css({'display':'none'});				}				if(data.session == 'true'){					$('#bottom_menu').css({'display':'block'});				}				else {					$('#bottom_menu').css({'display':'none'});				}				if((data.admin == 'true')&&(data.session == 'true')){					$admin_login = true;				}				else {					$admin_login = false;				}			}		});	});		$('select#titles_genre').live('change',function(){		genre = $(this).val();		if(genre != ""){			$('#titles a').css({display:'none'});			$('#titles a.'+genre).css({display:'block'});		}		else {			$('#titles a').css({display:'block'});		}		listScroll();	});	$('#arrow_down').live('mouseover',function(){		listScrollMove(-1);	});		$('#arrow_up').live('mouseover',function(){		listScrollMove(1);	});		$('#arrow_down,#arrow_up').live('mouseout',function(){		clearTimeout ( scrollTimerId );	});		$('.formError').live('mouseover',function(){		$('#customize_form ').validationEngine('hideAll');		$('#register_form ').validationEngine('hideAll');	});		$('input#project_type,input#project_genre').live('focus',function(){		$(this).css({color:'#444444'});		if($(this).val() == "Other (Please specify)"){			$(this).val("");		}	});			$('#register').live('click',function(){		$('#register_popup').jqm({modal:true,onShow:registerOpened,overlay:80});		$('#register_popup').jqmShow();		return false;	});		$('#register_popup #cancel_button').live('click',function(){		$('#register_form').get(0).reset();		$('#register_popup').jqmHide();	});		$('#customize_form select').live('change',function(){		$val = $(this).val();		$name = $(this).attr('name');		if($val == "Other"){			$selects[$name] = this;			$(this).replaceWith('<input id="'+$name+'" type="text" class="validate[required,custom[other]]" size="45" maxlength="100" style="color:#AAAAAA;" value="Other (Please specify)" name="'+$name+'">');		}	});		$('#reset_button').live('click',function() {		$('input#project_type').replaceWith($selects['project_type']);		$('input#project_genre').replaceWith($selects['project_genre']);		$('input').css({color:'#444444'});		$('#customize_form ').validationEngine('hideAll');	});		$('.close_thank_request').live('click',function() { 		$.unblockUI();		$('#customize_form').get(0).reset();		return false;     });		$('.close_thank_register').live('click',function() { 		$.unblockUI();		$('#register_popup').jqmHide();		return false;     }); 		$('div.button').mouseenter(function(){			$(this).find('.glow').css({left:'-150px'});			$(this).find('.glow').animate({left:'130px'},800);	});		$('#'+$currentpage+'_but').css({opacity:1});	if($currentpage != 'intro'){		$('#logo').css({'visibility':'visible','height':'145px'});	}		$('#copyright_form').live('submit',function(event){		event.preventDefault();		$href = $(this).attr('action');		$content = $('#ccontent').val();		$('div#form').html('Updating! Please wait...');		$.post($href, {content: $content} ,function(data){			if (data.error == 'none'){				$('#div_to_popup').jqmHide();				switch(data.mode){					case "update":						$('#copyright').html(data.content);						break;				}			}			else {				$('div#form').html('ERROR! Please try again!');			}		});	});		$('#user_form').live('submit',function(event){		event.preventDefault();		$href = $(this).attr('action');		$name = $('#name').val();		$username = $('#username').val();		$password = $('#password').val();		$admin = '';		if($('#admin_check:checked').length > 0){			$admin = 'yes'		}		$('div#form').html('Updating! Please wait...');		$.post($href, {name: $name, username: $username, password: $password, admin: $admin} ,function(data){			if (data.error == 'none'){				$('#div_to_popup').jqmHide();				switch(data.mode){					case "new":						$('#users_div #users').append(data.content);						break;					case "update":						$('#user_box_'+data.user_id).html(data.content);						break;				}			}			else {				$('div#form').html('ERROR! Please try again!');			}		});	});		$('#genre_form').live('submit',function(event){		event.preventDefault();		$href = $(this).attr('action');		$label = $('#label').val();		$('div#form').html('Updating! Please wait...');		$.post($href, {label: $label} ,function(data){			if (data.error == 'none'){				$('#div_to_popup').jqmHide();				switch(data.mode){					case "new":						$('#genres_div #genres').append(data.content);						break;					case "update":						$('#genre_box_'+data.genre_id).html(data.content);						break;				}			}			else {				$('div#form').html('ERROR! Please try again!');			}		});	});		$('#type_form').live('submit',function(event){		event.preventDefault();		$href = $(this).attr('action');		$label = $('#label').val();		$('div#form').html('Updating! Please wait...');		$.post($href, {label: $label} ,function(data){			if (data.error == 'none'){				$('#div_to_popup').jqmHide();				switch(data.mode){					case "new":						$('#types_div #types').append(data.content);						break;					case "update":						$('#type_box_'+data.type_id).html(data.content);						break;				}			}			else {				$('div#form').html('ERROR! Please try again!');			}		});	});		$('#news_form').live('submit',function(event){		event.preventDefault();		$href = $(this).attr('action');		$date = $('#ndate').val();		$title = $('#ntitle').val();		$content = newsArr['ncontent'].get_content();		//$('div#form').html('Updating! Please wait...');		$.blockUI({message:'Updating! Please wait...'});		$.post($href, {date: $date, title: $title, content: $content} ,function(data){			if (data.error == 'none'){				switch(data.mode){					case "new":						$('#news_div #news_boxes').prepend('<div class="hr" ><!-- --></div>');						$('#news_div #news_boxes').prepend(data.content);						break;					case "update":						$('#news_box_' + data.news_id).html(data.content);						break;				}				$('#div_to_popup').jqmHide();				$.unblockUI();			}			else {				//$('div#form').html('ERROR! Please try again!');				$.unblockUI();				$.blockUI({timeout:2000,message:'ERROR ! Please retry !'});			}		});	});		$('a.ajax_but2').live('click',function(event){		event.preventDefault();		$href = $(this).attr('href');		$alt = $(this).attr('alt');		switch($alt){			case "delete":				$('.cues').block({ message: 'Deleting! Please wait...' });				break;		}		$.post($href,function(data){			if (data.error == 'none'){				switch(data.mode){					case "delete_chapter":						$(".cues").unblock();						$("#cue"+data.chap_id).remove();						break;				}			}			else {				switch(data.mode){					case "delete_chapter":						$(".cues").unblock();						$(".cues").block({timeout:2000,message:'ERROR ! Please retry !'});						break;				}			}		});	});		$('.ajax_but').live('click',function(event){		event.preventDefault();		$href = $(this).attr('href');		$alt = $(this).attr('alt');		switch($alt){			case "delete":				$box = $(this).parent().parent();				$box.block({ message: 'Deleting! Please wait...' });				break;			case "add_row":				$.blockUI({ message: 'Adding a new row! Please wait...' });				break;			case "delete_row":				$.blockUI({ message: 'Deleting row! Please wait...' });				break;			case "move_thumb":				$.blockUI({ message: 'Moving credits! Please wait...' });				break;			case "delete_billboard":				$.blockUI({ message: 'Deleting billboard! Please wait...' });				break;			case "move_billboard":				$.blockUI({ message: 'Moving billboard! Please wait...' });				break;		}		$.post($href,function(data){			if (data.error == 'none'){				switch(data.mode){					case "delete_user":						$("#user_box_"+data.user_id).remove();						break;					case "delete_catalogue_genre":					case "delete_genre":						$("#genre_box_"+data.genre_id).remove();						break;					case "delete_type":						$("#type_box_"+data.type_id).remove();						break;					case "delete_news":						if($("#news_box_"+data.news_id).next("div.hr").length > 0){							$("#news_box_"+data.news_id).next("div.hr").remove();						}						else {							$("#news_box_"+data.news_id).prev("div.hr").remove();						}						$("#news_box_"+data.news_id).remove();						break;					case "delete_title":						$('#a'+data.title_id).remove();						$('#title_details').html("");						listScroll();						break;					case "add_row":					case "delete_row":					case "move_thumb":						$('#content').html(data.content);						$.unblockUI();						break;					case "move_billboard":					case "delete_billboard":						bills = $(data.content).find('#billboards').html();						$('#billboards').html(bills);						$.unblockUI();						break;				}			}			else {				switch(data.mode){					case "delete_user":						$("#user_box_"+data.user_id).unblock();						$("#user_box_"+data.user_id).block({timeout:2000,message:'ERROR ! Please retry !'});						break;					case "delete_catalogue_genre":					case "delete_genre":						$("#genre_box_"+data.genre_id).unblock();						$("#genre_box_"+data.genre_id).block({timeout:2000,message:'ERROR ! Please retry !'});						break;					case "delete_type":						$("#type_box_"+data.type_id).unblock();						$("#type_box_"+data.type_id).block({timeout:2000,message:'ERROR ! Please retry !'});						break;					case "delete_news":						$("#news_box_"+data.news_id).unblock();						$("#news_box_"+data.news_id).block({timeout:2000,message:'ERROR ! Please retry !'});						break;					case "delete_title":						$('#title_details').unblock();						$('#title_details').block({timeout:2000,message:'ERROR ! Please retry !'});						break;					case "add_row":					case "delete_row":					case "move_thumb":					case "move_billboard":					case "delete_billboard":						$.blockUI({timeout:2000,message:'ERROR ! Please retry !'});						break;				}			}		});	});		$('#aboutform').live('submit',function(event){		event.preventDefault();		$.blockUI({message:'Updating! Please wait...'});				$href = $baseurl + 'admin/about_submit';		$.post($href, {about_text: aboutArr['about_text'].get_content()} ,function(data){			if (data.error == 'none'){				$.unblockUI();			}			else {				$.unblockUI();				$.blockUI({timeout:2000,message:'ERROR ! Please retry !'});			}		});	});		$('#customizeform').live('submit',function(event){		event.preventDefault();		$.blockUI({message:'Updating! Please wait...'});				$href = $baseurl + 'admin/customize_submit';		$.post($href, {customize_text: customizeArr['customize_text'].get_content()} ,function(data){			if (data.error == 'none'){				$.unblockUI();			}			else {				$.unblockUI();				$.blockUI({timeout:2000,message:'ERROR ! Please retry !'});			}		});	});		$('.contact_form').live('submit',function(event){		event.preventDefault();		$.blockUI({message:'Updating! Please wait...',overlayCSS: { backgroundColor: '#FFF',opacity:0.9 },css: {padding:'5px',border:'1px solid #DDD'}});				$(this).ajaxSubmit({			success: function(data){				if (data.error == 'none'){					$.blockUI({timeout:3000,overlayCSS: { backgroundColor: '#FFF',opacity:0.9 },css: {padding:'5px',border:'1px solid #DDD'},message:'Update successful !!!'});				}				else {					$.blockUI({timeout:3000,overlayCSS: { backgroundColor: '#FFF',opacity:0.9 },css: {padding:'5px',border:'1px solid #DDD'},message:'ERROR ! Please retry !'});				}			},			error: function(){				$.blockUI({timeout:3000,overlayCSS: { backgroundColor: '#FFF',opacity:0.9 },css: {padding:'5px',border:'1px solid #DDD'},message:'ERROR ! Please retry !'});			}		}); 	});		$('#loginform').live('submit',function(event){		// "_trackEvent" is the pageview event, 		_gaq.push(['_trackPageview', $(this).attr('action')]);				event.preventDefault();		$(this).ajaxSubmit({			success: function(data){				if (data.error == 'none'){					if(data.admin == 'true'){						$('span#admin').css({'display':'inline'});					}					else {						$('span#admin').css({'display':'none'});					}					if(data.session == 'true'){						$('#bottom_menu').css({'display':'block'});					}					else {						$('#bottom_menu').css({'display':'none'});					}					if((data.admin == 'true')&&(data.session == 'true')){						$admin_login = true;						if($adminjs < $total_adminjs){							setTimeout(checkAdminjs,1000);							$.blockUI({message:'Loading admin scripts! Please wait...'});							$.getScript($baseurl + "js/jquery.rte.js",function(){								$adminjs++;							});							$.getScript($baseurl + "js/jquery.rte.tb.js",function(){								$adminjs++;							});							$.getScript($baseurl + "js/jquery.ocupload-1.1.4.js",function(){								$adminjs++;							});						}					}					else {						$admin_login = false;					}					//display catalogue page					document.title = data.title;					$('#content').html(data.content);					$currentpage = 'catalogue';					listScroll();				}				else {					$.blockUI({timeout:3000,overlayCSS: { backgroundColor: '#FFF',opacity:0.9 },css: {padding:'5px',border:'1px solid #DDD'},message:'Invalid username / password.<br/>Please try again...'});				}			},			error: function(){				$.blockUI({timeout:3000,overlayCSS: { backgroundColor: '#FFF',opacity:0.9 },css: {padding:'5px',border:'1px solid #DDD'},message:'Login error !!!<br/>Please try again...'});			}		});	});			$('#customize_form').live('submit',function(event){		// "_trackEvent" is the pageview event, 		_gaq.push(['_trackPageview', $(this).attr('action')]);				event.preventDefault();		$.blockUI({overlayCSS: { backgroundColor: '#FFF',opacity:0.9 },css: {padding:'5px',border:'1px solid #DDD'},message:'Sending request...<br/>Please wait !'});		$(this).ajaxSubmit({			success: function(data){				if (data.error == 'none'){					$.blockUI({overlayCSS: { backgroundColor: '#FFF',opacity:0.9 },css: {padding:'5px',border:'1px solid #DDD'},message:$('#thankyou')});				}				else {					$.blockUI({timeout:3000,overlayCSS: { backgroundColor: '#FFF',opacity:0.9 },css: {padding:'5px',border:'1px solid #DDD'},message:'Error sending your request !<br/>Please try again...'});				}			},			error: function(){				$.blockUI({timeout:3000,overlayCSS: { backgroundColor: '#FFF',opacity:0.9 },css: {padding:'5px',border:'1px solid #DDD'},message:'Error sending your request !<br/>Please try again...'});			}		}); 	});		$('#register_form').live('submit',function(event){		// "_trackEvent" is the pageview event, 		_gaq.push(['_trackPageview', $(this).attr('action')]);				event.preventDefault();		$.blockUI({overlayCSS: { backgroundColor: '#FFF',opacity:0.9 },css: {padding:'5px',border:'1px solid #DDD'},message:'Sending registration...<br/>Please wait !'});		$(this).ajaxSubmit({			success: function(data){				if (data.error == 'none'){					$.blockUI({overlayCSS: { backgroundColor: '#FFF',opacity:0.9 },css: {padding:'5px',border:'1px solid #DDD'},message:$('#thankyou')});					$('#register_form').get(0).reset();				}				else {					$.blockUI({timeout:3000,overlayCSS: { backgroundColor: '#FFF',opacity:0.9 },css: {padding:'5px',border:'1px solid #DDD'},message:'Error sending your registration !<br/>Please try again...'});				}			},			error: function(){				$.blockUI({timeout:3000,overlayCSS: { backgroundColor: '#FFF',opacity:0.9 },css: {padding:'5px',border:'1px solid #DDD'},message:'Error sending your registration !<br/>Please try again...'});			}		}); 	});				function checkAdminjs(){		if($adminjs < $total_adminjs){			setTimeout(checkAdminjs,1000);		}		else {			$.unblockUI();		}	}		$('div.button a').click(function(event){		event.preventDefault();		but = this;		$href = $(this).attr('href');				// "_trackEvent" is the pageview event, 		_gaq.push(['_trackPageview', $href]);				$page = $href.substring($href.lastIndexOf('/') + 1);		$page = $page.split('.');		$page = $page[0];		if ($currentpage != $page){			$('div.button').css('opacity','0.4');			$.post($href, function(data){				if (data.error == 'none'){					document.title = data.title;					$('#content').html(data.content);					$('#logo').css({'visibility':'visible','height':'145px'});					$currentpage = $page;					if(data.admin == 'true'){						$('span#admin').css({'display':'inline'});					}					else {						$('span#admin').css({'display':'none'});					}					if(data.session == 'true'){						$('#bottom_menu').css({'display':'block'});					}					else {						$('#bottom_menu').css({'display':'none'});					}					if((data.admin == 'true')&&(data.session == 'true')){						$admin_login = true;						switch(data.page){							case 'about':								aboutAdmin();								break;							case 'customize':								customizeAdmin();								break;							case 'contact':								contactAdmin();								break;						}					}					else {						$admin_login = false;					}				}				formTweak();				billboardCycle();				dateWidget();				formCheckInit();				listScroll();				$(but).parent().css('opacity','1');			});		}	});		$('#logout_but').click(function(event){		event.preventDefault();		$href = $(this).attr('href');				// "_trackEvent" is the pageview event, 		_gaq.push(['_trackPageview', $href]);				$('div.button').css('opacity','0.4');		$.post($href, function(data){			if (data.error == 'none'){				document.title = data.title;				$('#content').html(data.content);				$currentpage = 'customize';				$('#bottom_menu').css({'display':'none'});				$admin_login = false;				$('#customize_but').css('opacity','1');			}			formTweak();			dateWidget();			formCheckInit();		});	});		$('#user_but,#catalogue_genres_but,#genres_types_but,#login_page_but').click(function(event){		event.preventDefault();		$href = $(this).attr('href');		$page = $href.substring($href.lastIndexOf('/') + 1);		$page = $page.split('.');		$page = $page[0];		if ($currentpage != $page){			$('div.button').css({opacity:'0.4'});			$.post($href, function(data){				if (data.error == 'none'){					document.title = data.title;					$('#content').html(data.content);					$currentpage = $page;					if(data.admin == 'true'){						$('span#admin').css({'display':'inline'});					}					else {						$('span#admin').css({'display':'none'});					}					if(data.session == 'true'){						$('#bottom_menu').css({'display':'block'});					}					else {						$('#bottom_menu').css({'display':'none'});					}					if((data.admin == 'true')&&(data.session == 'true')){						$admin_login = true;					}					else {						$admin_login = false;					}					registerAdmin();				}			});		}	});		$('.popup_but').live('click',function(event){		$href = $(this).attr('href');		$('#div_to_popup').jqm({ajax:$href,onLoad:newsAdmin,overlay:80});		$('#div_to_popup').jqmShow();		return false;	});		$('#catalogue_form').live('submit',function(event){		event.preventDefault();		$href = $(this).attr('action');		$title = $('#title').val();		if ($.trim($title) == ""){			$title = "Untitled";		}		$duration = $('#duration').val();		$genre = $('#genre').val();		$tempo = $('#tempo').val();		$description = $('#description').val();		$sc_object = $('#sc_object').val();		$sc_html5 = $('#sc_html5').val();		$('div#form').html('Updating! Please wait...');		$.post($href, {title: $title, duration: $duration, genre: $genre, tempo: $tempo, description: $description, sc_object: $sc_object, sc_html5: $sc_html5} ,function(data){			if (data.error == 'none'){				$('#div_to_popup').jqmHide();				switch(data.mode){					case "new":						$('#title_details').html(data.details);						$('#titles a').removeClass('active');						link = '<a class="active '+ data.title_genre + '" id="a' + data.title_id + '" href="' + $baseurl + 'view/catalogue/' + data.title_id + '.html">' + $title + '</a>'						$('#titles').prepend(link);						listScroll();						break;					case "update":						$('#title_details').html(data.details);						$('#a'+data.title_id).removeClass();						$('#a'+data.title_id).addClass('active');						$('#a'+data.title_id).addClass(data.title_genre);						break;				}			}			else {				$('div#form').html('ERROR! Please try again!');			}		});	});		$('#chapter_form').live('submit',function(event){		event.preventDefault();		$href = $(this).attr('action');		$title = $('#title').val();		$timecode = $('#timecode').val();		if($.trim($title) == ""){			$title = "Untitled";		}		$('div#form').html('Updating! Please wait...');		$.post($href, {title: $title, timecode: $timecode} ,function(data){			if (data.error == 'none'){				$('#div_to_popup').jqmHide();				switch(data.mode){					case "new":						$('div.cues').append(data.content);						break;					case "update":						$('#cue' + data.chap_id).html(data.content);						break;				}			}			else {				$('div#form').html('ERROR! Please try again!');			}		});	});		$('.image_box a.admin').live('click', function(){		$('.image_box input#thumb').trigger('click');	});		$('.image_box input#thumb').live('change',function(){		$('.image_box form').ajaxSubmit({			target: ".image_box .img_holder",		});	});		$('.credit_box a.img_change').live('click', function(event){		event.preventDefault();		$(this).parent().find('input.thumb').trigger('click');	});		$('.credit_box a.img_clear').live('click', function(event){		event.preventDefault();		$href = $(this).attr('href');		$.post($href ,function(data){			$('#credit_box_' + data.id + ' .img_holder').html(data.content);		});	});		$('.credit_box input.thumb').live('change',function(){		$(this).parent().ajaxSubmit({			dataType: 'json',			success: function(data){				$('#credit_box_' + data.id + ' .img_holder').html(data.content);			}		});	});		$('a.billboard_add').live('click', function(event){		event.preventDefault();		$('#billboards_div input.thumb').trigger('click');	});		$('#billboards_div input.thumb').live('change',function(){		$.blockUI({message:'Adding billboard! Please wait...'});		$(this).parent().ajaxSubmit({			dataType: 'json',			success: function(data){				if(data.error == 'none'){					bills = $(data.content).find('#billboards').html();					$('#billboards').html(bills);					$.unblockUI();				}				else {					$.blockUI({timeout:3000,message:'Error! Please retry...'});				}			}		});	});		$('#register_admin_form').live('submit',function(event){		event.preventDefault();		$.blockUI({message:'Updating! Please wait...'});				$href = $(this).attr('action');		$.post($href, {register_text: regArr['rcontent'].get_content()} ,function(data){			if (data.error == 'none'){				$.unblockUI();			}			else {				$.unblockUI();				$.blockUI({timeout:2000,message:'ERROR ! Please retry !'});			}		});	});});function showmail(){	if ( $("span.mailme").length ) {		// variables, which will be replaced		var at = / AT /;		var dot = / DOT /g;		// function, which replaces pre-made class		$('span.mailme').each(function () {			var addr = $(this).text().replace(at, '@').replace(dot, '.');			$(this).after('<a href="mailto:' + addr + '">' + addr + '</a>');			$(this).remove();		});	}}function anim_end(){	}
