//write in js effects stylesheet before ad code
if($.browser.msie){var cssCreate=document.createElement('link');$(cssCreate).attr({type:'text/css',href:'/socceram/styles/js-effects.css',rel:'stylesheet',media:'screen',title:'default'});$('head').append(cssCreate);}

else{$('head').append("<link rel='stylesheet' href='/socceram/styles/js-effects.css' type='text/css' media='screen' title='default' />");
}

// Extend Array prototype 
Array.prototype.inArray = function (value){
var i = this.length;
var re = new RegExp('^' + value);
do{if(this[i-1].match(re)){return true};}
while(--i)
};

var pageID= new Array();

// cookies
setCookie = function(name,value,days) {
// write a cookie
	  if (days) {
	    var date = new Date();
	    date.setTime(date.getTime()+(days*24*60*60*1000));
	    var expires = "; expires="+date.toGMTString();
	  }
	  else expires = "";
	  document.cookie = name+"="+value+expires+"; path=/";
	}
	
getCookie = function(name) {
// read a cookie
	  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;
	}
	

//sets stylesheet onload
	loadStyle = function(){
		currentStyle=getCookie('styleName');
		if(currentStyle){
			$('link[@rel]').each(function(i){
				this.disabled=true
					if(this.getAttribute('title')==currentStyle) this.disabled=false;
			})
		}

}

loadStyle();


changeStyle = function(){
		$("a[@rel='stylesheet']").click(function(){
			(this.title) ? sheetName=this.title : sheetName=toolTitle;setCookie('styleName',sheetName);
			$('link[@rel]').each(function(i){
			this.disabled=true;
				if(this.getAttribute('title')==sheetName) this.disabled=false;
			})
return false;
		})
}	

//get mouse position
	var mouseX, mouseY;
	document.onmousemove=getMouse;
	function getMouse(e) {
		if (!e){e=window.event};
			mouseX=e.clientX+document.documentElement.scrollLeft;
			mouseY=e.clientY+document.documentElement.scrollTop;
	};
	
function toolTip(tag,tip,tipClass){
		$(tag).mouseover(function(){
			$("div.ss-tooltip").remove();oldTitle=this.title;toolTitle="";if(this.title)toolTitle=this.title;if(tip)toolTitle=tip;if(tip=='sort')toolTitle='Click to sort by ' + this.title;
			$("body").append("<div class='ss-tooltip'>"+toolTitle+"</div>");$(this).attr({title:""});
			$('div.ss-tooltip').fadeIn(90).css({left:mouseX+"px",top:mouseY+"px"}).addClass(tipClass)}).mouseout(function(){
			$("div.ss-tooltip").fadeOut(100);$(this).attr('title',oldTitle);
		});
	}

fixIE = function(el){
		var objects;
		if (el) {
			//objects = $(el).getElementsByTagName("object");
			objects = el.getElementsByTagName("object");
		} else {
			objects = document.getElementsByTagName("object");
			
		}
		/*
		for (var i = objects.length-1; i > -1; i--){
			var object = objects.item(i);

			// Fix flash object
			if (object.type == "application/x-shockwave-flash"){
				if (object.getAttribute("data")){object.removeAttribute( "data" );}
				object.outerHTML = object.outerHTML;
				
			}
		}
		$('object').css('display','inline');
		*/
		
	}
	



$(document).ready(function(){
						   
// Grab every ID off the page and insert it into the page ID array
	$("//[@id]").each(function(i){pageID.push(this.id);})
	
fixIE();
$('#clip-list ul').hide()  						   
$('#clip-list ul:first').show()

$('#clip-list .clip-list-link > a').click(function(){
	$('#clip-list .clip-list-link ul').hide();
	$(this).siblings('ul').show();
	return false;
}) 

toolTip($('.ourStuff ul li a'),'','tip');
toolTip($('.yourStuff ul li a'),'','sc-tip');
toolTip($('.galleries ul li a'),'','gallery-tip');

// Stylesheet switcher

$('#switcher').html("<h2>Change page style: <a href='#' rel='stylesheet' title='default'>default</a> | <a href='#' rel='stylesheet' title='high contrast'>high contrast</a></h2>");
changeStyle();
	
$("#ss-bookmark").hover(function(){$(this).find("ul").show().css('z-index','4');$(this).find('a').addClass('ss-bookmarks')},function(){$(this).find("ul").hide();$(this).find('a').removeClass('ss-bookmarks')});
// set print article button
	if(pageID.inArray('ss-print')){$('#ss-print').css('display', 'block').click(function(){window.print();})};
})


