// JavaScript Document

$(document).ready(function(){
if($("div#giFlash").length){
	var po = new SWFObject("/common/swf/gi-article-2.swf?"+cachekill, "giFlashArticle", "960", "450", "8", "#eaeaea");
	po.addParam("wmode", "opaque");
	po.addParam("allowScriptAccess","always");
	po.addVariable("articleId", articleId);
	po.addVariable("articleLang", articleLang);
	po.addVariable("articleDir", articleDir);
	po.addVariable("articleNumPages", articleNumPages);
	po.addVariable("articleFirstFile", articleFirstFile);
	po.addVariable("activearea", activearea);
	po.addVariable("articleTitle", articleTitle);
	po.addVariable("articleUrlTitle", articleUrlTitle);
	po.addVariable("articleServer", articleServer);
	po.addVariable("cachekill", cachekill);
	po.write("giFlash");
	// this bit handles the deep linking within flash (urls with #/page/1 etc in them)
	DeepLink.setObject('giFlashArticle');
// call the function that sets up the article sub navigation links.
}
	articleSubNav();
	
	sendtofriend();
});


function sendtofriend()
{
	if($("#sendtofriendButton").length){	
		$("#sendtofriendButton").click(
		  function (e) {
			 	e.preventDefault();
				dosendtofriend();
				return false;
				//$("#sendtofriend").submit();
		  }  
		);	
	}	
}
function dosendtofriend()
{

	$('div#sendtofriendModule img.loadingBar').show();
	$('label.hideme').hide();
	$('p.hideme').hide();
	$.post("/sendtofriend/", { 
			value:$('#spoof').val(), 
			spoof:$('#spoof').attr('name'),
			to_email:$('#to_email').val(),
			to_name:$('#to_name').val(),
			my_email:$('#my_email').val(),
			my_name:$('#my_name').val(),
			my_msg:$('#my_msg').val(),
			article_id:$('#article_id').val()
		},
		function(data){
			if(data == 'Message sent.')
			{
				$('p.hideme').html('Your message was sent.');
				$('p.hideme').show();
				//$('label.hideme').show();
				
			}else{
				//alert(data);	
				$('p.hideme').html('There were errors sending the form.');
				$('p.hideme').show();
				$('label.hideme').show();
			}
			$('div#sendtofriendModule img.loadingBar').hide()
		}
	,'text');
	
}

function articleSubNav(){
	/*
	if($("div#giSubNavColumn").length){
		
		$("div#giSubNavColumn").hide();
		$("#giHeaderBarNav a.activeHeaderBar").click(
		  function () {
			$('div#giSubNavColumn').show();
			hideme = '#'+$(this).attr('id') + 'SubNav';
			$('#giFlash').hide();
			$('#giBodyFullColumn').hide();
		  	return false;
		  }  
		);	

		$("#giSubNavBackLink").click(
		  function () {
			$('div#giSubNavColumn').hide();
			$('#giFlash').show();
			$('#giBodyFullColumn').show();
			return false;
		  }
		);			


	}
	*/
}