



/*
passing "this" into a jquery object wont work (due to jQuery being a super class and tier 2 functions using "this"), 
so there are only two methods. Declare it as a parameter or define it before jQuery is used.



Dont use this model in the future lol - ML 4-18-11
(too much work)
*/
//alert(parent.document.title);
javascript=(function() {
	/*  Initiate - Document - Window
	================================ */
	//declare all variables before dom/window
	function construct() {
		this.document();this.window();
	}
	construct.prototype.document=function(){var _=this;$(document).ready(function(){
		loadCufon();
		navigation();
		navigateOnAllBrowsers();
		topLevelnavCufonHover();
		topLevelnavCufonActive();
		logoHover();
		share(150);
		popup();
		external_popup();
		fixAnchorLinkIcons();
		//debug_meta();
		trackLinks();
		loadSWF();
		//highlight();
	});}
	construct.prototype.window=function(){$(window).load(function(){
		
	});}
	construct.prototype.extendToDom=function(func) {
		releaseOnDom(func);
	}
	/*    private calls
	==================*/
	loadCufon=function() {
		font.set("#header .row-1 .set-1 a");
		font.set("#header .nav .cufon-this",{textShadow:'#466184 0px 1px',color:"#ffffff",lineHeight:"20px",fontSize:"16px",ignoreClass:"nocufon"});
	};font={set:function(selector,options){if(!options){options=null}Cufon.replace(selector,options);}}
	releaseOnDom=function(func) {$(document).ready(function() {											
		func();
	});}
	
	highlight = function(){
		//document.body.innerHTML = document.body.innerHTML.replace(/(SubQ|subcutaneous)/g,"<span class=\"g-highlight\">$1</span>");
	}
	
	navigateOnAllBrowsers=function() {
		if($.browser.msie && jQuery.browser.version <= 6) {
			var parent = null;
			$("#header .nav li ul li").hover(function() {
				parent = $(this);
				$("ul",$(this)).show();
				$("a",$(this)).addClass("ie"+(parent.index()+1));
			},function() {
				parent = $(this);
				$("ul",$(this)).hide();
				$("a",$(this)).removeClass("ie"+(parent.index()+1));
			});
		}
	};
	topLevelnavCufonHover=function() {
		$("#header .nav li ul li").hover(function() {
			font.set($(".cufon-this",$(this)),{textShadow:'#9fbadd 0px 1px',color:"#003366",lineHeight:"20px",fontSize:"16px",ignoreClass:"nocufon"});
		},function() {
			font.set($(".cufon-this",$(this)),{textShadow:'#466184 0px 1px',color:"#ffffff",lineHeight:"20px",fontSize:"16px",ignoreClass:"nocufon"});
			topLevelnavCufonActive();
		});
	};
	topLevelnavCufonActive=function() {
		font.set($(".about-pi #header .nav .about-pi .cufon-this"),{textShadow:'#9fbadd 0px 1px',color:"#003366",lineHeight:"20px",fontSize:"16px",ignoreClass:"nocufon"});
		font.set($(".choosing-a-therapy #header .nav .choosing-a-therapy .cufon-this"),{textShadow:'#9fbadd 0px 1px',color:"#003366",lineHeight:"20px",fontSize:"16px",ignoreClass:"nocufon"});
		font.set($(".living-with-pi #header .nav .living-with-pi .cufon-this"),{textShadow:'#9fbadd 0px 1px',color:"#003366",lineHeight:"20px",fontSize:"16px",ignoreClass:"nocufon"});
		font.set($(".community #header .nav .community .cufon-this"),{textShadow:'#9fbadd 0px 1px',color:"#003366",lineHeight:"20px",fontSize:"16px",ignoreClass:"nocufon"});
		font.set($(".help-and-support #header .nav .help-and-support .cufon-this"),{textShadow:'#9fbadd 0px 1px',color:"#003366",lineHeight:"20px",fontSize:"16px",ignoreClass:"nocufon"});
	};
	logoHover=function() {
		$(".logo-container").hover(function() {
			$("#header .row-2 .logo-hover").show();
		},function() {
			$("#header .row-2 .logo-hover").hide();
		});
	}
	share=function(i) {
		var title = encodeURIComponent(document.title);
		var url = encodeURIComponent(window.location.href);
		$(".sharethis ul li a.facebook").attr("href","http://www.facebook.com/sharer.php?u="+url+"&t="+title);
		$(".sharethis ul li a.myspace").attr("href","http://www.myspace.com/index.cfm?fuseaction=postto&u="+url+"&t="+title);
		$(".sharethis ul li a.twitter").attr("href","http://twitter.com/home?status="+url+" "+title);
		$(".sharethis ul li a.email").attr("href","mailto:?subject="+document.title+"&body="+window.location.href);
		$(".sharethis .sharing").each(function(){
			$(this).toggle(function(){
				$("ul",$(this).parent()).stop(true,true).fadeIn(i);
			},function() {
				$("ul",$(this).parent()).fadeOut(i);
			});
		});
	}
	popup=function() {
		$('a[href="https://webforms.baxterbioscience.com/immune/piPanel.jspa"]').live("click",function(e){
			e.preventDefault();
			window.open("https://webforms.baxterbioscience.com/immune/piPanel.jspa","Ask a Question","width=800,scrollbars=yes");
		});
	}
	fixAnchorLinkIcons = function() {
		if(/MSIE\s[67]/.test(navigator.userAgent)){
			$(".exit").removeClass("icon").removeClass("exit").append('<span class="icon-incompatibility exit"></span>');
			$(".pdf").removeClass("icon").removeClass("pdf").append('<span class="icon-incompatibility pdf"></span>');
		}
	}
	loadSWF = function() {
		swfobject.embedSWF("/swf/Parts.swf", "swf_parts-movie","400px", "380px", "9.0.0", "/swf/expressInstall.swf",null,{wmode:"transparent"},{id:"swf_parts-movie",name:"swf_parts-movie"});
		swfobject.embedSWF("/swf/B_CELLS.swf", "swf_b-cells-movie","275px", "290px", "9.0.0", "/swf/expressInstall.swf",null,{wmode:"transparent"},{id:"swf_b-cells-movie",name:"swf_b-cells-movie"});
		swfobject.embedSWF("/swf/T_CELLS.swf", "swf_t-cells-movie","255px", "350px", "9.0.0", "/swf/expressInstall.swf",null,{wmode:"transparent"},{id:"swf_t-cells-movie",name:"swf_t-cells-movie"});
		swfobject.embedSWF("/swf/Phagocytes.swf", "swf_phagocyte-movie","255px", "350px", "9.0.0", "/swf/expressInstall.swf",null,{wmode:"transparent"},{id:"swf_phagocyte-movie",name:"swf_phagocyte-movie"});
		swfobject.embedSWF("/swf/Complement.swf", "swf_complement-movie","350px", "305px", "9.0.0", "/swf/expressInstall.swf",null,{wmode:"transparent"},{id:"swf_complement-movie",name:"swf_complement-movie"});
	}

	external_popup = function() {
		var ie6_htc = 0;
		font.set("#external-link-notice .ex-head",{color:"#375993",textShadow:'#accae8 0px 1px'});
		$(".external").live("click",function(e){	
			e.preventDefault();
			$("#blackscreen").fadeTo(750,.5);
			if(/MSIE\s[78]/.test(navigator.userAgent)){
				$("#external-link-notice").show();
			} else {
				$("#external-link-notice").fadeIn(750);
			}
			
			if(/MSIE\s[6]/.test(navigator.userAgent)){
				$("#external-link-notice .ex-body").css({marginTop:"29px"});
				if(ie6_htc == 0){ie6_htc = 1;
					$("#external-link-notice .ex-body").css({"behavior":"url(/css/htc/iepng.htc)"});
				}
			} else {
				$("#external-link-notice .ex-body").animate({marginTop:"29px"},750,"easeInSine");
			}
			$(".continuethis").attr("href",$(this).attr("href")).attr("target","_blank");
		});
		$("#external-link-notice ul a").live("click",function(e) {
			if(!$(this).hasClass("continuethis")) {
				e.preventDefault();
			}
			$("#blackscreen,#external-link-notice").css({"display":"none"});
			$("#external-link-notice .ex-body").css({marginTop:"10px"});
		});
	}
	debug_meta = function() {
		$('body').prepend('<div style="width:100%;padding:10px 0;background:#fff;font:12px/14px Verdana;"><div style="display:block;width:980px;margin:0 auto;"><strong>Page Title: </strong>'+$("title").html()+'<br /><br /><strong>Page Description: </strong> '+$('meta[name="description"]').attr("content")+'</div></div>');
	}
	$.fn.trackPage = function(a,b,c,d) {
		if(!callback){var callback=function(){}}
		if('dcsMultiTrack' in window){
			WT={};dcsVar();var x=_getPageTrackerID($(this));
			dcsMultiTrack(x.a,x.b,x.c,x.d);
		}
		return $(this);
	}
	_getPageTrackerID = function(o) {
		var r;
		if(o.hasClass("register")) {
			r={a:'WT.dl',b:'24',c:'WT.z_emailregistration',d:'1'}
		} else if(o.hasClass("gardian-home-button")) {
			r={a:'WT.dl',b:'24',c:'WT.z_ID_Enroll_HP',d:'1'}
		} else if(o.hasClass("gardian-enroll-page")) {
			r={a:'WT.dl',b:'24',c:'WT.z_ID_Enroll_GPg',d:'1'}
		} else if(o.hasClass("header-gardian-enroll")) {
			r={a:'WT.dl',b:'24',c:'WT.z_MyG_Enroll_Hd',d:'1'}
		} else if(o.hasClass("header-gardian-login")) {
			r={a:'WT.dl',b:'24',c:'WT.z_MyG_Login_Hd',d:'1'}
		} else if(o.hasClass("order-form")) {
			r={a:'WT.dl',b:'24',c:'WT.z_order',d:'1'}
		} else {
			r={a:'WT.dl',b:'24',c:'',d:'1'}
		}
		return r;
	}
	trackLinks = function() {
		$('.pdf').live('click',
			function(){	
				if('dcsMultiTrack' in window){//PDF download
					WT = {};dcsVar();
					dcsMultiTrack('DCS.dcsuri',$(this).attr('href'),'WT.dl','20','WT.ti',"download: "+$(this).text(),'WT.z_pdfdownload',this.pathname,'WT.z_pdfdownloadcount','1');				
				}
				window.open(this.href);
				return false;
			}
		);
		// temp for now.. 
		$('a[href="https://webforms.baxterbioscience.com/immune/order.jspa"]').addClass("order-form").addClass("webform");
		// not efficient, but for now its okay.
		// (add additional information later)
		$(".register,.order-form,.gardian-home-button,.gardian-enroll-page,.header-gardian-enroll,.header-gardian-login").
		click(function(e) {
			e.preventDefault();
			$(this).trackPage();
			if($(this).hasClass("webform")) {
				var w = 800;
				var h = 700;
				window.open($(this).attr("href"),'immunedisease','resizable=1,scrollbars=1,height='+h+',width='+w);
			} else {
				window.open($(this).attr("href"));
			}
		});
	}
	
return construct;})();var ini=new javascript();
