// Funzione che apre un div e chiude tutti gli altri //
jQuery(function(){
	
	checkLength(jQuery('#cartaMilesPage'),partial(slideshow));

});

function slideshow(){
	jQuery('#slideShowInterno').cycle({ 
		fx:     'fade', 
		speed:  500, 
		timeout: 5000, 
		pager:  '#slideshowNav', 
		pagerAnchorBuilder: function(idx, slide) { 
			// return selector string for existing anchor 
			return '#slideshowNav li:eq(' + idx + ') a'; 
		} 
	});
}

function THISonTHAToff(code) {

    ff = document.getElementsByTagName("div");
    for (i = 0; i < ff.length; i++) {
        if (ff[i].id.substr(0,5)=="onOff") {
            ff[i].style.display = "none";
        }
    }   
    for (i = 0; i < ff.length; i++) {
        if (ff[i].id == code) {
            if (ff[i].style.display == "none") {
                ff[i].style.display = "";
            }
        }
    }
}

// Funzione che apre e chiude un div cliccando sul link //

function THISonTHISoff(code) {
    ff = document.getElementById(code);
		if (ff.style.display == "") {
			ff.style.display = "none";
		} else
		if (ff.style.display == "none") {
			ff.style.display = "";
		}
}

// Funzione che apre la popup //

function Popup(url, stile) {
	window.open(url, "", stile);
	}
	
// Cambia classe //

function classChange(element,newclass) 
{
     document.getElementById(element).className = newclass;
}

function checkLength(el,func){
	if (el.length) { func(); } 
}

function partial(func,args) {
  	var args = Array.prototype.slice.call(arguments, 1);
  	return function() {
		var allArguments = args.concat(Array.prototype.slice.call(arguments));
		return func.apply(this, allArguments);
  	}
}

