function setActiveStyleSheet(title) {
   var i, a, main;
   document.getElementById("normal").style.display='block';
   document.getElementById("larger").style.display='block';
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) {
       		a.disabled = false;
     		  createCookie("style", title, 365);
     		  document.getElementById(title).style.display='none';
     	}
     }
   }
}

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 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 pop(url, target, width, height) {
	popup = window.open(url, target, 'toolbar=no,location=no,scrolling=auto,status=no,menubar=no,scrollbars=yes,resizable=no,width='+(width+22)+',height='+(height+101));
	popup.focus();
}

/* __________________________________________________________________________ */

function mini_pop(url, target, width, height) {

	if ((height+200)>screen.availHeight) {
		height = screen.availHeight-200;
	}

	popup = window.open(url, target, 'toolbar=no,location=no,scrolling=auto,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+(width+42)+',height='+(height+235));
	popup.focus();
}

      // GET X COORDINATE
      function getRealLeft(id) {
            var el = document.getElementById(id);
            if (el) {
                  xPos = el.offsetLeft;
                  tempEl = el.offsetParent;
                  while (tempEl != null) {
                        xPos += tempEl.offsetLeft;
                        tempEl = tempEl.offsetParent;
                  }
                  return xPos;
            }
      }
     
      // GET Y COORDINATE
      function getRealTop(id) {
			var el = document.getElementById(id);
            if (el) {
                  yPos = el.offsetTop;
                  tempEl = el.offsetParent;
                  while (tempEl != null) {
                        yPos += tempEl.offsetTop;
                        tempEl = tempEl.offsetParent;
                  }
                  return yPos;
            }
      }
     
	function showThumb( id, name, x, y )
	{
		var el = document.getElementById(id+"image");
		el.innerHTML="<img alt='pop up' src='/images/toenails/"+name+"'/>";
		document.getElementById(id+"image").style.top = (getRealTop( id+"shift" )+18)+'px';
		
		el.style.width=x+'px';
		el.style.height=y+'px';
		
		if( id == 'prev_' )
			el.style.left = (getRealLeft( id+"shift" )-(x)+75)+'px';
		else
			el.style.left = (getRealLeft( id+"shift" ))+'px';
		el.style.display='block';
	}
	
	function hideThumb( id )
	{
		var el = document.getElementById(id+"image");
		el.style.display='none';
	}
	
/**
 * @author ilkinulas@gmail.com
 * jquery plugin that rotates div elements inside a given div element
 */
var hiddenDivs = [];

jQuery.fn.divroller = function(options) {
	settings = jQuery.extend( {
		visible : 3,
		pause : 3000
	}, options);
	
	start(settings, this);
	
	
	function start(settings, container) {
		var divs = container.children();
		//hide unvisible divs
		while (settings.visible < divs.length) {
			var removedDiv = $(divs[divs.length - 1]).remove();
			hiddenDivs.push(removedDiv);
			divs = container.children();
		}
		
		setTimeout( function() {
			roll(settings, container)
		}, settings.pause);
		
	};

	function roll(settings, container) {
		//Dom manipulation.
		container.prepend(hiddenDivs.pop());
		hiddenDivs.unshift($(container.children()[settings.visible]).remove());
		
		//Efect
		$(container.children()[0]).hide();
		$(container.children()[0]).fadeIn("slow");

		//Repeat
		setTimeout( function() {
			roll(settings, container)
		}, settings.pause);
	}
}

/**
 * @author ilkinulas@gmail.com
 * jquery plugin that rotates div elements inside a given div element
 */
var hiddenDivs2 = [];

jQuery.fn.gifswapper = function(options) {
	settings = jQuery.extend( {
		visible : 1,
		pause : 3000
	}, options);
	
	start(settings, this);
	
	
	function start(settings, container) {
		var divs = container.children();
		//hide unvisible divs
		while (settings.visible < divs.length) {
			var removedDiv = $(divs[divs.length - 1]).remove();
			hiddenDivs2.push(removedDiv);
			divs = container.children();
		}
		
		setTimeout( function() {
			roll(settings, container)
		}, settings.pause);
		
	};

	function roll(settings, container) {
		//Dom manipulation.
		container.prepend(hiddenDivs2.pop());
		//$(container.children()[0]).fadeOut("slow");
		hiddenDivs2.unshift($(container.children()[settings.visible]).remove());
		
		//Efect
		$(container.children()[0]).show();

		//Repeat
		setTimeout( function() {
			roll(settings, container)
		}, settings.pause);
	}
}

/**
 * @author ilkinulas@gmail.com
 * jquery plugin that rotates div elements inside a given div element
 */
jQuery.fn.shoproller = function(options) {
	var hiddenDivs = [];

	settings = jQuery.extend( {
		visible : 3,
		pause : 3000
	}, options);
	
	start(settings, this);
	
	
	function start(settings, container) {
		var divs = container.children(".side_bar_shop_item");
		//hide unvisible divs
		while (settings.visible < divs.length) {
			var removedDiv = $(divs[divs.length - 1]).remove();
			hiddenDivs.push(removedDiv);
			divs = container.children();
		}
		
		setTimeout( function() {
			roll(settings, container)
		}, settings.pause);
		
	};

	function roll(settings, container) {
		//Dom manipulation.
		container.prepend(hiddenDivs.pop());
		hiddenDivs.unshift($(container.children()[settings.visible]).remove());
		
		//Efect
		$(container.children()[0]).hide();
		$(container.children()[0]).fadeIn("slow");

		//Repeat
		setTimeout( function() {
			roll(settings, container)
		}, settings.pause);
	}
}
