/* Marc Boronat                                                               */
/* Toggle Visibility                                                          */

var toggle_lmnt;

function showimg(url,clurl) {
    var popimg = document.createElement("div");
    popimg.setAttribute('class', 'popimg');
    popimg.setAttribute('className','popimg');
    popimg.style.visibility = "hidden";

    var theimage = document.createElement("img");
    theimage.setAttribute('src', url);
    theimage.setAttribute('class', 'theimage');
    theimage.setAttribute('className','theimage');

    var close = document.createElement("img");
    close.setAttribute('onclick', 'toggle_visibility(this.parentNode)');
    close.setAttribute('src', clurl);
    close.setAttribute('class', 'close');
    close.setAttribute('className','close');
    close.style.cursor = "pointer";

    popimg.appendChild(theimage);
    popimg.appendChild(close);

    document.documentElement.appendChild(popimg);
    toggle_visibility(popimg);
}

function showvideo(clurl) {
    var popimg = document.createElement("div");
    popimg.setAttribute('class', 'popimg');
    popimg.setAttribute('className','popimg');
    popimg.style.visibility = "hidden";

    var theimage = document.createElement("object");
    theimage.setAttribute('width', '400');
    theimage.setAttribute('height', '320');
    theimage.setAttribute('class', 'theobj');
    theimage.setAttribute('className','theobj');
    theimage.innerHTML = '<param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=11082574&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=11082574&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="320"></embed>';

    var close = document.createElement("img");
    close.setAttribute('onclick', 'toggle_visibility(this.parentNode)');
    close.setAttribute('src', clurl);
    close.setAttribute('class', 'obj-close');
    close.setAttribute('className','obj-close');
    close.style.cursor = "pointer";

    popimg.appendChild(theimage);
    popimg.appendChild(close);

    document.documentElement.appendChild(popimg);
    toggle_visibility(popimg);
}

function toggle_visibility(lmnt) {
    toggle_lmnt = lmnt;
    if(lmnt.style.visibility == "hidden"){
        lmnt.style.visibility = "visible";
        lmnt.style.opacity = 0.1;
        lmnt.style.filter = "alpha(opacity=1)";
        appear_int = window.setInterval("appear(toggle_lmnt);", 10);
    } else if (lmnt.style.visibility == "visible"){
        lmnt.style.opacity = 1.0;
        lmnt.style.filter = "alpha(opacity=100)";
        appear_int = window.setInterval("disappear(toggle_lmnt);", 10);
    }
}

function appear(lmnt) {
    if(lmnt.style.opacity >= 1){
        clearInterval(appear_int);
    } else {
        lmnt.style.opacity *= 1.2;
        lmnt.style.filter = "alpha(opacity="+(lmnt.style.opacity*100)+")";
    }
}

function disappear(lmnt) {
    if(lmnt.style.opacity <= 0.1){
        clearInterval(appear_int);
        document.documentElement.removeChild(lmnt);
    } else {
        lmnt.style.opacity -= 0.1;
        lmnt.style.filter = "alpha(opacity="+(lmnt.style.opacity*100)+")";
    }
}

/* Other functions                                                            */

var thelink;

function ie7_links(){
    if(navigator.appVersion.indexOf("MSIE 7.")==-1){
        thelink = document.getElementById('link1');
        if(thelink) {
            thelink.removeAttribute('target');
            thelink.setAttribute('href','#');
        }

        thelink = document.getElementById('link2');
        if(thelink) {
            thelink.removeAttribute('target');
            thelink.setAttribute('href','#');
        }

        thelink = document.getElementById('link3');
        if(thelink) {
            thelink.removeAttribute('target');
            thelink.setAttribute('href','#');
        }
    }
}