//! ################################################################
//! Copyright (c) 2005-2006 Creative Async, LLC
//! All rights reserved.
//! Not to be reused without permission
//! ################################################################



	
	
	var _HIDDEN_SOCIAL_DIV_EXTRA_HEIGHT_OFFSET = 20;
	


// Get page offset of an element
function GetPageOffsetLeft(el) {
  var x = el.offsetLeft;
  if (el.offsetParent != null)
    x += GetPageOffsetLeft(el.offsetParent);
  return x;
}

// Get page offset of an element
function GetPageOffsetTop(el) {
  var y = el.offsetTop;
  if (el.offsetParent != null)
    y += GetPageOffsetTop(el.offsetParent);
  return y;
}


		function setBookmark2(url,str)
			{
				if(str=='')
					str=url;
				if (document.all)
					window.external.AddFavorite(url,str);
				else 
					alert('Press CTRL and D to add a bookmark to:\n"'+url+'".');
			}
			
			
			
	
		
		
		function hideSocialSection()		
		{
		
			hidden_social_div =  document.getElementById('hidden_social_bookmark_div');

			if (!hidden_social_div)
			{
				return;
			}
			
			

			hidden_social_div.style.display="none";			
			
			document.getElementById('subscribe').style.display="none";			
			document.getElementById('email').style.display="none";			
			document.getElementById('bookmark').style.display="none";			
		}	
		
function clearEmailForm(id_of_to_address_textbox,id_of_from_address_textbox, id_of_your_name_textbox,id_of_from_your_message_textbox,id_of_email_error_msg)
	{
	
	//alert('start:  clearEmailForm');
	
	var erMessageSpan=  document.getElementById(id_of_email_error_msg);
	
	var toAddressTextBox=  document.getElementById('id_of_to_address_textbox');
	var fromAddressTextBox=  document.getElementById('id_of_from_address_textbox');
	var yourNameTextBox=  document.getElementById('id_of_your_name_textbox');
	var yourMessageTextBox=  document.getElementById('id_of_from_your_message_textbox');
	
	
	erMessageSpan.innerHTML="&nbsp;";
	toAddressTextBox.value="";
	fromAddressTextBox.value="";
	yourNameTextBox.value="";
	yourMessageTextBox.value="";
	
	

		return true;
	}
		
function validateEmailForm(id_of_to_address_textbox,id_of_from_address_textbox, id_of_your_name_textbox,id_of_from_your_message_textbox,id_of_email_error_msg) 
		{
		
		//alert('start:  validateEmailForm');
		
		var erMessageSpan=  document.getElementById(id_of_email_error_msg);
		
		if (!erMessageSpan)
			return false;
		
		
		//var toAddressTextBox=  document.getElementById(id_of_to_address_textbox);
		//var fromAddressTextBox=  document.getElementById(id_of_from_address_textbox);
		var yourNameTextBox=  document.getElementById(id_of_your_name_textbox);
		var yourMessageTextBox=  document.getElementById(id_of_from_your_message_textbox);

		
		if ( checkEmail(id_of_to_address_textbox) == false)
		{
		  erMessageSpan.innerHTML = "Invalid 'To' E-mail Address. Please re-enter.";
		  return false;
		}
		
		if ( checkEmail(id_of_from_address_textbox) == false)
		{
		
			erMessageSpan.innerHTML = "Invalid 'From' E-mail Address. Please re-enter.";
			return false;
		}
		
	if ( yourNameTextBox && yourNameTextBox.value.length ==0)
		{
		
			erMessageSpan.innerHTML = "'Your Name' must be valued.";

		  return false;
		}		 
		
	if ( yourMessageTextBox && yourMessageTextBox.value.length > 100)
		{
		
		  erMessageSpan.innerHTML = "'Your Message' cannot be longer than 100 characters.";
		  return false;
		}		 
		
		//alert('end:  validateEmailForm');

		
		return true;
		
		}		
		
		
function checkEmail(id_of_email_textbox) 
		{
		
		
		
		var textBoxWithEmail=  document.getElementById(id_of_email_textbox);

		 
		 if (!textBoxWithEmail)
		 {
		   return false;
		 }
		 
		 
		 
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(textBoxWithEmail.value))
		{
		
		return (true)
		}

		//alert("Invalid E-mail Address. Please re-enter.")
		return (false)
}		
		
	function showSocialSection(sectionId, idOfLinkToOffsetFrom, offset_left, offset_top, page_title)
			{
			
			hidden_social_div =  document.getElementById('hidden_social_bookmark_div');
			
			if (!hidden_social_div)
			{
			 	return;
			}
			
            //This toggles the window on\off if the user keeps clicking the "More" link
            
            /*
				if (hidden_social_div.style.display == "block" &&        
					document.getElementById(sectionId).style.display == "block")
				{
					  hideSocialSection();
					  return;
				}
			*/
			
			
			if (!sectionId || sectionId =='')
				{
					sectionId = 'bookmark';
				}
				
			 
			  /*
			  SOCIAL_NORMAL_BK_COLOR = "#ffff00";
			  SOCIAL_SELECTED_BK_COLOR = "#DEDFDE";
			  */
			  
			 var  SOCIAL_NORMAL_BK_COLOR = "#FFFF00";
			 var  SOCIAL_SELECTED_BK_COLOR = "#CCCCCC";
			  
			 var  EMAIL_NORMAL_HEIGHT = "235px";
			 var  EMAIL_EXTENDED_HEIGHT = "320px";
			  
			  
			//alert(document.getElementById('tab_header_div_subscribe').style.bgcolor);					
			//document.getElementById('tab_header_div_subscribe').style.bgcolor= "#ffff00";		
			
			//tabs
			var social_div_bookmarks = document.getElementById('bookmark');
			var social_div_subscribe = document.getElementById('subscribe');
			var social_div_email = document.getElementById('email');
			var social_div_link = document.getElementById('link');
			
			//tab headers			
			var tab_header = document.getElementById('social_tag_header');
			
			
			   
				 
				 
			var tab_header_bookmarks = document.getElementById('tab_header_div_bookmark');
			var tab_header_subscriptions = document.getElementById('tab_header_div_subscribe');
			var tab_header_email = document.getElementById('tab_header_div_email');
			var tab_header_link = document.getElementById('tab_header_div_link');
			
			
			//social window offsets
			var link_position_left =0;
			var link_position_top =0;
			
			var link_to_offset_from = document.getElementById(idOfLinkToOffsetFrom) ; 
			
			//set the window position
			if (link_to_offset_from && idOfLinkToOffsetFrom.length > 0)
			{
			   link_position_left = GetPageOffsetLeft(link_to_offset_from);
			   link_position_top = GetPageOffsetTop(link_to_offset_from);
			   
				hidden_social_div.style.left= link_position_left + offset_left + 'px';			
				hidden_social_div.style.top= link_position_top + offset_top + _HIDDEN_SOCIAL_DIV_EXTRA_HEIGHT_OFFSET+ 'px';			
			   
		     }
		     
			
			//alert ("hidden_social_div.style.left =" + hidden_social_div.style.left);
			//alert ("hidden_social_div.style.top =" + hidden_social_div.style.top);
			
		     
			//alert ("hidden_social_div.style.left =" + hidden_social_div.style.left);
			//alert ("hidden_social_div.style.top =" + hidden_social_div.style.top);
			
			
			//set email window height
			social_div_email.style.height= EMAIL_NORMAL_HEIGHT ;
			
			if (sectionId =='bookmark') 
				{
				    

					//tabs
					social_div_bookmarks.style.display="block";			
					social_div_subscribe.style.display="none";			
					social_div_email.style.display="none";	
					social_div_link.style.display="none";			
					

					//headers
					tab_header.innerHTML = "Bookmark " + page_title;
				
				
					//css class
					tab_header_bookmarks.className= "social_td_selected";
					tab_header_subscriptions.className="social_td_normal";			
					tab_header_email.className="social_td_normal";			
					tab_header_link.className="social_td_normal";			
					
					
				}
		   	
			if (sectionId =='subscribe')
				{

					//tabs
					social_div_bookmarks.style.display="none";			
					social_div_subscribe.style.display="block";			
					social_div_email.style.display="none";	
					social_div_link.style.display="none";			
					

					//headers
					tab_header.innerHTML = "Subscribe to " + page_title;
				
					//css class
					tab_header_bookmarks.className= "social_td_normal";
					tab_header_subscriptions.className="social_td_selected";			
					tab_header_email.className="social_td_normal";			
					tab_header_link.className="social_td_normal";			
					

					
					
					
				}
		   	
		   	if (sectionId =='email')
				{
				
					//set email extensed height
					social_div_email.style.height= EMAIL_EXTENDED_HEIGHT ;

					//tabs
					social_div_bookmarks.style.display="none";			
					social_div_subscribe.style.display="none";			
					social_div_email.style.display="block";	
					social_div_link.style.display="none";			
					

					//headers
					tab_header.innerHTML = "Email a Link to " + page_title;
				
					//css class
					tab_header_bookmarks.className= "social_td_normal";
					tab_header_subscriptions.className="social_td_normal";			
					tab_header_email.className="social_td_selected";			
					tab_header_link.className="social_td_normal";			
					
					
				}

		   		if (sectionId =='link')
				{
			
					//tabs
					social_div_bookmarks.style.display="none";			
					social_div_subscribe.style.display="none";			
					social_div_email.style.display="none";	
					social_div_link.style.display="block";			
					

					//headers
					tab_header.innerHTML = "Link to " + page_title;
				
					//css class
					tab_header_bookmarks.className= "social_td_normal";
					tab_header_subscriptions.className="social_td_normal";			
					tab_header_email.className="social_td_normal";			
					tab_header_link.className="social_td_selected";			
							
								
				}
				
				
				
			//finally, after all display properties are set, shhow the whole block			
			hidden_social_div.style.display="block";

			   	
			}			   	
			

	
		

		
		
			
	