/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  jagoskin.js - http://www.jagoskin.com/

  credits:
  CSS Browser Selector v0.2.5 : http://rafael.adm.br/css_browser_selector
  Dyn Random Banner : http://lineoflight.com/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

// CSS Browser Selector v0.2.5
var css_browser_selector = function() {
	var 
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
}();

// launcher
window.onload = init;

// onLoad event handler.
function init() {
	if (window.jagoInit) {
	jagoInit();
	}
}

// random banner.
function jagoInit() {
  cycleAds();
}

if (document.images) {
  adImages = new Array(
	"images/jagoskin/ss/umb_kamenrider1.jpg",
	"images/jagoskin/ss/umb_kamenrider2.jpg",
	"images/jagoskin/ss/umb_superhero.jpg",
	"images/jagoskin/ss/umb_sf.jpg",
	"images/jagoskin/ss/umb_pokemon.jpg",
	"images/jagoskin/ss/umb_bleach.jpg",
	"images/jagoskin/ss/umb_spongebob.jpg"
  );
  adURLs = new Array(
	"http://jagoskin.com/gallery/categories.php?cat_id=55",
	"http://jagoskin.com/gallery/categories.php?cat_id=55",
	"http://jagoskin.com/gallery/categories.php?cat_id=10",
	"http://jagoskin.com/gallery/categories.php?cat_id=58",
	"http://jagoskin.com/gallery/categories.php?cat_id=37",
	"http://jagoskin.com/gallery/categories.php?cat_id=26",
	"http://jagoskin.com/gallery/categories.php?cat_id=9"
  );
  thisAd = 0;
}

function cycleAds() {
  if (document.images)
  {
    if (document.jgSkin.complete)
    {
      // Get a random array index
      thisAd = Math.floor(Math.random() * adImages.length);

      // Or use the next two lines for sequential display
      //++thisAd;
      //thisAd %= adImages.length;

      document.jgSkin.src = adImages[thisAd];

      // This can be removed
      window.status = adURLs[thisAd];
    }
  }
  // Wait N seconds and repeat
  setTimeout("cycleAds()", 3000);
}

function goSkin() {
  document.location.href = adURLs[thisAd];
}
