jQuery(document).ready(function(){
	// Hide the non-default countries on the select box
	jQuery("#ssearchStallion2").hide();
	jQuery("#ssearchStallion3").hide();
	jQuery("#ssearchStallion4").hide();
	
	// Effect when the country is changed
	jQuery("#ssearchCountry").change(function(){
		num = jQuery(this).val();
		jQuery("select.ssearchStallionOpen").slideUp("slow");
		jQuery("select.ssearchStallionOpen").removeClass("ssearchStallionOpen");
		jQuery("#ssearchStallion"+num).addClass("ssearchStallionOpen");
		jQuery("#ssearchStallion"+num).slideDown("slow");
		return false;
	});
	
	// Submit link
	jQuery(".submitLink").click(function(){
		jQuery(this).parents("form").submit();
		return false;
	});
	
	
	
	// Slide Area
	jQuery(".slide-area").hide();
	function slidemove(obj,action) {
		if (action=='up') {
			obj.find(".slide-area").slideUp("slow");
			obj.find("h2").removeClass("arrowdown");
		} else {
			obj.find(".slide-area").slideDown("slow");
			obj.find("h2").addClass("arrowdown");
		}
	}
	jQuery(".slideBox h2").click(function(){
		obj = jQuery(this).parents(".slideBox");
		if (obj.find(".slide-area").is(":visible")) action = "up"; else action = "down";
		slidemove(obj,action);
	});
	slidemove(jQuery("#boxMiniFeeds"),"down");
	
	// Share Email
	jQuery('a.email-share-link').click(function(){
		html_id = jQuery(this).find('input').val();
		html_id = "#"+html_id;
		tablearea_content = jQuery(html_id+" .tablearea").html();
		if (jQuery(html_id).is(':visible')) {
			jQuery(html_id).fadeOut("slow");
		} else {
			jQuery(html_id).fadeIn("slow",function(){
				jQuery(html_id+" .share-email-submit").click(function(){
					yname = jQuery(html_id+" .f-yname").val();
					rname = jQuery(html_id+" .f-rname").val();
					email = jQuery(html_id+" .f-email").val();
					what = jQuery(html_id+" .f-what").val();
					linkx = jQuery(html_id+" .f-link").val();
					if (yname!='' && rname!='' && email!='') {
						jQuery(this).html("SENDING... PLEASE WAIT");
						jQuery.ajax({
							type: "POST",
							url: "email-share.php",
							data: 'yname='+yname+'&rname='+rname+'&email='+email+'&what='+what+'&link='+linkx,
							success: function(msg){
								jQuery(html_id+' .tablearea').fadeOut("slow",function(){
									jQuery(html_id+' .tablearea').html('<p>'+msg+'<p>');
									jQuery(html_id+' .tablearea').fadeIn('slow');
									jQuery(html_id+' .tablearea a.thenclose').click(function(){
										jQuery(html_id).fadeOut("slow",function(){
											jQuery(html_id+' .tablearea').html(tablearea_content);
										});
									});
									jQuery(html_id+' .tablearea a.sendanother').click(function(){
										jQuery(html_id+' .tablearea').html(tablearea_content);
									});
								});
							}
						});
					} else {
						alert('Please fill out all the fields.');
					}
				});
			});
		}
	});


});
