$(document).ready(function(){	//title switcher	var ttl = ['Pity. It\'s 100% Curable', 'Become a part of the cure'];	var title = $('div#title h2');	i = -1;	var slideshow = setInterval(function(){		var val = ttl[++i] || ttl[i = 0];		title.fadeOut("slow", function(){			$(this).text(val).fadeIn("slow");		});	}, 4000);		//hide buttons initially	$("#player ul").hide();	$("#player ul:first").show();	$("#kids li:first").addClass("active");		//initial fun is done with	$("#kids li a").click(function(){		return false;	});		$("#bottom div:not(div#actions)").hide();	$("#bottom div#contentarea").show();		initLinks();});function initLinks(){	$("#kids li a").click(function(){		if($(this).attr('title')=='Welcome'){			resetBottom();		}		$("#kids li").removeClass("active");		$(this).parent().addClass("active");		var videoTemp = $(this).attr("rel").toString().split(':');		var fileTemp = $(this).attr("href");		$("#player #links a").click(function(){			return false;		});		playVideo(videoTemp);		$("#player #links").load(fileTemp + " #links ul", {}, function(){			$("#links a.story").click(function(){				$("#story_outer #ad").hide();				$("#story_outer #story").show();				loadStory($(this).html());				$('#story_navigation').show();				return false;			});			$("#links a.ad").click(function(){				$("#story_outer #story").hide();				$("#story_outer #ad").show();				loadStory($(this).html());				$('#story_navigation').show();				return false;			});			$("#links a.video").click(function(){				if ($(this).attr('rel') !== undefined && $(this).attr('rel') !== '') {					var thisVideo = $(this).attr("rel").toString().split(':');					playVideo(thisVideo);					return false;				}			});		});		$("#player #story_outer").load(fileTemp + " #hero", {}, function(){			$("#player #story_outer #links").remove();			$('#story_navigation').hide();		});	});	$("#actions li a").click(function(){		var t = $(this);		var fileTemp = $(this).attr("href");		if ($(this).attr('rel') !== undefined) {			var imgstr = '<img src="imagesupload/' + $(this).attr("rel") + '" border="0">';			$("#video").hide();			$("#links").hide();			$("#videoImage").html(imgstr);			$("#videoImage").show();			//var videoTemp = $(this).attr("rel").toString().split(':');			//playVideo(videoTemp);		}		$("#actions li a").removeClass("view");		$("#kids li").removeClass("active");		$(this).addClass("view");		$("#bottom div:not(div#actions)").hide();		$("#contentarea").load(fileTemp + " #contentx", {}, function(){			if(t.hasClass('pledgelink')){				$("#fmbldr_34141").submit(function(){					var options = {						target:		'#tempContent',						type:		'post',						url:		'default.cfm?PID=1.10&action=FB_guestsubmit',						error:		function() {													},						success:	function() {							$("#contentarea").html($("#tempContent div#contentx table table tr td").html());						}					};					$('#fmbldr_34141').ajaxSubmit(options);					return false;				});			}			if(t.hasClass('becomelink')){				$("#field_F6AC337F097208B0").search();				$("#field_B3923D316A71A0C4").search();				$("#field_F02CBFB96E693935").search();				$("#field_CD38E097FFFCD890").search();				$("#field_782044E0DEC74598").search();				$("#field_5284F12620617CC2").search();				$("#field_9BFA2D752CFDD70F").search();				$("#field_5F1D7625B38450F2").search();				$("#field_AD1DD276103A45FE").search();				$("#fmbldr_34179").submit(function(){					var options = {						target:		'#tempContent',						type:		'post',						url:		'default.cfm?PID=1.8&action=FB_guestsubmit',						error:		function() {													},						success:	function() {							$("#contentarea").html($("#tempContent div#contentx table table tr td").html());						}					};					$('#fmbldr_34179').ajaxSubmit(options);					return false;				});			}			if(t.hasClass('friendlink')){				initTellAFriend();				$('#field_7719912C43C46031').keyup(function(){					limitChars('field_7719912C43C46031', 500);				});				$("#field_0CB0AE8765A4293A").search();				$("#field_BE53C8CA8A9638C6").search();				$("#field_9394BF78393D3FC2").search();				$("#field_19DD7EFC3470594E").search();				$("#field_7719912C43C46031").search();			}		}).fadeIn();		return false;		//$("#bottom div#" + this.title).fadeIn();	});	$("#footerlinks a").click(function(){		var t = $(this);		$("#tempContent").load(t.attr('href')+' #contentx',{},function(){			tb_show(t.attr('title'),"#TB_inline?height=400&width=500&inlineId=tempContent",{});			readyPaging();		});		return false;	});	}function initTellAFriend(){	imagePreview();	$("#fmbldr_34160").submit(function(){		if(validateform('fmbldr_34160')){			$('#eCardMethod').val('sendCard');			var options = {				target:		'#tempContent',				type:		'post',				url:		'default.cfm?PID=1.9&action=guestsubmit',				error:		function() {				},				success:	function() {					$("#contentarea").html($("#tempContent div#ECardConfirm").html());				}			};			$('#fmbldr_34160').ajaxSubmit(options);			return false;		}		else{			return false;		}	});	$("#PreviewCard").click(function(){		if(validateform('fmbldr_34160')){			$('#eCardMethod').val('PreviewCard');			var options = {				target:		'#tempContent',				type:		'post',				url:		'default.cfm?PID=1.9&action=guestsubmit',				error:		function() {				},				success:	function() {					$("#contentarea").find('div').each(function(){						$(this).css('display','block');					});					$("#tempContent").html($("#tempContent div#contentx").html());					tb_show("e-Card Preview","#TB_inline?height=580&width=695&inlineId=tempContent",{});					$('#preview_edit').click(function(){						tb_remove();						//initTellAFriend();						return false;					});					$('#preview_send').click(function(){						tb_remove();						$('#eCardMethod').val('sendCard');						var options = {							target:		'#tempContent',							type:		'post',							url:		'default.cfm?PID=1.9&action=guestsubmit',							error:		function() {							},							success:	function() {								$("#contentarea").html($("#tempContent div#ECardConfirm").html());							}						};						$('#fmbldr_34160').ajaxSubmit(options);						return false;					});				}			};			$('#fmbldr_34160').ajaxSubmit(options);			return false;		}		else{			return false;		}	});}$.fn.search = function() {	return this.focus(function() {		if( this.value == this.defaultValue ) {			this.value = "";		}	}).blur(function() {		if( !this.value.length ) {			this.value = this.defaultValue;		}	});};function playVideo(arrayPlaylist){	$("#video").show();	$("#videoImage").hide();	$("#links").show();				$f("player2", "http://" + document.domain + "/imagesupload/flowplayer.commercial-3.1.1.swf", {		//license key for *.curepity.org		key: "#$db0de84d5c9c39539ee",				canvas: {  			background: 'url(ImagesUpload/video-background-gradient.jpg) repeat-x'		},				//video clip settings		clip: {			autoPlay: true,			autoBuffering: true,			scaling: "fit"		},				// playlist with two entries 		playlist: arrayPlaylist,				// show playlist buttons in controlbar 		plugins: {			controls: {				playlist: true,				fullscreen: false			}		}	});}function resetBottom(){	$('#contentarea').html($('#contentarea_hidden').html());	$('div#actions ul li a').each(function(){		$(this).removeClass('view');	});}function readyPaging(divWrapper){	$("#TB_ajaxContent #story_list li").each(function(){		$(this).removeClass('current_story')	});	$("#TB_ajaxContent #story_list li:first").addClass('current_story');	if ($("#TB_ajaxContent #story_list li").length > 1) {		$("#TB_ajaxContent .tb_navigation .next").show();		$("#TB_ajaxContent .tb_navigation .prev").addClass('inactive');	} else {		$("#TB_ajaxContent .tb_navigation .next").hide();		$("#TB_ajaxContent .tb_navigation .prev").hide();	}	$("#TB_ajaxContent .tb_navigation .prev").click(function(){		storyPrevious();	});	$("#TB_ajaxContent .tb_navigation .next").click(function(){		storyNext();	});}//story areafunction loadStory(title){	tb_show(title, '#TB_inline?height=420&width=520&inlineId=story_outer', {});	readyPaging();}function storyNext(divWrapper){	var cur = $("#TB_ajaxContent #story_list li.current_story");	if (cur.next().length !== 0) {		cur.removeClass('current_story');		cur.next().addClass('current_story');		if (cur.next().next().length == 0) {			$("#TB_ajaxContent .tb_navigation .next").addClass('inactive');		}		$("#TB_ajaxContent .tb_navigation .prev").removeClass('inactive');	}}function storyPrevious(divWrapper){	var cur = $("#TB_ajaxContent #story_list li.current_story");	if (cur.prev().length !== 0) {		cur.removeClass('current_story');		cur.prev().addClass('current_story');		if (cur.prev().prev().length == 0) {			$("#TB_ajaxContent .tb_navigation .prev").addClass('inactive');		}		$("#TB_ajaxContent .tb_navigation .next").removeClass('inactive');	}}/* js for the ecard stuff */function validateform(formname){	var newformname = formname + '.field_58DEDE451CB97808';	newformname = eval(newformname);		var radio_choice = false;	for (counter = 0; counter < newformname.length; counter++) 	{		if (newformname[counter].checked) 		{			radio_choice = true; 		}	}	if (!radio_choice) {		alert("You must select a Template");	return false;	}		if(document.getElementById('field_0CB0AE8765A4293A').value.toLowerCase() == "your name" || document.getElementById('field_0CB0AE8765A4293A').value.length == 0)	{		alert('You must enter Your Name!');		return false;	}	if(document.getElementById('field_BE53C8CA8A9638C6').value.toLowerCase() == "your friend's name" || document.getElementById('field_BE53C8CA8A9638C6').value.length == 0)	{		alert("You must enter Your Friend's' Name!!");		return false;	}              	if(document.getElementById('field_9394BF78393D3FC2').value.toLowerCase() == "your email" || document.getElementById('field_9394BF78393D3FC2').value.length == 0)	{		alert('You must enter a valid Your Email!');		return false;	}	if(document.getElementById('field_19DD7EFC3470594E').value.toLowerCase() == "your friend's email" || document.getElementById('field_19DD7EFC3470594E').value.length == 0)	{		alert("Your must enter your friend's email");		return false;	}	if(document.getElementById('field_7719912C43C46031').value.toLowerCase() == "type in a message" || document.getElementById('field_7719912C43C46031').value.length == 0)	{		document.getElementById('field_7719912C43C46031').value = "";	}	if(validateEmail('field_9394BF78393D3FC2') == false || validateEmail('field_19DD7EFC3470594E') == false)	{		return false;	}	return true;}function validateEmail(emailfield) {	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;	var address = document.getElementById(emailfield).value;	if(reg.test(address) == false) {		alert('Invalid Email Address');		return false;	}}function limitChars(textid, limit) {	var text = $('#'+textid).val();  	var textlength = text.length; 	if(textlength > limit) 	{ 		$('#'+textid).val(text.substr(0,limit)); 		return false; 	} 	else 	{ 		return true; 	} }	this.imagePreview = function(){			xOffset = 380;		yOffset = 30;		$("img.tell_a_friend_image").hover(function(e){			var s = $(this).attr('src').replace('_thumbnail','');			//this.t = this.title;			//this.title = "";			//var c = (this.t != "") ? "<br/>" + this.t : "";			var c = '';			$("body").append("<p id='preview_ecard'><img src='"+ s +"' alt='Image preview' />"+ c +"</p>");			$("#preview_ecard")				.css("top",(e.pageY - xOffset) + "px")				.css("left",(e.pageX + yOffset) + "px")				.fadeIn("fast");		},		function(){			//this.title = this.t;			$("#preview_ecard").remove();		});		$("img.tell_a_friend_image").mousemove(function(e){			$("#preview_ecard")				.css("top",(e.pageY - xOffset) + "px")				.css("left",(e.pageX + yOffset) + "px");		});	}
