    /**
    *
    *   global.js
    *
    *   This JS file include will hold all global functionality.
    *   Global is defined as appearing on more than one type of page.
    *
    */

	$(function() {
		
		var xp = 20;
		var yp = 70;
		var exp_cp = 60;
		var name_cp = 'sub_pop';
		var cp_val = readCookie(name_cp);
		var pop_timeout = 10000;
		
		if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = window.innerWidth;
		    myHeight = window.innerHeight;
		  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = document.documentElement.clientWidth;
		    myHeight = document.documentElement.clientHeight;
		  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		    //IE 4 compatible
		    myWidth = document.body.clientWidth;
		    myHeight = document.body.clientHeight;
		  }
	
		var width = myWidth;
		var left = (width / 2) - 275;
		 
	    if (!cp_val) {
	        $("#sub_pop").css('display', 'block');
	        $("#sub_pop").css('left', left);
	        createCookie(name_cp,1,exp_cp); 
	    }
	    
	    $('#pop_click,#pop_close').click(function() {
			$('#sub_pop').hide();
		});

		function createCookie(name,value,days) {
			if (days) {
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}
			else var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
		}

		function readCookie(name) {
			var nameEQ = name + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			return null;
		}
		
	});
	
function google_ad_request_done(google_ads)
	{var s='';var i;
	var s = '<div class ="googleAdTitle"><a target="_new" class="ad_attribution" href="' + google_info.feedback_url + '">Ads by Google</a></div>';

	var multicolumns=false;if(google_ads.length==0)
	return;if(google_ads[0].type=="text")
	{if(column_count_afc>1)
	{multicolumns=true;}
	if(multicolumns==true)
	s+='<table width="100%" class="google_afc_tbl" border="0" cellspacing="0" cellpadding="5">';for(i=0;i<google_ads.length;++i)
	{if(multicolumns==true)
	{if(i%column_count_afc==0)
	s+='<tr>';s+='<td valign="top" width="25%">';}
	var description=google_ads[i].line2+' '+google_ads[i].line3;var url_text=google_ads[i].visible_url;if(max_length_description>0)
	description=description.substring(0,max_length_description);if(max_length_url>0)
	url_text=url_text.substring(0,max_length_url);s+='<div '+css_class_item_cell+'><a target="_blank" href="'+google_ads[i].url+'" '+'onmouseout="window.status=\'\'" '+'onmouseover="window.status=\'go to '+
	google_ads[i].visible_url+'\';return true;" '+
	css_class_ads_title+'>'+
	google_ads[i].line1+'</a><br /><span '+
	css_class_ads_description+'>'+
	description+'</span><br><a target="_blank" href="'+google_ads[i].url+'" '+'onmouseout="window.status=\'\'" '+'onmouseover="window.status=\'go to '+
	google_ads[i].visible_url+'\';return true;" '+
	css_class_ads_url+'>'+
	url_text+'</a></div><br />';if(multicolumns==true)
	{s+='</td>';if(i%column_count_afc==column_count_afc-1)
	s+='</tr>';}}
	if(multicolumns==true)
	{s+='</table>';}}
	document.write(s);return;}
	function rewrite_google_header()
	{var headers=document.getElementsByTagName('div');if((headers!=null)&&(headers.length>0))
	{for(var i=headers.length-1;i>=0;i--)
	{var att=headers[i].getAttribute("name");if(att=='adsByGoogleHeader')
	{var color=get_element_style(headers[i],"color","color");if(typeof google_info!="undefined")
	{headers[i].innerHTML='<a style\=\"color:'+color+'; text-decoration: none" target="_blank" class="ad_attribution" href="'+
	google_info.feedback_url+'">'+headers[i].innerHTML+'</a>';}}}}}
	function get_element_style(elem,ieStyleProp,cssStyleProp){if(elem.currentStyle){return elem.currentStyle[ieStyleProp];}else if(window.getComputedStyle){var compStyle=window.getComputedStyle(elem,"");return compStyle.getPropertyValue(cssStyleProp);}
	return"";}	
	
	//FB TWEET tabs
	 function ShowDiv(divID) {
		document.getElementById(divID).style.display = "block";
	}
	function HideDiv(divID) {
		document.getElementById(divID).style.display = "none";
	}	
	function showOfficeBlog() {
	var officeBlogDiv = document.getElementById("officeBlog");
	var newsBlogDiv = document.getElementById("newsBlog");
	var ob_whitetab = document.getElementById("office_blog_whitetab");
	var tyi_greytab = document.getElementById("thisjustin_greytab");	
	officeBlogDiv.style.display = "block";
	newsBlogDiv.style.display = "none";
	ob_whitetab.src = '/wp-content/themes/www.supthemag.com/images/facebook-up.gif';
	tyi_greytab.src = '/wp-content/themes/www.supthemag.com/images/twitter-hidden.gif';
	} 
	function showNewsBlog() {
		var officeBlogDiv = document.getElementById("officeBlog");
		var newsBlogDiv = document.getElementById("newsBlog");
		var ob_whitetab = document.getElementById("office_blog_whitetab");
		var tyi_greytab = document.getElementById("thisjustin_greytab");
		officeBlogDiv.style.display = "none";
		newsBlogDiv.style.display = "block";	
		ob_whitetab.src = '/wp-content/themes/www.supthemag.com/images/facebook-hidden.gif';
		tyi_greytab.src = '/wp-content/themes/www.supthemag.com/images/twitter-up.gif';
	} 
