/**
* Styleswitch stylesheet switcher built on jQuery
* Under an Attribution, Share Alike License
* By Kelvin Luck ( http://www.kelvinluck.com/ )
**/

// Embed YouTube video
(function($){
    
    $.fn.youtube = function(options) {
        
        var defaults = {
            iframe: true,
            video: "",
            width: "568",
            height: "400",
            play: "1",
            loop: "0",
            link: "external",
            controls: "1"
        };
        
        var o = $.extend(defaults, options);
                
        var height = o.height - 26;
        
        var videoDIV = "yt-" + o.video;
                                
        return this.each(function() {
            
            if (o.iframe === true) {
                $(this).html('<iframe id="'+videoDIV+'" width="'+o.width+'" height="'+height+'" src="http://www.youtube.com/embed/' + o.video + '?enablejsapi=1&amp;version=3&amp;wmode=transparent&amp;rel=0&amp;autohide=1&amp;showinfo=0&amp;controls='+o.controls+'&amp;autoplay='+o.play+'" frameborder="0" allowfullscreen></iframe>');
            }
                
            if (o.iframe === false) {
                $(this).html('<div id="' + videoDIV + '">')

                var flashvars = {
                    hd: "1",
                    fs: "1",
                    fmt: "18",
                    egm: "0",
                    loop: o.loop,
                    autoplay: o.play,
                    showinfo: "0",
                    autohide: "1",
                    showsearch: "0",
                    enablejsapi: "1",
                    playerapiid: this.id,
                    wmode: "transparent"
                };
                var params = {
                    wmode: "transparent",
                    allowscriptaccess: "always",
                    allowfullscreen: "true",
                    allownetworking: o.link
                };
                var attributes = {
                    id: o.video,
                    name: o.video
                };
                // All of the magic handled by SWFObject (http://code.google.com/p/swfobject/)
                swfobject.embedSWF("http://www.youtube.com/v/" + o.video +"&rel=0&version=1", videoDIV, o.width, height, "8", false, flashvars, params, attributes);            
            }
        })       
    };
}) (jQuery);


(function($)
{
	$(document).ready(function() {
		$('.styleswitch').click(function()
		{
			switchStylestyle(this.getAttribute("rel"));
			return false;
		});

	});


})(jQuery);

function switchStylestyle(styleName)
	{
		$('link[rel*=style][title]').each(function(i) 
		{
			this.disabled = true;
			if (this.getAttribute('title') == styleName) this.disabled = false;
		});
		createCookie('style', styleName, 365);
	}
// cookie functions http://www.quirksmode.org/js/cookies.html
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 eraseCookie(name)
{
	createCookie(name,"",-1);
}
// /cookie functions

		var c = readCookie('style');
		if (c) switchStylestyle(c);
