﻿ /* click with enter 
==================================================*/
function doClick(buttonName, e) { var key; if (window.event) { key = window.event.keyCode; } else { key = e.which; } if (key == 13) { var btn = document.getElementById(buttonName); if (btn != null) { newBtnName = buttonName.replace(/_/g, "$"); if (DES_BtnClick(buttonName)) { __doPostBack(newBtnName, e) } event.keyCode = 0 } } } function doButtonClick(buttonName, e) { var key; if (window.event) { key = window.event.keyCode; } else { key = e.which; } if (key == 13) { var btn = document.getElementById(buttonName); if (btn != null) { event.keyCode = 0 } } }

/* animate progressbar */
function fillProgressbar(divID, height) {
    $("#"+divID).animate({"top": height+"px"}, 3000);
}
/* trigger progressbar after donation */
function triggerProgressbar(divID, height) {
    $("#" + divID).animate({ "top": height + "px" }, { duration: 2000, easing: "easeOutBounce" });
}
/* animate box */
function fillBox(divID, height) {
   	$("#" + divID).animate({"top": height + "px"},  6000);
}

/* Nifty Corners Cube - rounded corners with CSS and Javascript
==================================================*/
var niftyOk = (document.getElementById && document.createElement && Array.prototype.push); var niftyCss = false; String.prototype.find = function(a) { return (this.indexOf(a) >= 0 ? true : false) }; var oldonload = window.onload; if (typeof (NiftyLoad) != "function") { NiftyLoad = function() { } } if (typeof (oldonload) == "function") { window.onload = function() { oldonload(); AddCss(); NiftyLoad() } } else { window.onload = function() { AddCss(); NiftyLoad() } } function AddCss() { } function Nifty(a, c) { if (niftyOk == false) { return } if (niftyCss == false) { AddCss() } var d, b = a.split(","), e = 0; if (c == null) { c = "" } if (c.find("fixed-height")) { e = getElementsBySelector(b[0])[0].offsetHeight } for (d = 0; d < b.length; d++) { Rounded(b[d], c) } if (c.find("height")) { SameHeight(a, e) } } function Rounded(a, d) { var e, f = "", c = "", b = new Array(); if (d != "") { d = d.replace("left", "tl bl"); d = d.replace("right", "tr br"); d = d.replace("top", "tr tl"); d = d.replace("bottom", "br bl"); d = d.replace("transparent", "alias"); if (d.find("tl")) { f = "both"; if (!d.find("tr")) { f = "left" } } else { if (d.find("tr")) { f = "right" } } if (d.find("bl")) { c = "both"; if (!d.find("br")) { c = "left" } } else { if (d.find("br")) { c = "right" } } } if (f == "" && c == "" && !d.find("none")) { f = "both"; c = "both" } b = getElementsBySelector(a); for (e = 0; e < b.length; e++) { FixIE(b[e]); if (f != "") { AddTop(b[e], f, d) } if (c != "") { AddBottom(b[e], c, d) } } } function AddTop(c, l, m) { var k = CreateEl("b"), e = 4, h = "", a, j, b = "r", f, g; k.style.marginLeft = "-" + getPadding(c, "Left") + "px"; k.style.marginRight = "-" + getPadding(c, "Right") + "px"; if (m.find("alias") || (g = getBk(c)) == "transparent") { g = "transparent"; f = "transparent"; h = getParentBk(c); b = "t" } else { f = getParentBk(c); h = Mix(g, f) } k.style.background = f; k.className = "niftycorners"; a = getPadding(c, "Top"); if (m.find("small")) { k.style.marginBottom = (a - 2) + "px"; b += "s"; e = 2 } else { if (m.find("big")) { k.style.marginBottom = (a - 10) + "px"; b += "b"; e = 8 } else { k.style.marginBottom = (a - 5) + "px" } } for (j = 1; j <= e; j++) { k.appendChild(CreateStrip(j, l, g, h, b)) } c.style.paddingTop = "0"; c.insertBefore(k, c.firstChild) } function AddBottom(c, l, m) { var k = CreateEl("b"), e = 4, h = "", a, j, b = "r", f, g; k.style.marginLeft = "-" + getPadding(c, "Left") + "px"; k.style.marginRight = "-" + getPadding(c, "Right") + "px"; if (m.find("alias") || (g = getBk(c)) == "transparent") { g = "transparent"; f = "transparent"; h = getParentBk(c); b = "t" } else { f = getParentBk(c); h = Mix(g, f) } k.style.background = f; k.className = "niftycorners"; a = getPadding(c, "Bottom"); if (m.find("small")) { k.style.marginTop = (a - 2) + "px"; b += "s"; e = 2 } else { if (m.find("big")) { k.style.marginTop = (a - 10) + "px"; b += "b"; e = 8 } else { k.style.marginTop = (a - 5) + "px" } } for (j = e; j > 0; j--) { k.appendChild(CreateStrip(j, l, g, h, b)) } c.style.paddingBottom = 0; c.appendChild(k) } function CreateStrip(d, e, b, c, f) { var a = CreateEl("b"); a.className = f + d; a.style.backgroundColor = b; a.style.borderColor = c; if (e == "left") { a.style.borderRightWidth = "0"; a.style.marginRight = "0" } else { if (e == "right") { a.style.borderLeftWidth = "0"; a.style.marginLeft = "0" } } return (a) } function CreateEl(a) { return (document.createElement(a)) } function FixIE(a) { if (a.currentStyle != null && a.currentStyle.hasLayout != null && a.currentStyle.hasLayout == false) { a.style.display = "inline-block" } } function SameHeight(a, d) { var g, b = a.split(","), f, c, e = [], h; for (g = 0; g < b.length; g++) { f = getElementsBySelector(b[g]); e = e.concat(f) } for (g = 0; g < e.length; g++) { if (e[g].offsetHeight > d) { d = e[g].offsetHeight } e[g].style.height = "auto" } for (g = 0; g < e.length; g++) { h = d - e[g].offsetHeight; if (h > 0) { f = CreateEl("b"); f.className = "niftyfill"; f.style.height = h + "px"; nc = e[g].lastChild; if (nc.className == "niftycorners") { e[g].insertBefore(f, nc) } else { e[g].appendChild(f) } } } } function getElementsBySelector(d) { var h, g, b = "", n = "", x = d, t = "", r, e, m, q, w = [], p = [], o; if (d.find("#")) { if (d.find(" ")) { w = d.split(" "); var l = w[0].split("#"); if (l.length == 1) { return (p) } m = document.getElementById(l[1]); if (m) { u = m.getElementsByTagName(w[1]); for (h = 0; h < u.length; h++) { p.push(u[h]) } } return (p) } else { w = d.split("#"); x = w[0]; b = w[1]; if (b != "") { m = document.getElementById(b); if (m) { p.push(m) } return (p) } } } if (d.find(".")) { w = d.split("."); x = w[0]; n = w[1]; if (n.find(" ")) { w = n.split(" "); n = w[0]; t = w[1] } } var u = document.getElementsByTagName(x); if (n == "") { for (h = 0; h < u.length; h++) { p.push(u[h]) } return (p) } for (h = 0; h < u.length; h++) { o = u[h].className.split(" "); for (g = 0; g < o.length; g++) { if (o[g] == n) { if (t == "") { p.push(u[h]) } else { r = u[h].getElementsByTagName(t); for (e = 0; e < r.length; e++) { p.push(r[e]) } } } } } return (p) } function getParentBk(a) { var b = a.parentNode, d; while (b.tagName.toUpperCase() != "HTML" && (d = getBk(b)) == "transparent") { b = b.parentNode } if (d == "transparent") { d = "#FFFFFF" } return (d) } function getBk(a) { var b = getStyleProp(a, "backgroundColor"); if (b == null || b == "transparent" || b.find("rgba(0, 0, 0, 0)")) { return ("transparent") } if (b.find("rgb")) { b = rgb2hex(b) } return (b) } function getPadding(a, b) { var c = getStyleProp(a, "padding" + b); if (c == null || !c.find("px")) { return (0) } return (parseInt(c)) } function getStyleProp(a, b) { if (a.currentStyle) { return (a.currentStyle[b]) } if (document.defaultView.getComputedStyle) { return (document.defaultView.getComputedStyle(a, "")[b]) } return (null) } function rgb2hex(f) { var d = "", a, c, b; var e = /([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/; var c = e.exec(f); for (b = 1; b < 4; b++) { a = parseInt(c[b]).toString(16); if (a.length == 1) { d += "0" + a } else { d += a } } return ("#" + d) } function Mix(f, e) { var d, c, b, a, h, g = new Array(3); if (f.length == 4) { c = 1 } else { c = 2 } if (e.length == 4) { b = 1 } else { b = 2 } for (d = 0; d < 3; d++) { a = parseInt(f.substr(1 + c * d, c), 16); if (c == 1) { a = 16 * a + a } h = parseInt(e.substr(1 + b * d, b), 16); if (b == 1) { h = 16 * h + h } g[d] = Math.floor((a * 50 + h * 50) / 100); g[d] = g[d].toString(16); if (g[d].length == 1) { g[d] = "0" + g[d] } } return ("#" + g[0] + g[1] + g[2]) };

/* Nifty all divs specified here
==================================================*/
function NiftyAll() {

	Nifty("DIV.nifty");
	Nifty("DIV.begin", "tl tr");
	Nifty("DIV.end", "bl br");
	Nifty("DIV#main");
	Nifty("DIV.leftcontent");
	Nifty("DIV.success");
	Nifty("DIV.error");
}


/* CARROUSEL 
=============================================*/

var globalTimeout = 5000; // change slide after x milliseconds
var carrouselOnPause = false; // boolean to check if carrousel is on pause or not

function carrousel() {
    // get all elements
	var slides = $('#home_slides').children();

	// activate carrousel
	if (slides.length > 1) {

		// carrousel on pause when mouse is on it
		$('.home_slidecontainer').hover(function() {
			// mouseon
			carrouselPause(slides);
		}, function() {
			// mouseout
			carrouselPause(slides);
		});

		//start timeout 
		carrouselTimeout = setTimeout(function() { carrouselNext(slides, 0); }, globalTimeout);
	}
}

function carrouselHover(slides, current, last, speed) {

	if (speed != "fast" && speed != "slow") {
		alert("Please, set proper speed in carrousel");
	}

	// mark last active slide
	$(slides[last]).addClass('last-active');

    // fade in new active slide	
    $(slides[current]).css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, speed, function() {
            $(slides[last]).removeClass('active last-active');
        });
}

function carrouselNext(slides, current) {

	if ((current + 1) < slides.length) {
		current = current + 1;
		last = current - 1;
	} else {
		current = 0;
		last = slides.length - 1;
	}

	carrouselHover(slides, current, last, 'slow');

	carrouselTimeout = setTimeout((function() {
		carrouselNext(slides, current);
	}), globalTimeout);

}

function carrouselPause(slides) {
	if (carrouselOnPause == false) {
		clearTimeout(carrouselTimeout);
		carrouselOnPause = true;
	}
	else {
		// set current
		var current = 0;
		for (var i = 0; i < slides.length; i++) {
		    if ($(slides[i]).hasClass('active')) {
		        current = i;
		    }
		}
		carrouselTimeout = setTimeout((function() {
			carrouselNext(slides, current);
		}), globalTimeout);
		carrouselOnPause = false;
	}
}

/* WIDGETS 
=============================================*/
function GetMySpaceURL(T, C, U, L) {
    var targetUrl = 'http://www.myspace.com/Modules/PostTo/Pages/?' + 't=' + encodeURIComponent(T) + '&c=' + encodeURIComponent(C) + '&u=' + encodeURIComponent(U) + '&l=' + L;
    window.open(targetUrl);
}

/* YOUTUBE 
=============================================*/
function FormatYoutube(field) {
    document.getElementById(field).value = document.getElementById(field).value.replace("watch?v=", "v/");
}