/*------------------------

  Required Functions
 
------------------------*/

    //needed for the contact links funtion to work properly
    function getDisplayFriendID() { return MySpace.ClientContext.DisplayFriendId; }
    
    
    //required for add this javascript
    addthis_offset_top      = 0;
    addthis_offset_top_low  = 0;
    addthis_offset_left     = 0;
    

function writeDisclaimer() { 
	
	var legalContainer = document.getElementById('disclaimer');

	legalContainer.innerHTML = 'The Running Ribbon is a registered trademark of Susan G. Komen for the Cure&reg;<br /><br /> <a href="http://www.generalmills.com/corporate/privacy/privacy.aspx" target="_blank" name="&amp;lid=linkGM_Privacy" id="linkGM_Privacy">General Mills Privacy Policy</a> '; 

}





// JavaScript Document

/*function iframeLogg() {
var loggedPasser = getElementById('iframeDiv');

loggedPasser.src = "http://pink.ugenmedia.com?isLoggedIn=' + isLoggedIn + '";

}

iframeLogg();*/


function jumpToTop() { 

     //   parent.location = 'http://www.myspace.com/pinktogether#topOfPage'; 
        parent.location.hash = 'topOfPage'; 
        parent.scrollTo(0, 0); 
        return false; 
} 


function SetCookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
		expire.setTime(today.getTime() + 3600000*24*nDays);
		document.cookie = cookieName+"="+escape(cookieValue)
		+ ";expires="+expire.toGMTString();
}
	
function Get_Cookie(check_name) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}


function checkForTOS() {
  if (Get_Cookie('forumsTOS')) {
	document.getElementById('forumContainer').style.display = 'block';
	document.getElementById('forumsHolder').style.display = 'none';
	document.getElementById('forumFake').style.display = 'none';
	}	
}



function forumsAgree() {
	if (tosForm.agree.checked) {
		SetCookie('forumsTOS',true,30);
		document.getElementById('forumContainer').style.display = 'block';
		document.getElementById('forumsHolder').style.display = 'none';
	} else {
		alert ('You must check that you agree to the Terms of Participation to continue.');
	}
}

function forumsCancel() {
		document.getElementById('forumContainer').style.display = 'none';
		document.getElementById('forumFake').style.display = 'block';
}

function openForums() {
	document.getElementById('forumFake').style.display = 'none';
	document.getElementById('forumsHolder').style.display = 'block';
}

function videoSwap(videoId){
	//var videoContainer = document.getElementById('videoPlayer');
   	//videoContainer.innerHTML = '<object width="384" height="249" ><param name="allowFullScreen" value="true"/><param name="wmode" value="opaque"/><param name="movie" value="http://mediaservices.myspace.com/services/media/embed.aspx/m='+ videoId +',t=1,mt=video,primaryColor=0x72b6b9,v=2,ap=1,secondaryColor=0x72b6b9,sr=0"/><embed src="http://mediaservices.myspace.com/services/media/embed.aspx/m='+ videoId +',t=1,mt=video,primaryColor=0x72b6b9,v=2,ap=1,secondaryColor=0x72b6b9,sr=0" width="384" height="249" allowFullScreen="true" type="application/x-shockwave-flash" wmode="opaque" /></object>';
	var vo = new SWFObject("http://mediaservices.myspace.com/services/media/embed.aspx/m="+ videoId +",t=1,mt=video,v=2,ap=1,sr=0", "videoPlayerWindow", "368", "247", "9", "#fad8ea");
	vo.addParam("allowFullScreen", "true");
	vo.addParam("wmode", "opaque");
	vo.addParam("quality", "high");
	vo.write("videoPlayer")
}


//writes the function that calls the iframes to write with variables
function divInsert()
{
	if (location.search.substring(9) != "") {
		var storyIdNumber = location.search.substring(9);
	} else {
		var storyIdNumber = null;
	}

var appFrame = document.getElementById("applicationIframe");
var widget1 = document.getElementById("widgetIframe2");

appFrame.innerHTML = '<iframe src="http://69.20.5.70/mainApplication.cfm?userId='+ isLoggedIn + '&storyId='+ storyIdNumber +'" height="650" width="950" marginheight="0" marginwidth="0" allowtransparency="true" scrolling="no" frameborder="0" id="iframeOne" name="iframeOne"></iframe>';

widget1.innerHTML = '<iframe src="http://69.20.5.70/featuredStoryWidget.cfm ?userId='+ isLoggedIn +'" height="240" width="850" marginheight="0" marginwidth="0" allowtransparency="yes" scrolling="true" frameborder="0" id="iframeTwo" name="iframeTwo"></iframe>';

}


// Click and select all for input fields and textareas

function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}


function vidSwap(vidID)
{
	document.getElementById("videoPlayer2").innerHTML = '<embed width="384" height="248" wmode="opaque" allowfullscreen="true" quality="high" bgcolor="#fad8ea" name="videoPlayer2Window" id="videoPlayer2Window" src="http://mediaservices.myspace.com/services/media/embed.aspx/m='+ vidID +',t=1,mt=video,v=2,ap=1,sr=0" type="application/x-shockwave-flash"/>';
	}

