		var jsReady = false;
			function pageInit() {
				jsReady = true;
			}
			function isReady() {
				return jsReady;
			}
			pageInit();

var randDARTNumber=0;
function genSetRandDARTNumber()
{
randDARTNumber=Math.round(Math.random()*1000000000000);
}
genSetRandDARTNumber();
//adrian - this loads a firebug console in js, useful for IE and other browsers
function loadFirebugLite()
{
	var obj = document.createElement('script');
	obj.src = 'http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js';
	obj.type = 'text/javascript';
	document.body.appendChild(obj);
}

	
// site specific javascript

$(function(){
		   
	// These sn_tabbed lines make the module tabs function properly.
	$('.sn_tabbed').parent('.mod-body').parent('.mod').addClass('sn_hasTabs');
	$('.sn_tabbed').each(function(){
		if($(this).children('.tabselected').length==0){
			$(this).children('li.sn_first').addClass('tabselected');
		}
	})
	$('.sn_tabbed li').click(function(){
		$(this).siblings().removeClass('tabselected');
		$(this).addClass('tabselected');
	});
	
	// this list of modules adds specific color classes to modules. it's here instead of the css because this will be much easier to track
	//GREEN MODULES
	//$('#sn_diet_tip').addClass('green_module');
	// YELLOW MODULES
	$('#sn_personal_goal').addClass('yellow_module');
	// BLUE BACKGROUND MODULES
	$('#sn_drag_blog').addClass('striped_fade_module');
	$('#sn_drag_groupblogs').addClass('blue_back_module');
	// STRIPED / FADED MODULES
	$('#sn_drag_photo').addClass('striped_fade_module');
	$('#sn_drag_photos').addClass('striped_fade_module');
	// BLANK MODULES
	$('#sn_loser_news').addClass('mod_blank');
	$('#sn_new_in_group').addClass('mod_blank');
	$('#sn_new_in_store').addClass('mod_blank');
	$('#sn_sponsor').addClass('mod_blank');
	$('#sn_sponsorship').addClass('mod_blank');
	// BLANK HEADER MODULES
	$('#sn_groups').addClass('mod_blank_head');
	$('#sn_get_started').addClass('mod_blank_head');
	$('#sn_get_started_user').addClass('mod_blank_head');
	$('#sn_getstart_exclnews').addClass('mod_blank_head');
	//GREY MODULE 300
	$('#sn_col3 #sn_drag_comment').addClass('grey_module');
	//BLANK GREY MODULE
	$('#sn_whatsnew').addClass('mod_blank_grey');
	
	//gives LI the width of the image */
	$("#sn_drag_photo").find(".sn_showthumb").children("li").each(function(){
		var img_span_width = $(this).find("img").outerWidth();
		$(this).width(img_span_width);
	});
	$("#sn_drag_video").find(".sn_showthumb").children("li").each(function(){
		var img_span_width = $(this).find("img").outerWidth();
		$(this).width(img_span_width);
	});
	
	// various page fixes
	$('#sn_defaultPhoto .mod-body-tabbed-internal').find('p:first').addClass('page_description');
	$('#sn_accountRegisterForm .sn_submit_btn').attr('value','submit');
	$('#sn_accountRegisterForm .sn_submit_btn').attr('style','');
	$('#sn_uploaded_thumbs_container').removeClass('mod-body'); // /groups/act/manage-created
	$('#sn_manager_group').removeClass('mod-body'); // /groups/act/add
	
	$('.sn_featured_select').append('<div class="clear"></div>');

	$("#sn_drag_photo").find(".sn_tabbed li.sn_first").addClass('tabselected sn_PHOTO_tab sn_drag_photo_tab');
	$("#sn_drag_photo").find(".sn_tabbed li.sn_last").addClass('sn_VIDEO_tab sn_drag_photo_tab');
	$('.striped_fade_module').find(".mod-body-cont a").append(' >>');
	$('.blue_back_module').find(".mod-body-cont a").append(' >>');
	
	
//	//fix <select> that has no default
//	if($("select[@name='sn_photoalbumpick']").children.length<=1)
//		$("select[@name='sn_photoalbumpick']").html('<option>Album</option>');
	
	//fix stat tracking -> challenges module appearance
	$("#challenges #challenges_title").html('<h3><span>CHALLENGES</span></h3>');
	
	$('#sn_mini_profile').parents('#mod-container').addClass('sn_three_columns_miniLeft');
	
	// exclusion for /groups/groupname/act/manage
	var sn_fix_url = window.location.href;
	if (sn_fix_url.substr((sn_fix_url.length - 11), 11) != '/act/manage')
	{
		$('#section_gro').find('#sn_drag_community').parents('#mod-container').addClass('sn_three_columns_miniLeft');
	}
	//please do not remove unless you are going to otherwise fix the tasks page.
	//fix tasks page div columns
//	var tmpArr = new Array();
//	$('#section_tas #sn_tasks .sn_tasks_body .sn_task_details_body .sn_task_details_col2').each(function(i){
//			tmpArr[i] = this.innerHTML;
//			$(this).remove();
//			});
//	$('#section_tas #sn_tasks .sn_tasks_body .sn_task_details_body .sn_task_details_col1').each(function(x){
//			var tmpDiv = document.createElement('div');
//			tmpDiv.id = "sn_task_name_1";
//			tmpDiv.innerHTML = tmpArr[x];
//			this.appendChild(tmpDiv);
//			});
//	$('#sn_tasks .sn_tasks_header .sn_task_details_body .sn_task_details_col1').each(function(){$(this).remove()});
	//done
	
	$('.sn_profile_personal_goal li').each(function(i){
		var tmpStr = this.innerHTML;
		this.innerHTML = '<div><b>*</b> '+tmpStr+'</div>';
	});
	
	//move the form field for height(inches) to match comps
	if(typeof(height_in_inch)!='undefined')
	{
		var inputFieldXML = '<input style="width:40px" id="aboutmeFields_tbll_height" class="Inch" type="text" maxlength="10" value="'+height_in_inch+'" name="tbll_height"/><span style="float:left">in.</span>';
		var tmpXML = $('#aboutmeFields_hide_tbll_height_div').html();
		$('#aboutmeFields_hide_tbll_height_div').html(inputFieldXML+tmpXML);
		tmpXML = $('#aboutmeFields_tbll_heightft_div').html();
		$('#aboutmeFields_tbll_heightft_div').html(tmpXML+'<span style="margin-left:8px;float:left">ft.</span>');
	}
	
	// fixes form on invite members page for community tools
	$('#existingUserFormFields_existingUser_div').next('p').attr('id','existingUserFormFields_existingUser_div_btn');
	$('#newUserFormFields_newUser1_div').find('label').text('New User');
	$('.newUserFormFields_elementDiv').next('p').attr('id','newUserFormFields_elementDiv_btn');
	$('.newUserFormFields_elementDiv').find('input').attr('value','email address');
	
	$('#newUserLookupFormFields_email_div label').html('email address');
	$('#newUserLookupFormFields_password').click(function(){
		$('#newUserLookupFormFields_password_div label').hide();
	});

	$('#existingUserFormFields_existingUser_div label').html('User Name');
	$('#existingUserFormFields_existingUser').click(function(){
	if(document.getElementById('existingUserFormFields_existingUser').value=='User Name')
		{
	document.getElementById('existingUserFormFields_existingUser').value='';
		}
		else
		{
			document.getElementById('existingUserFormFields_existingUser').value=document.getElementById('existingUserFormFields_existingUser').value;
		}
	});

	$('#newUserFormFields_newUser1_div label').html('email address');
	$('#newUserFormFields_newUser1').click(function(){
		if(document.getElementById('newUserFormFields_newUser1').value=='email address')
		{
		document.getElementById('newUserFormFields_newUser1').value='';
		}
	});
	$('#newUserFormFields_newUser2_div label').html('email address');
	$('#newUserFormFields_newUser2').click(function(){
	if(document.getElementById('newUserFormFields_newUser2').value=='email address')
		{
		document.getElementById('newUserFormFields_newUser2').value='';
		}
	});
	$('#newUserFormFields_newUser3_div label').html('email address');
	$('#newUserFormFields_newUser3').click(function(){
	if(document.getElementById('newUserFormFields_newUser3').value=='email address')
		{
			document.getElementById('newUserFormFields_newUser3').value='';
		}
	});
	$('#newUserFormFields_newUser4_div label').html('email address');
	$('#newUserFormFields_newUser4').click(function(){
	if(document.getElementById('newUserFormFields_newUser4').value=='email address')
		{
		document.getElementById('newUserFormFields_newUser4').value='';
		}
	});
	$('#newUserFormFields_newUser5_div label').html('email address');
	$('#newUserFormFields_newUser5').click(function(){
	if(document.getElementById('newUserFormFields_newUser5').value=='email address')
		{
		document.getElementById('newUserFormFields_newUser5').value='';
		}
	});

	$('#newUserLookupFormFields_email').click(function(){
		$('#newUserLookupFormFields_email_div label').hide();
	});
//	$('#existingUserFormFields_existingUser_div').find('input').attr('value','User Name');
	$('#newUserLookupFormFields_buttons_theFile_div').find('input').attr('value','CVS File to Upload');
	$('.newUserFormFields_elementDiv').find('input').click(function(){
		if($(this).attr('value') == 'email address'){
			$(this).attr('value','');
		}
	});
	
	$('#sn_lookupMember_form').find('button.sn_submit_btn').attr('id','sn_lookupMember_form_btn');
	
	
	//end client-side page fixes
	
	//set some dimensions  based on computed styles for ie6
	//$('#sn_personal_goal').css('height',$('#sn_personal_goal').height());
	//$('#sn_drag_blog').css('height',$('#sn_drag_blog').height());
	//$('#sn_drag_photo').css('height',$('#sn_drag_photo').height()+20);
	//$('#sn_drag_photo .mod-body').css('height',$('#sn_drag_photo .mod-body').height());
	//$('#sn_drag_comment').css('height',$('#sn_drag_comment').height());
	
	//load the ie6 fixes if we are in ie6
	if(typeof(_ie6_js)=='function')
	{
		site_ie6();
	}
	
	//loadFirebugLite();
	
	//CALLS THE BIND BEHAVIOR FUNCTION
	behavior_binder();
	
});

/*
Binds behaviors
** can be re-run whenever there are DOM changes
*/
function behavior_binder(){

// give checkbox/radio button sn_form_elementDiv a class
	$(':checkbox').each(function(){
		$(this).parent('.sn_form_elementDiv').addClass('sn_form_elementDiv_checkbox');
	});
	$(':radio').each(function(){
		$(this).parent('.sn_form_elementDiv').addClass('sn_form_elementDiv_radio');
	});

// this functions adds the internal div "mod-body-tabbed-internal" inside mod-body's with tabs
	$('.sn_hasTabs').each(function(){
		$(this).children('.mod-body').wrapInner('<div class="mod-body-tabbed-internal"></div>');
		$(this).children('.mod-body').prepend($(this).find('.module_tab_clear'));
		$(this).children('.mod-body').prepend($(this).find('.sn_tabbed'));
	});
	
/* ADD FIRST/LAST TO LI
		adds a class 'first' to the first LI, and a 'last' to the last LI and 'first last' to a single LI
	*/
	$('ul').each(function(i){
		$(this).children('li:first').addClass('first');
		$(this).children('li:last').addClass('last');
	});
// END ADD FIRST/LAST TO LI

}
