Cufon.replace('.hn_neue');

Cufon.CSS.ready(function () {
		setMenSource(true);
		});

(function(d){d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(f,e){d.fx.step[e]=function(g){if(!g.colorInit){g.start=c(g.elem,e);g.end=b(g.end);g.colorInit=true}g.elem.style[e]="rgb("+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(",")+")"}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}if(e=/rgba\(0, 0, 0, 0\)/.exec(f)){return a.transparent}return a[d.trim(f).toLowerCase()]}function c(g,e){var f;do{f=d.curCSS(g,e);if(f!=""&&f!="transparent"||d.nodeName(g,"body")){break}e="backgroundColor"}while(g=g.parentNode);return b(f)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}})(jQuery);


var commentOpen = false;
var menSource;
var sendObj = {eventID:null,hashcode1:null,hashcode2:null,email:null};


$(document).ready(function () {
	
	$("#comment_start").click(function () {
		
		currentTop = (window.pageYOffset);
		if(!commentOpen)
		{
			$("#comment_main").animate({"height":"151px"},250);
			$(".comment_label_vanishing").fadeIn(250);
			$("html,body").animate({scrollTop:91+currentTop},250);
			commentOpen = true;
		}
	
	});
	
	$("#comment_cancel").click(function () {
	
		currentTop = (window.pageYOffset);
		
		$("#comment_main").animate({"height":"60px"},250);
		$(".comment_label_vanishing").fadeOut(250);
		$("html,body").animate({scrollTop:currentTop-91},250);
		commentOpen = false;
	
	
	});
	$("input:radio[name=ml_add]").click(function () {
	
		$("#comment_send").attr("src","img/static/comment_send_on.gif");
		
		$("#comment_send").attr("disabled",null);

	
	});
	$("#email_form").click(function () {
	
		if($(this).val() == "Please enter your email address")
		{
			$(this).val("");
		}
	
	});
	
	connectEmails();
	
	$("#menu > li > .current").each(function () {
		colour = $(this).attr("class").split(" ").slice(1,2);
		//alert(colour);
				
		$(this).parent().css({"background-color":"#"+colour});
		//Hide menu2 version of this
		$("#menu2 > li > .current").css("visibility","hidden");
	});
	
	
	$("#menu2 > li:not(.current)").mouseenter(function () {
	
		$(this).find("a").addClass("men_target");
		
		if(!menSource)
		{
			setMenSource(false);
		
		}
		var menTarget = {	left:$(this).offset().left,
							width:txtC($(this).outerWidth()),
							backgroundColor:"#"+$(this).find("a").attr("class").split(" ").slice(1,2)};
							
							
		$("#menuFloater").animate(menTarget,250);
		
		$("#menu2 > li:not(.current)").find("a:not(.men_target)").animate({opacity:1},250);
	
		$(this).find("a").animate({opacity:0},250);
		
		$(this).find("a").removeClass("men_target");
	});
	
	$("#menu2").mouseleave(function () {
	
		$("#menuFloater").animate(menSource,250);
		$("#menu2 > li:not(.current)").find("a").animate({opacity:1},250);
		
	});
	$(window).resize(function() {
		setMenSource(true);
	});
	
	reminderSetup();
	
	
	
	
	
	
	
	
	
	
	
	

});

function reminderSetup()
{
	$(".rem2submit").click(function () {
		//alert("Reminder Submitted");
		initialID = $(this).attr("id");
		idA = initialID.split("_");
		sendObj.eventID = idA[0];
		sendObj.hashcode2 = idA[1];
		sendObj.hashcode1 = $("#hc1_"+sendObj.eventID).val();
		sendObj.email = $("#email_address_"+sendObj.eventID).val();
		sendObj.strike_two = $("#s2_"+sendObj.eventID).val();
		//objInspect(sendObj);
		
		$.getJSON("../inc/util.reminderSetup.php",sendObj,function(j){
			if(j.status == "ok")
			{
				$("#reminder_form_"+sendObj.eventID).html("<span class='reminder-thanks-message'><span style='color: #ef037f; line-height: 40px; font-size: 1.1em; font-weight: bold;'>Thank You</span><br />Your email address has been added to our mailing list and we will send you a reminder the day before tickets are available for "+j.eventName+"</span>");
			
			}
			else
			{
				if(j.status == "barred")
				{
					$(".all_reminder_forms").html("<span class='reminder-thanks-message'><span style='color: #ef037f; line-height: 40px; font-size: 1.1em; font-weight: bold;'>Sorry!</span><br />After two failed attempts to sign-up, your IP address has been blocked for 24 hours. Try again tomorrow.</span>");
				}
				else
				{
					if(j.error_type == "Invalid Email")
					{
						$("#email_address_"+sendObj.eventID).val("Invalid email address, please try again.");
						$("#email_address_"+sendObj.eventID).css({"background":"#ef037f","color":"#FFFFFF"});
					}
					else
					{
						if(j.error_type == "Wrong Shape")
						{
							$("#s2_"+sendObj.eventID).val("Y");
							$("#hc1_"+sendObj.eventID).val(j.new_hc1);
							$("#box_"+sendObj.eventID).html("<p class='rem_send_label'>Click the <b><span style='color: #"+j.new_col+";'>"+j.new_lab+"</span></b> to set a reminder</p>"+j.new_shapes);
							reminderSetup();
						}
					
					}
				}
			
			}
		});
		
	});



}


function connectEmails()
{
	$("form[name='email_entry']").submit(function () {
	
		$("#email_confirmation").css("display","block");
		$("#email_address").val($("#email_form").val());
		return false;
	});
	
	$(".form2submit").click(function () {
		$("#email_confirmation").load("../inc/util.mailSignup.php",{"email":$("#email_address").val(),"strike_two":$("#s2").val(),"hashcode1":$("#hc1").val(),"hashcode2":$(this).val()},function () {
			
			setFader();
			connectEmails();
		
		
		});
		return false;
	});
	
	$("form[name='email_form']").submit(function () {	
		return false;
	});
}
function setFader()
{
	var returnVal =	$("#email_confirmation").html();
	if(returnVal.search("Thankyou") != -1)
	{
		$("#email_confirmation").delay(2000).fadeOut(300);
	}
}

function setMenSource(initial)
{
	menSource = {	left:$("#menu > li > .current").parent().offset().left,
					width:txtC($("#menu > li > .current").parent().outerWidth()),
					backgroundColor:"#"+$("#menu > li > .current").attr("class").split(" ").slice(1,2)};
	
	if(initial)
	{
		$("#menuFloater").css(menSource);
	}
	
}

function numC(input)
{
	try {
		var string2 = input.replace(/px/,"");

		var num = parseInt(string2);
	
		return num;
	}
	catch (err) {
	}
}

function txtC(number)
{
	try {
		return number + "px";
	}
	catch (err) {
	}
}
function objInspect(object)
{
	var temp ="";
	for(x in object)
	{
		temp += x + ": " + object[x] + "\n";
	}
	alert(temp);
}

