/* OrthopediaTheme */
//SHOW-HIDE DISPLAY AND VISIBILITY------------------------------------------------------------------------------------------------------------
//USAGE: <a href="javascript:ShowDis('TargetID');">Show Display/Visibility</a>
function ShowDis(a) {document.getElementById(a).style.display="block";}
function ShowVis(a) {document.getElementById(a).style.visibility="visible";}
//USAGE: <a href="javascript:HideDis('TargetID');">Hide Display/Visibility</a>
function HideDis(a) {document.getElementById(a).style.display="none";}
function HideVis(a) {document.getElementById(a).style.visibility="hidden";}
//USAGE: <a href="javascript:ShowHideDis('TargetID');">Show/Hide Display/Visibility</a>
//NOTE: Make sure target's display is initially set to block/visible or none/hidden via inline styling first.
function ShowHideDis(a) {
	if(document.getElementById(a).style.display == "none") {document.getElementById(a).style.display="block";}
	else {document.getElementById(a).style.display="none";}
}
function ShowHideVis(a) {
	if(document.getElementById(a).style.visibility == "hidden") {document.getElementById(a).style.visibility="visible";}
	else {document.getElementById(a).style.visibility="hidden";}
}

//SWAPPING FUNCTIONS--------------------------------------------------------------------------------------------------------------------------
//Function to swap image or iframe source:
//USEAGE: <a href="javascript:SwapSrc('TargetID','NewSourcePath');">Swap Source</a>
function SwapSrc(a,b) {document.getElementById(a).src=b;}
//Function to swap a container's HTML content:
//USEAGE: <a href="javascript:SwapSrc('TargetID','<h2>New Header</h2><p>new text</p>');">Swap HTML</a>
function SwapHTML(a,b) {document.getElementById(a).innerHTML=b;}
//Function to swap css class:
//USEAGE: <a href="javascript:SwapClass('TargetID','code red');">Swap Class</a>
function SwapClass(a,b) {document.getElementById(a).className=b;}
//Function to swap other element properties (obviously only supports the included properties):
//USAGE: <a href="javascript:SwapProp('TargetID','height','300px');">Swap Property</a>
function SwapProp(a,b,c) {
	if(b == 'width') {document.getElementById(a).style.width=c;}
	if(b == 'height') {document.getElementById(a).style.height=c;}
	if(b == 'color') {document.getElementById(a).style.color=c;}
	if(b == 'background') {document.getElementById(a).style.background=c;}
	if(b == 'display') {document.getElementById(a).style.display=c;}
	if(b == 'left') {document.getElementById(a).style.left=c;}
	if(b == 'top') {document.getElementById(a).style.top=c;}
}

//POPUP WINDOW FUNCTIONS----------------------------------------------------------------------------------------------------------------------
//Function to launch Adjustable Size Popup Window
//USEAGE: <a href="javascript:PopupWindowFixed('target.html', 'idname', 600, 390);">Click here for popup window.</a>
function PopupWindow(Source,Name,Width,Height) { 
window.open (Source,Name,"menubar=0,toolbar=0,location=0,status=0,directories=0,scrollbars=0,width="+Width+",height="+Height+",resizable=1");
}
//Function to launch Fixed Size Popup Window
//USEAGE: <a href="javascript:PopupWindowFixed('target.html', 'idname', 600, 390);">Click here for popup window.</a>
function PopupWindowFixed(Source,Name,Width,Height) { 
window.open (Source,Name,"menubar=0,toolbar=0,location=0,status=0,directories=0,scrollbars=0,width="+Width+",height="+Height+",resizable=0");
}

//FLASH GENERIC EMBED LOADER------------------------------------------------------------------------------------------------------------------
//	This is the most cross browser compatible solution I have come up with thus far: ditch the object tag.
//	EmbedSWF resizes the target container and adds an optional background, then uses an innerHTML rewrite to populate it with the proper embed tag.
//	HTML: <div class="mauto rel beveled5 txtcenter" id="swfbox"><!-- swf gets inserted here by EmbedSWF --></div>
//	USEAGE: Call the target container's ID, the full path to the swf file to load, width, height, optional background, and optional FlashVars:
//	EmbedSWF('TargetID','../mymedia/NewFile.swf',600,400,'#000','file=this&buffertime=that&variable=something');
//	Use a set of empty quotes for the background if you want to leave it blank but still include FlashVars.
//	To have the page initialize with a file pre-loaded, place a script in a hidden p tag (if excluded, the container will remain empty):
//	<p class="dispnone"><script type="text/javascript">EmbedSWF('TargetID','../mymedia/NewFile.swf',600,400,'#000','file=this&buffertime=that&variable=something');< /script ></p>
//	AND/OR include multiple links to load more swf files by placing scripts inside link tags:
//	<p><a href="#" onclick="EmbedSWF('TargetID','../mymedia/NewFile.swf',600,400,'#000','file=this&buffertime=that&variable=something');">Load SWF</a></p>
//	Optional content may follow -mta
function EmbedSWF(t,p,w,h,b,v){
	if (b==null) {b='none'};
	document.getElementById(t).style.width=w+"px"; document.getElementById(t).style.height=h+"px"; document.getElementById(t).style.background=b;
	document.getElementById(t).innerHTML="<embed width='100%' height='100%' src="+p+" type='application/x-shockwave-flash' quality='high' wmode='transparent' align='center' allowscriptaccess='always' allowfullscreen='true' pluginspage='http://www.adobe.com/go/getflashplayer/' FlashVars='"+v+"'></embed>";
}
function EmbedYouTube(t,p,w,h){
	if (p=='none') {document.getElementById(t).style.width="auto"; document.getElementById(t).style.height="auto"; document.getElementById(t).innerHTML="<h3>Select A Video</h3>";}
	else {
	document.getElementById(t).style.width=w+"px"; document.getElementById(t).style.height=h+"px";
	document.getElementById(t).innerHTML="<embed width='100%' height='100%' src='http://www.youtube.com/v/"+p+"?fs=1&amp;hl=en_US&amp;rel=0' type='application/x-shockwave-flash' quality='high' wmode='transparent' align='center' allowscriptaccess='always' allowfullscreen='true' pluginspage='http://www.adobe.com/go/getflashplayer/'></embed>";
	}
}
function LoadSWF(t,p,w,h,b,v){
	if (b==null) {b='none'}; document.getElementById(t).style.width=w+"px"; document.getElementById(t).style.height=h+"px"; document.getElementById(t).style.background=b;
	document.getElementById(t).innerHTML="<object width='100%' height='100%'><param name='movie' value="+p+"></param><param name='quality' value='high'></param><param name='wmode' value='transparent'></param><param name='allowscriptaccess' value='always'></param><param name='allowFullScreen' value='true'></param><embed src="+p+" height='100%' width='100%' type='application/x-shockwave-flash' quality='high' wmode='transparent' align='center' allowscriptaccess='always' allowfullscreen='true' pluginspage='http://www.adobe.com/go/getflashplayer/' FlashVars='"+v+"'></embed></object>";
}
function LoadYouTube(t,p,w,h){
	if (p=='none') {document.getElementById(t).style.width="auto"; document.getElementById(t).style.height="auto"; document.getElementById(t).innerHTML="<h3>Select A Video</h3>";}
	else {
	document.getElementById(t).style.width=w+"px"; document.getElementById(t).style.height=h+"px";
	document.getElementById(t).innerHTML="<object width='100%' height='100%'><param name='movie' value='http://www.youtube.com/v/"+p+"?fs=1&amp;hl=en_US&amp;rel=0'></param><param name='quality' value='high'></param><param name='wmode' value='transparent'></param><param name='allowscriptaccess' value='always'></param><param name='allowFullScreen' value='true'></param><embed width='100%' height='100%' src='http://www.youtube.com/v/"+p+"?fs=1&amp;hl=en_US&amp;rel=0' type='application/x-shockwave-flash' quality='high' wmode='transparent' align='center' allowscriptaccess='always' allowfullscreen='true' pluginspage='http://www.adobe.com/go/getflashplayer/'></embed></object>";
	}
}

//COOKIE FUNCTIONS--------------------------------------------------------------------------------------------------------------------
//	Function to create a cookie
//	USAGE: set_cookie('flexbkgimg','bkgimg.jpg'); creates a cookie that lasts until browser is closed.
//	Under Construction: Not sure I want to even use the exp date, but if so, it will be done differently.
function set_cookie(name,value,exp_y,exp_m,exp_d,path,domain,secure) {
	var cookie_string=name+"="+escape(value);
	if (exp_y) {var expires=new Date(exp_y,exp_m,exp_d); cookie_string += "; expires="+expires.toGMTString();}
	if (path) cookie_string += "; path="+escape(path);
	if (domain) cookie_string += "; domain="+escape(domain);
	if (secure) cookie_string += "; secure";
	document.cookie=cookie_string;
}
function get_cookie(cookie_name) {
	var results=document.cookie.match('(^|;) ?'+cookie_name+'=([^;]*)(;|$)');
	if (results) return (unescape(results[2]));
	else return null;
}
function delete_cookie(cookie_name) {
	var cookie_date = new Date ( );  // current date & time
	cookie_date.setTime(cookie_date.getTime()-1);
	document.cookie = cookie_name += "=; expires="+cookie_date.toGMTString();
}
//Function to set the body tag background STYLE and set a cookie to remember it (cookie expires when browser closes)
//USEAGE: <a href="javascript:SetBkgCookie('flexbkg','#012 no-repeat bottom center fixed url(/images/flexbkgs/NewWorld-012.jpg)');">Background 1</a>
function SetBkgCookie(cookiename,bkg) {document.getElementsByTagName('body')[0].style.background=bkg; set_cookie(cookiename,bkg);}
//Function to check if cookie exists, then load the bkg STYLE from it.
//USEAGE: <body onLoad="LoadBkgCookie('flexbkg');">
function LoadBkgCookie(cookiename) {if (get_cookie(cookiename) != null) {var bkg=get_cookie(cookiename); document.getElementsByTagName('body')[0].style.background=bkg;}}
//Function to clear the cookie and reload the page
function ClearCookie(cookiename) {if (get_cookie(cookiename) != null) {delete_cookie(cookiename); history.go(0);}}

