

// ------------------------------------------------------------------------------------
// slideViewer Setup
// http://www.gcmingati.net/wordpress/wp-content/lab/jquery/imagestrip/imageslide-plugin.html

/*// Option 1: No tooltips
$(window).bind("load", function() {
	$("div#gallery").slideView()
});
*/

/* // Option 2: Use alt tags for tooltip
$(window).bind("load", function() {
	$("div#gallery").slideView({toolTip: true, ttOpacity: 0.5}) // ttOpacity can be 0.1 to 1.0
});
*/

// Set the slide speed (in ms), smaller is faster
$(window).bind("load", function() {
	$("div#myInstantGallery").slideView({
		easeFunc: "easeInOutBack",
		easeTime: 700
	});
});

// Option 3: No Tooltips, with AUTO SCROLL
var theLinks;
var nCount = 0;
var theTimerID;
function init(){
    $("div#gallery").slideView();
    theLinks = jQuery('#stripTransmitter0 a');
        //for kill interval purposes
        theTimerID = setInterval("autoSlide()", 5000);
}
function autoSlide(){
    jQuery.each(theLinks, function(i){
        if(jQuery(this).hasClass('current')){
            jQuery(theLinks[((i+1 < theLinks.length) ? (i+1) : 0)] ).trigger("click");
            return false;
        }
    });
}
$(window).bind("load", init );



// ------------------------------------------------------------------------------------
// s3Slider Setup
// http://www.serie3.info/s3slider/demonstration.html
/*
$(document).ready(function() {
   $('#s3slider').s3Slider({
      timeOut: 4000
   });
});
*/

// SlideShow2: http://www.electricprism.com/aeron/slideshow/


// ------------------------------------------------------------------------------------
// COOKIE
// http://www.quirksmode.org/js/cookies.html

// Write to the cookie
//
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=/";
}

// Read from the cookie
//
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;
}

// Erase cookie
//
function eraseCookie(name) {
	createCookie(name,"",-1);
}


// Wrapper to set the cookie
//
function setLanguage(Language)
{
	createCookie("Language",Language,365);
}

// Wrapper to get the language from the cookie
//
function getLanguage()
{
	var defaultLang = "es";	// es = Spanish, en = English, it, de, fr
	var Lang = readCookie("Language");	// BROKEN, perhaps not saving properly
	// Go to default
	if (Lang == null || Lang == undefined || Lang == 'undefined' || Lang == '')
	{
		setLanguage(defaultLang);
		return defaultLang;
	}
	else
		return Lang;
}

// Redirect browser to this language
//
function redirectToLanguage()
{
	window.location = getLanguage() + "/home.html";
}

function changeLanguage(Language)
{
	setLanguage(Language);
	window.location = "../" + Language + "/home.html";
}
