function navOver(id,imageover)
{
	document.getElementById('sub_' + id).style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + imageover + "', sizingMethod='scale');";
}

function navOut(id,image)
{
	document.getElementById('sub_' + id).style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + image + "', sizingMethod='scale');";
}

function tabStatus(id,amount)
{

	for(i=1;i<=amount;i++)
	{
		document.getElementById('border_l_' + i).style.display = "none";
		document.getElementById('border_r_' + i).style.display = "none";
		document.getElementById('tab_' + i).style.background = "url('" + jsSITEPATH + "Site_Gfx/tabs/tab_bg.gif')";
		document.getElementById('tab_' + i).style.color = "#0f9fdb";
		document.getElementById('tab_' + i).style.fontWeight = "normal";
	}
	document.getElementById('border_r_' + id).style.visibility = "visible";
	document.getElementById('border_l_' + id).style.display = "inline";
	document.getElementById('border_r_' + id).style.display = "inline";
	document.getElementById('tab_' + id).style.background = "url('" + jsSITEPATH + "Site_Gfx/tabs/tab_bg_sel.gif')";
	document.getElementById('tab_' + id).style.color = "#1e4571";
	document.getElementById('tab_' + id).style.fontWeight = "bold";
	document.getElementById('stock_display').innerHTML = "content";
	
	
}
// Contact Us -BEGIN //
var contact_us = function()
{
	
 	var form = document.forms['contact_us'];
 	var first_name = form.cu_first_name.value;
 	var last_name = form.cu_last_name.value;
 	var email = form.cu_email.value;
 	var contacting = form.cu_contacting[form.cu_contacting.selectedIndex].value;
	if ( validate_email(email) && first_name!="" && last_name!="" && contacting!=0 )
	{
	
		YAHOO.util.Connect.setForm('contact_us'); 
		var cObj = YAHOO.util.Connect.asyncRequest('POST', jsSITESERVER + jsSITEPATH + 'service.php', contact_callback, "option=contact");
	}
	else
	{
		var div = document.getElementById("error_msg");
		div.innerHTML = "<span class='failure'>Please make sure the <strong>* required fields</strong> are filled in.</span>";
	}
	
	
	return false;
}
var clearform= function()
{
	var form = document.forms['contact_us'];
 	form.cu_first_name.value = "";
 	form.cu_last_name.value = "";
 	form.cu_email.value = "";
 	form.cu_phone.value = "";
 	form.cu_comments.value = "";
 	form.cu_contacting.selectedIndex = 0;
 	var div = document.getElementById("error_msg");
	div.innerHTML = "";
	
 	
 	return false;
}
var contact_form_orig;
var contactResponseSuccess = function(o){ 
	/* Please see the Success Case section for more
	* details on the response object's properties.
	* o.tId
	* o.status
	* o.statusText
	* o.getResponseHeader[ ]
	* o.getAllResponseHeaders
	* o.responseText
	* o.responseXML
	* o.argument
	*/ 
	
	var parsedResponse = YAHOO.lang.JSON.parse(o.responseText);
	
	var div = document.getElementById("contact_form");
	
	contact_form_orig = div.innerHTML;
	
	if(parsedResponse.success == true)
	{
	
		div.innerHTML = "<span class='success'>Thank you for contacting us.</span>";
	}
	else
	{
		div.innerHTML = "<span class='failure'>Your could not be sent at this time (" + parsedResponse.reason + ")</span>";
	}

};

var contactResponseFailure = function(o){ 
	// Access the response object's properties in the 
	// same manner as listed in responseSuccess( ). 
	// Please see the Failure Case section and 
	// Communication Error sub-section for more details on the 
	// response object's properties. 
	div.innerHTML = "failure";
} 

var contact_callback = 
{ 
	success:contactResponseSuccess, 
	failure:contactResponseFailure, 
	argument:args 
};

// Contact Us -END //

// Share Form -BEGIN //
YAHOO.namespace("alnylam");

YAHOO.alnylam.share_active = false;
YAHOO.alnylam.y_email = true;
YAHOO.alnylam.f_email = true;

var show_share_form = function()
{
	if(YAHOO.alnylam.share_active)
	{
		YAHOO.alnylam.share_form.hide();
		YAHOO.alnylam.share_active = false;
	}
	else
	{
		YAHOO.alnylam.share_form.show();
		YAHOO.alnylam.share_active = true;
	}
}


var form_init = function()
{


	YAHOO.alnylam.share_form = new YAHOO.widget.Overlay("share_it",  {
	width:"621px", 
	fixedcenter: false, 
	constraintoviewport: false, 
	underlay: "none", 
	close: false, 
	visible: false, 
	draggable: false
	}
	);


	
	// Render the Dialog
	YAHOO.alnylam.share_form.render();

	
}
var args = ['foo','bar']; 
 
var responseSuccess = function(o){ 
	/* Please see the Success Case section for more
	* details on the response object's properties.
	* o.tId
	* o.status
	* o.statusText
	* o.getResponseHeader[ ]
	* o.getAllResponseHeaders
	* o.responseText
	* o.responseXML
	* o.argument
	*/ 
	
	var parsedResponse = YAHOO.lang.JSON.parse(o.responseText);
	
	var div = document.getElementById("response");
	
	if(parsedResponse.success == true)
	{
	
		div.innerHTML = "<span class='success'>Your email has been sent. <a href='#' onclick='show_share_form(); return false;' style='text-decoration: underline; color: #009ada; font-size: 10px;'>Click here to close this window.</a></span>";
	}
	else
	{
		div.innerHTML = "<span class='failure'>Your could not be sent at this time (" + parsedResponse.reason + ")</span>";
	}

}; 

var responseFailure = function(o){ 
	// Access the response object's properties in the 
	// same manner as listed in responseSuccess( ). 
	// Please see the Failure Case section and 
	// Communication Error sub-section for more details on the 
	// response object's properties. 
	div.innerHTML = "failure";
} 

var callback = 
{ 
	success:responseSuccess, 
	failure:responseFailure, 
	argument:args 
};


var clear_form = function(form_item)
{
	var form = document.forms['share_form'];
	if (YAHOO.alnylam[form_item])
	{
		form[form_item].value = "";
		YAHOO.alnylam[form_item] = false;
	}
}
var send_share = function()
{
	
 	var form = document.forms['share_form'];
 	var friend_email = form.f_email.value;
 	var your_email = form.y_email.value;
	if ( validate_email(friend_email) && validate_email(your_email) )
	{
	
	YAHOO.util.Connect.setForm('share_form'); 
	var cObj = YAHOO.util.Connect.asyncRequest('POST', jsSITESERVER + jsSITEPATH + 'service.php', callback, "option=share");
	}
	else
	{
		var div = document.getElementById("response");
		div.innerHTML = "<span class='failure'>Please make sure the email addresses are in the form of name@domain.com</span>";
	}
	
	
	return false;
}
var validate_email = function(email) {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

	return reg.test(email);

}
YAHOO.util.Event.onDOMReady(form_init); 

// share form - END //

// text size - BEGIN //

//variables
var smallTextSize = 1;
var largeTextSize = 1.3;
var largeCalloutSize = 1.1;
var textStatus = "small";

var text_size  = function()
{
	textStatus = (textStatus == "small")? "big":"small";
	
	document.cookie = "textSizeCookie=" + textStatus + "; 0; path=/";
	set_text_size(textStatus);
}

var set_text_size = function( textStatus )
{
	var text_container  = false;
	var callout_text_container = false;
	if(document.getElementById('page_body') != null)
	{
		text_container = document.getElementById('page_body');
	}
	else if(document.getElementById('page_body_no_callout') != null)
	{
		text_container = document.getElementById('page_body_no_callout');
	}
	
	
	if(document.getElementById('callout_col') != null)
	{
		callout_text_container = document.getElementById('callout_col');
	}
	
	
	if (text_container)
	{
		if (textStatus == "big")
		{
			text_container.style.fontSize = largeTextSize + "em";
		}
		else if(textStatus == "small")
		{
			text_container.style.fontSize = smallTextSize + "em";
		}
	}
	
	if (callout_text_container)
	{
		if (textStatus == "big")
		{
			callout_text_container.style.fontSize = largeCalloutSize + "em";
		}
		else if(textStatus == "small")
		{
			callout_text_container.style.fontSize = smallTextSize + "em";
		}
	}
}

var text_size_persist = function()
{
	c_start = (document.cookie.indexOf("textSizeCookie=")) + 15;
	size = document.cookie.substring(c_start);
	if(size == "big")
	{
		set_text_size("big");
		textStatus = size;
	}
	else
	{
		textStatus = "small";
	}
}
YAHOO.util.Event.onDOMReady(text_size_persist); 
// text size - END //

// external links
var linkExternal = function(url) {

	pageTracker._trackPageview('/external/' + url.href);
	return(confirm("This link will take you to a Web site maintained by a third party who is solely responsible for its contents.\n\n"+ 
		"Alnylam Pharmaceuticals, Inc. provides this link as a service to Web site visitors. "+ 
		"Alnylam Pharmaceuticals, Inc. is not responsible for the content or policies of any third party web sites. "+
		"We recommend that you read the privacy policy of every Web site you visit.\n\n"+
		 
		"Click Cancel to return or OK to continue."));
}