var root="";

function ApriPopup(idElem,lingua,stampa){
	window.open(root + '/News_popup.aspx?idElemento=' + idElem + '&lingua=' + lingua + '&stampa=' + stampa,'News','width=600,height=400,scrollbars=yes,toolbar=no,statusbar=no,resizable=yes');
	return false;
}
function InviaAmico(idElem,idCanale,lingua){
    window.open(root + '/InviaAmico_popup.aspx?idElemento=' + idElem + '&lingua=' + lingua + '&idCanale=' + idCanale, 'InviaAmico', 'width=600,height=450,scrollbars=yes,toolbar=no,statusbar=no,resizable=yes');
	return false;
}
function ValidaCategorie(oSrc, args){
	args.IsValid=false;
	var input=document.getElementsByTagName("input");
	for (i=0;i<input.length;i++) {
		if (input[i].id.substring(0,21)=="Template_chkCategorie") {
			if (input[i].checked) args.IsValid=true;
		}
	}
}
function digitaNomeForm() {
    var name = prompt("Inserisci il nome del form da duplicare: ");
    var el = document.getElementById("nomeFormDuplicato");
    if (name!=null && name!="" && name!="undefined") {
        el.value = name;
    }
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

document.onmousemove=sM;
document.onmouseup=sU;
var stD=false;
var mX,sMr;
function sD(e){
document.onmousedown=function(){return false;};
document.onselectstart=new Function ("return false");
sMr=document.getElementById("sM");
sMr.style.left=mX-1;
sMr.style.top=document.body.scrollTop;
sMr.style.height=document.body.clientHeight+"px";
sMr.style.display="block";
stD=true;
}
function sU(){
if(stD==false)return;
stD=false;
sMr.style.display="none";
el=document.getElementById("sL");
if(mX-3<50)mX=53;
else if(mX-3>500)mX=503;
el.style.width=mX-20+"px";
document.onselectstart=new Function("return true");
document.onmousedown=function(){return true;};
}
function sM(e){
if(window.event)mX=event.clientX;
else mX=e.pageX;
if(stD==true){
if(mX-1>49&&mX-1<501){sMr.style.left=mX-1;}
}
}
function NewWindow(url, w, h) 
{

// If you place Thumb.aspx in a different directory that your root image directory,
// you will need to add the image directory to url below, like:
// url = "/rootImageDirectory/" + url + ".jpg"

  //url = "fotogallery/" + url ;//+ ".jpg"
  //alert(url);
  if (w > screen.width || h > screen.width)
  {
    if (w > screen.width && h <= screen.height)
    {
      var nw = screen.width - 70;
      var nh = parseInt(h) + 36
    }
    if (h > screen.height && w <= screen.width)
    {
      var nh = screen.height - 70;
      var nw = parseInt(w) + 36
    }
    if (w > screen.width && h > screen.height)
    {
      var nh = screen.height - 70;
      var nw = screen.width - 70;
    }

    window.open(url,"_blank","width=" + nw + ",height=" + nh + ",left=0,top=0,scrollbars=yes,resizable=yes");

  }
  else
  {
    var nh = parseInt(h) + 25;
    var nw = parseInt(w) + 25;
    window.open(url,"_blank","width=" + nw + ",height=" + nh + ",scrollbars=no,resizable=no");
  }
  return false;
}

function attivaDisattivaTxtBoxAltro(IDCheckList,IDTextBoxAltro,n_check_altro) {
    var CheckAltroAnteprima = document.getElementById("AnteprimaForm_" + IDCheckList + "_" + n_check_altro);
    var textboxAltroAnteprima = document.getElementById("AnteprimaForm_" + IDTextBoxAltro);
    var CheckAltro = document.getElementById("Template__ctl2_" + IDCheckList + "_" + n_check_altro);
    var textboxAltro = document.getElementById("Template__ctl2_" + IDTextBoxAltro);
    if (CheckAltro != null) {
        if (CheckAltro.checked){
        	    textboxAltro.disabled = false;
        }
        else {
	        textboxAltro.disabled = true;
	        textboxAltro.value = "";
	    }
	}
	else if (CheckAltroAnteprima != null) {
        if (CheckAltroAnteprima.checked){
    	        textboxAltroAnteprima.disabled = false;
        }
        else {
	        textboxAltroAnteprima.disabled = true;
	        textboxAltroAnteprima.value = "";
	    }
	}
}

function attivaDisattivaInserimentoNRighe() {
    var Check = document.getElementById("chkMultiRows");
    var Text = document.getElementById("txtRows");
    if (Check.checked){
        Text.disabled = false;
    }
    else {
        Text.value = ""
        Text.disabled = true;
    }
}
function IsNumeric(ObjVal,ErrMsgToDsply) {
    if (/^\d+$/.test(ObjVal))
        return true;
    else {
        alert(ErrMsgToDsply);  
        return false;
    }
        
//return /^\d+$/.test(ObjVal) ? true : alert(ErrMsgToDsply),false;
}

function ForceNumbersOnly(myfield, e, dec) {
    var key;
    var keychar;

    if (window.event) {
        key = window.event.keyCode;
    }
    else if (e) {
        key = e.which;
    }
    else {
        if(dec !="") setNumber(myfield, dec);
        return true;
    }
    if (key != 46 && key != 45 && key > 31 && (key < 48 || key > 57)) {
        return false;
    }
    else {
        if (dec != "") setNumber(myfield, dec);
        return true;
    }
}

function RemoveNonNumeric(myfield) {
    var re = /[^0-9\.\-]/g;
    if (re.test(myfield.value)) {
        myfield.value = myfield.value.replace(re, '');
        myfield.value = myfield.value.replace(/\./, '');
    }
}
// _v numero da formattare _d formato es ####.00
function setNumber(_v, _d) {
    var v = String(_v.value).replace(/[^\d.-]*/gi, ""), m = _d; //this.mask;
    // make sure there's only one decimal point
    v = v.replace(/\./, "d").replace(/\./g, "").replace(/d/, ".");

    // check to see if an invalid mask operation has been entered
    if (!/^[\$]?((\$?[\+-]?([0#]{1,3},)?[0#]*(\.[0#]*)?)|([\+-]?\([\+-]?([0#]{1,3},)?[0#]*(\.[0#]*)?\)))$/.test(m))
        return alert( "An invalid mask was specified for the \nMask constructor.");

    //if ( (v.length == this.strippedValue.length)) v = v.substring(0, v.length - 1);

    if ( (v.replace(/[^0-9]/, "").length == 0)) return v;
    _v.value = v;

    if (v.length == 0) v = NaN;
    var vn = Number(v);
    if (isNaN(vn)) return alert("The value entered was not a number.");

    // if no mask, stop processing
    if (m.length == 0) return v;

    // get the value before the decimal point
    var vi = String(Math.abs((v.indexOf(".") > -1) ? v.split(".")[0] : v));
    // get the value after the decimal point
    var vd = (v.indexOf(".") > -1) ? v.split(".")[1] : "";
    var _vd = vd;

    var isNegative = (vn != 0 && Math.abs(vn) * -1 == vn);

    // check for masking operations
    var show = {
        "$": /^[\$]/.test(m),
        "(": (isNegative && (m.indexOf("(") > -1)),
        "+": ((m.indexOf("+") != -1) && !isNegative)
    }
    show["-"] = (isNegative && (!show["("] || (m.indexOf("-") != -1)));


    // replace all non-place holders from the mask
    m = m.replace(/[^#0.,]*/gi, "");

    /*
    make sure there are the correct number of decimal places
    */
    // get number of digits after decimal point in mask
    var dm = (m.indexOf(".") > -1) ? m.split(".")[1] : "";
    if (dm.length == 0) {
        vi = String(Math.round(Number(vi)));
        vd = "";
    } else {
        // find the last zero, which indicates the minimum number
        // of decimal places to show
        var md = dm.lastIndexOf("0") + 1;
        // if the number of decimal places is greater than the mask, then round off
        if (vd.length > dm.length) vd = String(Math.round(Number(vd.substring(0, dm.length + 1)) / 10));
        // otherwise, pad the string w/the required zeros
        else while (vd.length < md) vd += "0";
    }

    /*
    pad the int with any necessary zeros
    */
    // get number of digits before decimal point in mask
    var im = (m.indexOf(".") > -1) ? m.split(".")[0] : m;
    im = im.replace(/[^0#]+/gi, "");
    // find the first zero, which indicates the minimum length
    // that the value must be padded w/zeros
    var mv = im.indexOf("0") + 1;
    // if there is a zero found, make sure it's padded
    if (mv > 0) {
        mv = im.length - mv + 1;
        while (vi.length < mv) vi = "0" + vi;
    }


    /*
    check to see if we need commas in the thousands place holder
    */
    if (/[#0]+,[#0]{3}/.test(m)) {
        // add the commas as the place holder
        var x = [], i = 0, n = Number(vi);
        while (n > 999) {
            x[i] = "00" + String(n % 1000);
            x[i] = x[i].substring(x[i].length - 3);
            n = Math.floor(n / 1000);
            i++;
        }
        x[i] = String(n % 1000);
        vi = x.reverse().join(",");
    }


    /*
    combine the new value together
    */
    if ((vd.length > 0 && !true) || ((dm.length > 0) && true && (v.indexOf(".") > -1) && (_vd.length >= vd.length))) {
        v = vi + "." + vd;
    } else if ((dm.length > 0) && true && (v.indexOf(".") > -1) && (_vd.length < vd.length)) {
        v = vi + "." + _vd;
    } else {
        v = vi;
    }

    if (show["$"]) v = this.mask.replace(/(^[\$])(.+)/gi, "$") + v;
    if (show["+"]) v = "+" + v;
    if (show["-"]) v = "-" + v;
    if (show["("]) v = "(" + v + ")";
    _v.value = v;
}

function selectAllCheckboxList(listID,destCount) {
    var i
    for (i = 0; i < destCount; i++){
        var item = document.getElementById("Template_ModuloInvioSMS_CheckList_LD_" + listID + "_" + i);
        if (item.disabled == false){
	        item.checked = true ;
	    }
	}
	attivaDisativaPulsanteVerificaTesto();
}
function deselectAllCheckboxList(listID,destCount) {
    var i
    for (i = 0; i < destCount; i++){
        var item = document.getElementById("Template_ModuloInvioSMS_CheckList_LD_" + listID + "_" + i);
	        item.checked = false ;
	}
	attivaDisativaPulsanteVerificaTesto();
}
function attivaDisativaPulsanteVerificaTesto() {
    var testo = document.getElementById("Template_ModuloInvioSMS_txbTestoSMS");
    var pulsante = document.getElementById("Template_ModuloInvioSMS_btnVerificaTestoSMS");
    if (testo.value != "") {
        pulsante.disabled = false;
    }
    else {
        pulsante.disabled = true;
    }
}
function conteggioCaratteriRimanenti(numCar) {
    var testo = document.getElementById("Template_ModuloInvioSMS_txbTestoSMS");
    if (testo == null) {
        testo = document.getElementById("AUC_TabellaMod_Oggetto");
    }
    var caratteri = testo.value;
    var label = document.getElementById("Template_ModuloInvioSMS_txbNumCarTesto");
    if (label == null) {
        label = document.getElementById("AUC_TabellaMod_NumCarOggetto");
    }
    label.value = (numCar - caratteri.length)
    if (label.value < 0) {
        alert("Il numero di caratteri inseriti \u00E8 superiore al consentito.");
    }
}
function confermaInvioSMS() {
    var conferma=confirm("Conferma invio sms");
    var conf = document.getElementById("Template_ModuloInvioSMS_confermaInvio");
    if (conferma==true){
        conf.value = true;
    }
    else {
        conf.value = false;
        alert("Invio fermato");
    }
}

function NascondiAlbero() {
    var livelli;

    livelli = document.getElementsByTagName("div");
    for (i = 0; i < livelli.length; i++) {
        if (livelli[i].id.indexOf("divCategorieNewsletter") != -1) {
            livelli[i].className = "nascondiCat";
        }
    }
}
var isNS4 = (navigator.appName == "Netscape") ? 1 : 0;

function Espandi(oggetto, sub_nomeHREF, sub_nomeDIV, sub_nomeIMG, css_Espandi, css_Comprimi) {

    var NomeOggetto, NomeOggetto2, NomeOggetto3, Oggetto2, Oggetto3

    //oggetto HREF
    NomeOggetto = oggetto.id
    //eseguo il replace per operare sul DIV
    NomeOggetto2 = NomeOggetto.replace(sub_nomeHREF, sub_nomeDIV)
    //eseguo il replace per operare sul IMG
    NomeOggetto3 = NomeOggetto.replace(sub_nomeHREF, sub_nomeIMG)

    //oggetto DIV
    Oggetto2 = document.getElementById(NomeOggetto2)
    //oggetto IMG
    Oggetto3 = document.getElementById(NomeOggetto3)

    //imposto le proprietà desiderate per gli oggetti
    if (Oggetto2.className == css_Espandi) {
        Oggetto2.className = css_Comprimi
        Oggetto3.src = "/images/blueup.gif"
        Oggetto3.alt = "Espandi"

    } else {
        Oggetto2.className = css_Espandi
        Oggetto3.src = "/images/bluedrop.gif"
        Oggetto3.alt = "Comprimi"
    }
}

function getElementLeft(elm) {
    var x = 0;

    //set x to elm’s offsetLeft
    x = elm.offsetLeft;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while (elm != null) {
        x = parseInt(x) + parseInt(elm.offsetLeft);
        elm = elm.offsetParent;
    }
    return x;
}

function getElementTop(elm) {
    var y = 0;

    //set x to elm’s offsetLeft
    y = elm.offsetTop;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while (elm != null) {
        y = parseInt(y) + parseInt(elm.offsetTop);
        elm = elm.offsetParent;
    }

    return y;
}
function Out() {
    document.getElementById("imgboxZoom").style.visibility = 'hidden';
}
function Large(obj, imgPath) {
    var imgbox = document.getElementById("imgboxZoom");
    var title = document.createElement("div");
    var imgx = document.createElement("img");
    var img = document.createElement("img");
    var offSetTop = 45; // offset verticale dell' ingrandimento immagine
    var offSetLeft = 20; // offset orizzontale dell' ingrandimento immagine
    var tP = 3; // padding del titolo
    var iL = 500; // larghezza immagine articolo
    var iH = 500; // altezza immagine articolo
    var xL = 22; // larghezza icona X chiusura ingrandimento immagine
    var xH = 22; // altezza icona X chiusura ingrandimento immagine

    imgbox.style.visibility = 'visible';
    imgbox.style.height = iH + xH + 'px';
    imgbox.style.width = iL + 'px';
    
    img.src = imgPath;
    img.style.width = iL + 'px';
    img.style.height = iH + 'px';
    imgx.src = root + "/images/chiudi_imgArt.png";
    imgx.setAttribute('style', 'float:right;');
    imgx.style.styleFloat = 'right';
    imgx.style.width = xL + 'px';
    imgx.style.height = xH + 'px';
    imgx.style.display = 'block';
    imgx.style.padding = '0px';
    imgx.style.margin = '0px';
    imgx.style.cursor = 'hand';
    title.setAttribute('style', 'float:left;');
    title.style.styleFloat = 'left';
    title.style.display = 'block';
    title.style.width = iL - xL - (tP * 2) + 'px';
    title.innerHTML = imgPath.substring(imgPath.lastIndexOf("/") + 1, imgPath.lastIndexOf("."));
    title.style.padding = tP + 'px';
    title.style.background = '#eeeeee';
    title.style.color = '#000000';
    title.style.margin = '0px';
    // for (i in title.style) alert(i+' - ' +title.style[i]);
    if (img.addEventListener) {
        imgx.addEventListener('click', Out, false);
    } else {
        imgx.attachEvent('onclick', Out);
    }
    imgbox.innerHTML = '';
    imgbox.appendChild(title);
    imgbox.appendChild(imgx);
    imgbox.appendChild(img);
    imgbox.style.left = (getElementLeft(obj) + offSetLeft) + 'px';
    imgbox.style.top = (getElementTop(obj) + offSetTop) + 'px';
}
// FUNZIONI aggiunte in occasione delle Implementazioni Accessibilità P.A.
// Data: dicembre 2010
// riguardano l' utilizzo del WeManager per selezionare le immagini
// e riguardano l' utilizzo del nuovo CKeditor
// rifImmagine = ID dell' asp:TextBox contenente l' url dell' immagine
function selezionaImmagine(rifImmagine) {
    window.open(root + '/Admin/WebFileManager/editor.aspx?path=' + root + '/UserFile/Image&sort=Name'+'&r=' +rifImmagine, 'SelezionaImmagine' + rifImmagine, 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
}
function anteprimaImmagine(ClientIdImmaginePrew) {
    document.getElementById(ClientIdImmaginePrew).src = document.getElementById(event.srcElement.id).value;
}
function aggiornaImmagine(rifImmagine) {
    document.getElementById(rifImmagine + 'Prew').src = document.getElementById(rifImmagine).value;
}

/*
Title: equalHeights
*/
$.fn.equalHeights = function(px) {
$(this).each(function() {
var currentTallest = 0;
$(this).children().each(function(i) {
if ($(this).outerHeight(true) > currentTallest) { currentTallest = $(this).outerHeight(true); }
});
// for ie6, set height since min-height isn't supported
if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({ 'height': currentTallest }); }
$(this).children().css({ 'min-height': currentTallest });
});
return this;
};
/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
*
* @param f onMouseOver function || An object with configuration options
* @param g onMouseOut function || Nothing (use configuration options object)
* @author Brian Cherne brian(at)cherne(dot)net
*/
(function($) { $.fn.hoverIntent = function(f, g) { var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function(ev) { cX = ev.pageX; cY = ev.pageY }; var compare = function(ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]) } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function() { compare(ev, ob) }, cfg.interval) } }; var delay = function(ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]) }; var handleHover = function(e) { var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t) } if (e.type == "mouseenter") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function() { compare(ev, ob) }, cfg.interval) } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function() { delay(ev, ob) }, cfg.timeout) } } }; return this.bind('mouseenter', handleHover).bind('mouseleave', handleHover) } })(jQuery);
/*
Title: jShowOff: a jQuery Content Rotator Plugin
Author: Erik Kallevig
Version: 0.1.2
Website: http://ekallevig.com/jshowoff
License: Dual licensed under the MIT and GPL licenses.
*/
(function($) {
$.fn.jshowoff = function(settings) {
var config = { animatePause: true, autoPlay: true, changeSpeed: 1000, controls: true, controlText: { play: 'Play', pause: 'Pause', next: 'Next', previous: 'Previous' }, effect: 'fade', hoverPause: true, links: true, speed: 3000 }; if (settings) $.extend(true, config, settings); if (config.speed < (config.changeSpeed + 20)) { alert('jShowOff: Make speed at least 20ms longer than changeSpeed; the fades aren\'t always right on time.'); return this; }; this.each(function(i) {
var $cont = $(this); var gallery = $(this).children().remove(); var timer = ''; var counter = 0; var preloadedImg = []; var howManyInstances = $('.jshowoff').length + 1; var uniqueClass = 'jshowoff-' + howManyInstances; var cssClass = config.cssClass != undefined ? config.cssClass : ''; $cont.css('position', 'relative').wrap('<div class="jshowoff ' + uniqueClass + '" />'); var $wrap = $('.' + uniqueClass); $wrap.css('position', 'relative').addClass(cssClass); $(gallery[0]).clone().appendTo($cont); preloadImg(); if (config.controls) { addControls(); if (config.autoPlay == false) { $('.' + uniqueClass + '-play').addClass(uniqueClass + '-paused jshowoff-paused').text(config.controlText.play); }; }; if (config.links) { addSlideLinks(); $('.' + uniqueClass + '-slidelinks a').eq(0).addClass(uniqueClass + '-active jshowoff-active'); }; if (config.hoverPause) { $cont.hover(function() { if (isPlaying()) pause('hover'); }, function() { if (isPlaying()) play('hover'); }); }; if (config.autoPlay && gallery.length > 1) { timer = setInterval(function() { play(); }, config.speed); }; if (gallery.length < 1) { $('.' + uniqueClass).append('<p>For jShowOff to work, the container element must have child elements.</p>'); }; function transitionTo(gallery, index) {
var oldCounter = counter; if ((counter >= gallery.length) || (index >= gallery.length)) { counter = 0; var e2b = true; }
else if ((counter < 0) || (index < 0)) { counter = gallery.length - 1; var b2e = true; }
else { counter = index; }
if (config.effect == 'slideLeft') { var newSlideDir, oldSlideDir; function slideDir(dir) { newSlideDir = dir == 'right' ? 'left' : 'right'; oldSlideDir = dir == 'left' ? 'left' : 'right'; }; counter >= oldCounter ? slideDir('left') : slideDir('right'); $(gallery[counter]).clone().appendTo($cont).slideIt({ direction: newSlideDir, changeSpeed: config.changeSpeed }); if ($cont.children().length > 1) { $cont.children().eq(0).css('position', 'absolute').slideIt({ direction: oldSlideDir, showHide: 'hide', changeSpeed: config.changeSpeed }, function() { $(this).remove(); }); }; } else if (config.effect == 'fade') { $(gallery[counter]).clone().appendTo($cont).hide().fadeIn(config.changeSpeed, function() { if ($.browser.msie) this.style.removeAttribute('filter'); }); if ($cont.children().length > 1) { $cont.children().eq(0).css('position', 'absolute').fadeOut(config.changeSpeed, function() { $(this).remove(); }); }; } else if (config.effect == 'none') { $(gallery[counter]).clone().appendTo($cont); if ($cont.children().length > 1) { $cont.children().eq(0).css('position', 'absolute').remove(); }; }; if (config.links) { $('.' + uniqueClass + '-active').removeClass(uniqueClass + '-active jshowoff-active'); $('.' + uniqueClass + '-slidelinks a').eq(counter).addClass(uniqueClass + '-active jshowoff-active'); };
}; function isPlaying() { return $('.' + uniqueClass + '-play').hasClass('jshowoff-paused') ? false : true; }; function play(src) {
if (!isBusy()) {
counter++; transitionTo(gallery, counter); if (src == 'hover' || !isPlaying()) { timer = setInterval(function() { play(); }, config.speed); }
if (!isPlaying()) { $('.' + uniqueClass + '-play').text(config.controlText.pause).removeClass('jshowoff-paused ' + uniqueClass + '-paused'); }
};
}; function pause(src) { clearInterval(timer); if (!src || src == 'playBtn') $('.' + uniqueClass + '-play').text(config.controlText.play).addClass('jshowoff-paused ' + uniqueClass + '-paused'); if (config.animatePause && src == 'playBtn') { $('<p class="' + uniqueClass + '-pausetext jshowoff-pausetext">' + config.controlText.pause + '</p>').css({ fontSize: '62%', textAlign: 'center', position: 'absolute', top: '40%', lineHeight: '100%', width: '100%' }).appendTo($wrap).addClass(uniqueClass + 'pauseText').animate({ fontSize: '600%', top: '30%', opacity: 0 }, { duration: 500, complete: function() { $(this).remove(); } }); } }; function next() { goToAndPause(counter + 1); }; function previous() { goToAndPause(counter - 1); }; function isBusy() { return $cont.children().length > 1 ? true : false; }; function goToAndPause(index) { $cont.children().stop(true, true); if ((counter != index) || ((counter == index) && isBusy())) { if (isBusy()) $cont.children().eq(0).remove(); transitionTo(gallery, index); pause(); }; }; function preloadImg() { $(gallery).each(function(i) { $(this).find('img').each(function(i) { preloadedImg[i] = $('<img>').attr('src', $(this).attr('src')); }); }); }; function addControls() { $wrap.append('<p class="jshowoff-controls ' + uniqueClass + '-controls"><a class="jshowoff-play ' + uniqueClass + '-play" href="#null">' + config.controlText.pause + '</a> <a class="jshowoff-prev ' + uniqueClass + '-prev" href="#null">' + config.controlText.previous + '</a> <a class="jshowoff-next ' + uniqueClass + '-next" href="#null">' + config.controlText.next + '</a></p>'); $('.' + uniqueClass + '-controls a').each(function() { if ($(this).hasClass('jshowoff-play')) $(this).click(function() { isPlaying() ? pause('playBtn') : play(); return false; }); if ($(this).hasClass('jshowoff-prev')) $(this).click(function() { previous(); return false; }); if ($(this).hasClass('jshowoff-next')) $(this).click(function() { next(); return false; }); }); }; function addSlideLinks() { $wrap.append('<p class="jshowoff-slidelinks ' + uniqueClass + '-slidelinks"></p>'); $.each(gallery, function(i, val) { var linktext = $(this).attr('title') != '' ? $(this).attr('title') : i + 1; $('<a class="jshowoff-slidelink-' + i + ' ' + uniqueClass + '-slidelink-' + i + '" href="#null">' + linktext + '</a>').bind('click', { index: i }, function(e) { goToAndPause(e.data.index); return false; }).appendTo('.' + uniqueClass + '-slidelinks'); }); };
}); return this;
};
})(jQuery); (function($) { $.fn.slideIt = function(settings, callback) { var config = { direction: 'left', showHide: 'show', changeSpeed: 1000 }; if (settings) $.extend(config, settings); this.each(function(i) { $(this).css({ left: 'auto', right: 'auto', top: 'auto', bottom: 'auto' }); var measurement = (config.direction == 'left') || (config.direction == 'right') ? $(this).outerWidth() : $(this).outerHeight(); var startStyle = {}; startStyle['position'] = $(this).css('position') == 'static' ? 'relative' : $(this).css('position'); startStyle[config.direction] = (config.showHide == 'show') ? '-' + measurement + 'px' : 0; var endStyle = {}; endStyle[config.direction] = config.showHide == 'show' ? 0 : '-' + measurement + 'px'; $(this).css(startStyle).animate(endStyle, config.changeSpeed, callback); }); return this; }; })(jQuery);
/*!
* jQuery Cycle Lite Plugin
* http://malsup.com/jquery/cycle/lite/
* Copyright (c) 2008-2011 M. Alsup
* Version: 1.3.1 (07-OCT-2011)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Requires: jQuery v1.3.2 or later
*/
; (function($) {
var ver = 'Lite-1.3';
$.fn.cycle = function(options) {
return this.each(function() {
options = options || {};
if (this.cycleTimeout) clearTimeout(this.cycleTimeout);
this.cycleTimeout = 0;
this.cyclePause = 0;
var $cont = $(this);
var $slides = options.slideExpr ? $(options.slideExpr, this) : $cont.children();
var els = $slides.get();
if (els.length < 2) {
window.console && console.log('terminating; too few slides: ' + els.length);
return; // don't bother
}
// support metadata plugin (v1.0 and v2.0)
var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null;
if (meta)
opts = $.extend(opts, meta);
opts.before = opts.before ? [opts.before] : [];
opts.after = opts.after ? [opts.after] : [];
opts.after.unshift(function() { opts.busy = 0; });
// allow shorthand overrides of width, height and timeout
var cls = this.className;
opts.width = parseInt((cls.match(/w:(\d+)/) || [])[1]) || opts.width;
opts.height = parseInt((cls.match(/h:(\d+)/) || [])[1]) || opts.height;
opts.timeout = parseInt((cls.match(/t:(\d+)/) || [])[1]) || opts.timeout;
if ($cont.css('position') == 'static')
$cont.css('position', 'relative');
if (opts.width)
$cont.width(opts.width);
if (opts.height && opts.height != 'auto')
$cont.height(opts.height);
var first = 0;
$slides.css({ position: 'absolute', top: 0, right: 0 }).each(function(i) {
$(this).css('z-index', els.length - i)
});
$(els[first]).css('opacity', 1).show(); // opacity bit needed to handle reinit case
if ($.browser.msie) els[first].style.removeAttribute('filter');
if (opts.fit && opts.width)
$slides.width(opts.width);
if (opts.fit && opts.height && opts.height != 'auto')
$slides.height(opts.height);
if (opts.pause)
$cont.hover(function() { this.cyclePause = 1; }, function() { this.cyclePause = 0; });
var txFn = $.fn.cycle.transitions[opts.fx];
txFn && txFn($cont, $slides, opts);
$slides.each(function() {
var $el = $(this);
this.cycleH = (opts.fit && opts.height) ? opts.height : $el.height();
this.cycleW = (opts.fit && opts.width) ? opts.width : $el.width();
});
if (opts.cssFirst)
$($slides[first]).css(opts.cssFirst);
if (opts.timeout) {
// ensure that timeout and speed settings are sane
if (opts.speed.constructor == String)
opts.speed = { slow: 600, fast: 200}[opts.speed] || 400;
if (!opts.sync)
opts.speed = opts.speed / 2;
while ((opts.timeout - opts.speed) < 250)
opts.timeout += opts.speed;
}
opts.speedIn = opts.speed;
opts.speedOut = opts.speed;
opts.slideCount = els.length;
opts.currSlide = first;
opts.nextSlide = 1;
// fire artificial events
var e0 = $slides[first];
if (opts.before.length)
opts.before[0].apply(e0, [e0, e0, opts, true]);
if (opts.after.length > 1)
opts.after[1].apply(e0, [e0, e0, opts, true]);
if (opts.click && !opts.next)
opts.next = opts.click;
if (opts.next)
$(opts.next).bind('click', function() { return advance(els, opts, opts.rev ? -1 : 1) });
if (opts.prev)
$(opts.prev).bind('click', function() { return advance(els, opts, opts.rev ? 1 : -1) });
if (opts.timeout)
this.cycleTimeout = setTimeout(function() {
go(els, opts, 0, !opts.rev)
}, opts.timeout + (opts.delay || 0));
});
};
function go(els, opts, manual, fwd) {
if (opts.busy) return;
var p = els[0].parentNode, curr = els[opts.currSlide], next = els[opts.nextSlide];
if (p.cycleTimeout === 0 && !manual)
return;
if (manual || !p.cyclePause) {
if (opts.before.length)
$.each(opts.before, function(i, o) { o.apply(next, [curr, next, opts, fwd]); });
var after = function() {
if ($.browser.msie)
this.style.removeAttribute('filter');
$.each(opts.after, function(i, o) { o.apply(next, [curr, next, opts, fwd]); });
queueNext();
};
if (opts.nextSlide != opts.currSlide) {
opts.busy = 1;
$.fn.cycle.custom(curr, next, opts, after);
}
var roll = (opts.nextSlide + 1) == els.length;
opts.nextSlide = roll ? 0 : opts.nextSlide + 1;
opts.currSlide = roll ? els.length - 1 : opts.nextSlide - 1;
}
function queueNext() {
if (opts.timeout)
p.cycleTimeout = setTimeout(function() { go(els, opts, 0, !opts.rev) }, opts.timeout);
}
};
// advance slide forward or back
function advance(els, opts, val) {
var p = els[0].parentNode, timeout = p.cycleTimeout;
if (timeout) {
clearTimeout(timeout);
p.cycleTimeout = 0;
}
opts.nextSlide = opts.currSlide + val;
if (opts.nextSlide < 0) {
opts.nextSlide = els.length - 1;
}
else if (opts.nextSlide >= els.length) {
opts.nextSlide = 0;
}
go(els, opts, 1, val >= 0);
return false;
};
$.fn.cycle.custom = function(curr, next, opts, cb) {
var $l = $(curr), $n = $(next);
$n.css(opts.cssBefore);
var fn = function() { $n.animate(opts.animIn, opts.speedIn, opts.easeIn, cb) };
$l.animate(opts.animOut, opts.speedOut, opts.easeOut, function() {
$l.css(opts.cssAfter);
if (!opts.sync) fn();
});
if (opts.sync) fn();
};
$.fn.cycle.transitions = {
fade: function($cont, $slides, opts) {
$slides.not(':eq(0)').hide();
opts.cssBefore = { opacity: 0, display: 'block' };
opts.cssAfter = { display: 'none' };
opts.animOut = { opacity: 0 };
opts.animIn = { opacity: 1 };
},
fadeout: function($cont, $slides, opts) {
opts.before.push(function(curr, next, opts, fwd) {
$(curr).css('zIndex', opts.slideCount + (fwd === true ? 1 : 0));
$(next).css('zIndex', opts.slideCount + (fwd === true ? 0 : 1));
});
$slides.not(':eq(0)').hide();
opts.cssBefore = { opacity: 1, display: 'block', zIndex: 1 };
opts.cssAfter = { display: 'none', zIndex: 0 };
opts.animOut = { opacity: 0 };
}
};
$.fn.cycle.ver = function() { return ver; };
// @see: http://malsup.com/jquery/cycle/lite/
$.fn.cycle.defaults = {
animIn: {},
animOut: {},
fx: 'fade',
after: null,
before: null,
cssBefore: {},
cssAfter: {},
delay: 0,
fit: 0,
height: 'auto',
metaAttr: 'cycle',
next: null,
pause: 0,
prev: null,
speed: 1000,
slideExpr: null,
sync: 1,
timeout: 4000
};
})(jQuery); 
