﻿/*
var FINAL_URL = 'http://www.pinkribbonmagazine.nl/gallery/'
if (location.href.indexOf(".local") > -1 || location.href.indexOf(".accep") > -1 || location.href.indexOf(".dev") > -1) FINAL_URL = 'iframetest.html'
*/
window.onload = function() {
    Cufon.now();
    if (document.getElementById("flashcontent")) {
        var flashvars = {
            settingsXML: "flashsettings.aspx"
        };
        var params = {
            menu: "false",
            scale: "noScale",
            allowFullscreen: "true",
            allowScriptAccess: "always",
            wmode: "transparent"
        };
        if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i)) {
            document.getElementById("flashcontent").style.display = 'none';

            // document.getElementById("iOS").style.display = 'block';
        }
        else {
            swfobject.embedSWF("doorslapen.swf", "flashcontent", "960", "909", "10.0", "expressInstall.swf", flashvars, params, { id: "flashcontent" });
        }
    }

    if (document.getElementById("playerflashcontent")) {
        var flashvars = {
            settingsXML: "flashsettings.aspx"
        };
        var params = {
            menu: "false",
            scale: "noScale",
            allowFullscreen: "true",
            allowScriptAccess: "always",
            wmode: "transparent"
        };
        if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i)) {
            document.getElementById("playerflashcontent").style.display = 'none';
            // document.getElementById("iOS").style.display = 'block';
        }
        else {

            swfobject.embedSWF("doorslapen_player.swf", "playerflashcontent", "90", "40", "10.0", "expressInstall.swf", flashvars, params, { id: "playerflashcontent" });

        }
    }
}

$(function() {
    initPoll();
})

function uploadFacebook(data) {
    window.open('Facebook/Upload.aspx?url=' + data.url + '&caption=' + data.caption, 'social' + randomID(), 'width=1000,height=430,scrollbars=auto,toolbar=no,location=yes');
}

function downloadFacebook() {
    window.open('Facebook/Download.aspx', 'social' + randomID(), 'width=1000,height=430,scrollbars=auto,toolbar=no,location=yes'); 
}

function uploadHyves(data) {
    window.open('api/Hyves/Upload.aspx?url=' + data.url + '&caption=' + data.caption, 'social' + randomID(), 'width=1000,height=430,scrollbars=auto,toolbar=no,location=yes'); 
}

function downloadHyves() {
    window.open('api/Hyves/AlbumsView.aspx', 'social' + randomID(), 'width=1000,height=430,scrollbars=auto,toolbar=no,location=yes');
}

function randomID() { return (Math.random() * 999) >> 0 }

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);
}

function getFlashMovie(movieName) {
    document.getElementById(movieName).setAttribute("name", movieName);

    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? window[movieName] : document[movieName];
}

function sendNewImage(url) {
    getFlashMovie("flashcontent").sendNewImage(url);
}

function setHeight(newHeight)
{
    getFlashMovie("flashcontentr").style.height = newHeight + "px";
}



$(function() {
    menuCenter();
    //tipsFrame();
    $('.scroll-pane').jScrollPane(
        {
            verticalDragMinHeight: 16,
            verticalDragMaxHeight: 16,
            horizontalDragMinWidth: 16,
            horizontalDragMaxWidth: 16
        }
    );

    $('a.overlay').colorbox({
        innerWidth: '716px',
        opacity: '0',
        transition: 'elastic',
        initialWidth: '716px',
        initialHeight: '100px'
    });

    $('#slider').anythingSlider({
        buildArrows: true,
        buildNavigation: false,
        buildStartStop: false,
        autoPlay: false,
        hashTags: false
    });
    $('a.tipsoverlay').colorbox({
        innerWidth: '716px',
        innerHeight: '350px',
        opacity: '0',
        transition: 'elastic',
        initialWidth: '716px',
        initialHeight: '100px',
        iframe: true
    });
    //alert($("div.pageTips").height);
});
/* Tips iFrame resize
function tipsFrame() {
    $('iframe').attr('src', getIframeUrl());
    registerEvents();
    resizeIframe();
    alert("Ola");
}

function getIframeUrl() {
    var url = window.location.href;
    var iframe_url = 'http://doorslapeniframe.local/';
    var param_start = url.indexOf("iframe=");
    if (param_start != -1)
        iframe_url = url.substr(param_start + 7, url.length - param_start - 7);
    if (iframe_url.indexOf("http://") == -1)
        iframe_url = "http://" + iframe_url;

    return iframe_url;
}
function resizeIframe()
{
	$("#tipsiframe").height( WindowHeight());
}

function WindowHeight()
{
	var de = document.documentElement;
	return self.innerHeight ||
		(de &amp;amp;amp;&amp;amp;amp; de.clientHeight ) ||
		document.body.clientHeight;
}

function getObjHeight(obj)
{
	if( obj.offsetWidth )
	{
		return obj.offsetHeight;
	}
	return obj.clientHeight;
}
/*end tips iframe*/
function menuCenter() {
/*
    $("#navigation ul li:last").css("margin-right", "0px");

    var menuWidth = $("#nav_middle").width() + 70; // nav_left (35) + nav_right (35)
    var menuMargin = (780 - menuWidth) / 2;
    $("#navigation").css("margin-left", menuMargin);*/
}

function initPoll() {
    $("#poll a.btnBekijkResult, #voteButton").live("click", function(e) {
    voteResult()
    e.preventDefault();
    });
}
    
function voteResult() {
        $("#poll div.poll_question").slideUp(500);
        $("#poll div.poll_result").delay(500).slideDown(500);

    }

