function Bugger()
{alert ('Hello SwitchStyle Bugger function');}

/*goes thru all the tags & Returns array of the Style sheets link or empty if non CSS browser */
function getAllSheets() 
{
	if(!document.styleSheets && document.getElementsByTagName ) 
	{ //if there are no current stylesheets & browser support get elements
		var ss = document.getElementsByTagName('LINK');//get all link tags & store
		document.styleSheets = []; //reset stylesheets array
		for( var x = 0; ss[x]; x++ ) 
		{ //strip out the rel value of current stylesheet
			var rel = ss[x].rel ? ss[x].rel : ss[x].getAttribute ? ss[x].getAttribute('rel') : 'style';
			if( rel.toLowerCase().indexOf('style') + 1 ) //if attribute contains value="style"
			{ document.styleSheets[document.styleSheets.length] = ss[x]; }//add current sheet to stylesheet array
		}//for
		 document.styleSheets.concat( document.getElementsByTagName('STYLE') );
	} 
	//alert ('getAllSheets function');
	if( document.styleSheets ) 
	{ return document.styleSheets; } //return the array of style sheets
	//alert ('no stylesheets found by getElementsByTagName');
	return [];
}//getAllSheets

/* Get's All the stylesheets present in the document & disables them
& then matches the parameter to title & if a matched enables it*/
/* Parameter:title of the stylesheet that need to be switched on'
css files must be uploaded eg. non Blue.css etc */
/**************changeStyle()  *********/
function changeStyle() 
{   alert ('changeStyle  called');
	for( var x = 0, ss = getAllSheets(); x < ss.length; x++ ) //alias array of sheets
	 { alert ("length of ss array"+ss.length+" index="+ x+" title ="+ss[x].title+" attribute ");
		if( ss[x].title ) // if the current sheet is titled d...isable
		  { ss[x].disabled = true; 
		  alert (ss[x].title + 'disabled');
		  }
		  /*then check for a parameter/sheet match in array */
		for( var y = 0; y < arguments.length; y++ ) 
		  {			
			if( ss[x].title == arguments[y] ) //if matching parameter switch on
			{ ss[x].disabled = false;
			/*alert ('Match argument='+arguments[y]+' title='+ss[x].title 
			        + ' disabled='+ss[x].disabled); */
			}
			//enable each parameter match
		}//argument for
	}
}
/*************changeStyleSheet rewritten to run on safari ...simpler ....**********/
function changeStyleSheet (ptitle) 

{ //alert ('changeStylesheet called "'+ptitle);
var linka = document.getElementsByTagName("link"); // get all links into array
      for (var index = 0; index < linka.length;index++)
	  { //alert("index="+index+" css title='" +linka[index].title+"' '"+ ptitle+"' selected");
	    if(linka[index].title) // if there's a title
	       { linka[index].disabled=true;}//alert(linka[index].title +".css is disabled"); }// disable every  link/stylesheet
	    if(linka[index].title == ptitle)	// if the title matches the selected ss
		    { linka[index].disabled=false;}//alert(linka[index].title +".css is now on"); }//enable the matching link/stylesheet
	  
	  }//link for
}
/**************rememberStyle *********/
function rememberStyle( cookieName, cookieLife ) 
{
	for( var x = 0, ss = getAllSheets(), outLine = ''; x < ss.length; x++ ) 
	{
		if( ss[x].title && ss[x].disabled == false ) 
		{ outLine += ( outLine ? ' MWJ ' : '' ) + escape( ss[x].title ); } }
	if( ss.length ) 
	{ document.cookie = escape( cookieName ) + '=' + escape( outLine ) + ( cookieLife ? ';expires=' + new Date( ( new Date() ).getTime() + ( cookieLife * 86400000 ) ).toGMTString() : '' ) + ';path=/'; }
}
function useStyleAgain( cookieName ) {
	for( var x = 0; x < document.cookie.split( "; " ).length; x++ ) 
	{
		var oneCookie = document.cookie.split( "; " )[x].split( "=" );
		if( oneCookie[0] == escape( cookieName ) ) 
		{
			var styleStrings = unescape( oneCookie[1] ).split( " MWJ " );
			for( var y = 0, funcStr = ''; styleStrings[y]; y++ ) 
			{ funcStr += ( y ? ',' : '' ) + 'unescape( styleStrings[' + y + '] )'; }
			eval( 'changeStyle(' + funcStr + ');' ); break;
		}
	}
}

//google analytics 2/6/10 now included via nonStyles.php

// https://www.google.com/analytics/settings/check_status_profile_handler?id=17189397 22 /1/11

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-7951494-2']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
  //speed tracker http://www.google.com/support/analyticshelp/bin/answer.py?hl=en&answer=1205784&topic=1120718&utm_source=gablog&utm_medium=blog&utm_campaign=newga-blog&utm_content=sitespeed
  _trackPageLoadTime();
// End of Google tracker Script -


