jQuery(document).ready(function() { 

// style the pagination at the bottom of the blog listing footer  
// but first remove the pagination that ASP.net inserts at the top of the page
//$(".blog_listing .latest_posts .footer:first").remove();
jQuery(".blog_listing .latest_posts .footer .PagerControl").paginate(); 

jQuery(".girls_speak_up .footer .PagerControl").paginate(); 

// make sure that an empty text area does not cause a form to submit
jQuery("div.form_inputs input").click(function(){ 
	 if(jQuery("div.form_inputs textarea").val() == '') return false; 
})

// hide poll input field and make label clickable
jQuery("div.poll_wrapper li").hidePollInput() ;


// change profile picture
jQuery("a.change_pic").changeProfilePic();     
// check for moderation messge
 


if(jQuery(".user_profile_forms span.awaiting_moderation").size() !=0){ jQuery("fieldset.submit input").after('<span class="save_moderation"> Your changes have been saved and will appear in your profile pending moderation</span>');}
 
if(jQuery("span.email_confirmation").size() !=0) jQuery(".signin_form ol").before(jQuery("span.email_confirmation"))   

// Change Password  Account Settings Page.  Check that  the password field is not blank
jQuery(".edit_account fieldset.submit input").click(function(e){
	e.preventDefault(); 
	jQuery("div.user_profile_forms").checkPasswordField();
	});

     
// show "send to a friend" over lay  
jQuery("a.send_friend").click(function(e){e.preventDefault(); jQuery("div#send_to_a_friend").showOverlay(); })     
jQuery("a.invite_friend").click(function(e){e.preventDefault(); jQuery("div#invite_a_friend").showOverlay(); }) 
jQuery("a.BadgeTopBannerLink").click(function(e){e.preventDefault(); jQuery("div#BadgePopupWindow").showOverlay(); })

// old rounded corner rules
//$("div.inactive").boxcorner({corner_type:'gray'});
//$("div.topic_activities div.activity").boxcorner({corner_type:'gray', tl:"off", tr:"off"}); 
//$("div.topic_activities div.next_section").boxcorner({corner_type:'thin-gray'});
//$("div.user_profile_forms").boxcorner({corner_type:'gray',tl:"off"}) 
//$("div.all_topics").boxcorner({corner_type:'white'});     
//$("div.profile_info").boxcorner({corner_type:'thick-gray'}); 
//$("#main .content .topic_activities ").boxcorner({corner_type:'white',tl:"off", tr:"off"})
                                 
jQuery('fieldset.terms').showTerms(jQuery("a.display_terms"),jQuery("a.close"), jQuery("li.terms_text"));


// apply the closeMessage plugin to the warning message on the edit profile page 
jQuery("#warning a.close_button").click(function(e){
	e.preventDefault(); 
	jQuery("div#warning").hide(); 
	jQuery.cookie('moderate_warning', 'yes', { expires: 1000} );
});

if(jQuery.cookie('moderate_warning') != 'yes') {
	jQuery("div#warning").show();
}
       
// ensure that the  Account Settings password prevents a submit when the password field is empty 
jQuery(".edit_account fieldset.submit input").click(function(e){e.preventDefault(); jQuery(".edit_account").checkPasswordField() }); 


// apply the closeMessage plugin to the warning message on the edit profile page 
jQuery("#welcome a.close_button").click(function(e){
	e.preventDefault(); 
	jQuery("div#welcome").hide(); 
	jQuery.cookie('old_visitor', 'yes', { expires: 1000} );
});
if(jQuery.cookie('old_visitor') != 'yes') { 
   
	jQuery("div#welcome").show();
} 

/* Hover over girls on  girls landing page  
   Circle the girl, underline her name and display a popup which links to her profile
*/
    
jQuery(".avatar .girl").hoverIntent({
		sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
		interval: 100,   // number = milliseconds of polling interval
		over: showBubble,  // function = onMouseOver callback (required)
		timeout: 0,   // number = milliseconds delay before onMouseOut function call
		out: hideBubble    // function = onMouseOut callback (required)
});
   
function showBubble(){  
	   var name= jQuery('a.name',this).html(); 
	   var state = jQuery('span.state', this).html(); 
	   jQuery('.bubble', this).show()  
	  
}   

function hideBubble(){
	   jQuery(".bubble").hide()
}
// end code to show and hide text bubble on girls landing page  

/* show/hide detailed info on girls profile page */
jQuery("div.girl_info div.about a.more").click(function(e){ 
	
	    e.preventDefault();   
	    var more =  jQuery(this);  
	    var hidden = jQuery(this).prev()  
	   // if the extra information is hidden, show it 
	    if (jQuery('div.hidden').is(':hidden')){
		   	 hidden.show();
			 more.html("Read Less")
	    } else {
		     hidden.hide();
			 more.html("Read More  &rsaquo;&rsaquo;&rsaquo;")
		}   
});
// end code to show and hide more info about girls
 

// if the topic item is a poll, hide the headline as it is rendered in the poll body 

if (jQuery.trim(jQuery("div.item_content h3.item_type").html()) == "Poll") {
		 jQuery("div.item_content h3.item_type").next().hide();
	}    

// On the test yourself pages move the send to a friend button  inside the correct div
 
jQuery("div#quiz div.footer").prepend(jQuery("div.quiz a.send_friend"));
  


});  