﻿jQuery.noConflict();

/* dom helpers */
var olfx = [];
function AddOnLoadFx(a) { olfx[olfx.length] = a; }
Event.observe(window, 'load', function() { for (var i = 0; i < olfx.length; i++) { eval(olfx[i]); }});
var oufx = [];
function AddOnUnloadFx(a) { oufx[oufx.length] = a; }
Event.observe(window, 'unload', function() { for (var i = 0; i < oufx.length; i++) { eval(oufx[i]); }});
var orfx = [];
function AddOnResizeFx(a) { orfx[orfx.length] = a; }
Event.observe(window, 'resize', function() { for (var i = 0; i < orfx.length; i++) { eval(orfx[i]); } });

/* login */
var loginState = 0;
function toggleLogin() {
    if (loginState == 0) {
        new Effect.Parallel([
        new Effect.Move('toppanel', { sync: true, x: 0, y: 57, mode: 'relative' }),
        new Effect.Move('bigcontainer', { sync: true, x: 0, y: 57, mode: 'relative' }),
        new Effect.Move('logintab', { sync: true, x: 0, y: 57, mode: 'relative' })],
        { transition: Effect.Transitions.sinoidal, duration: 0.5 });
        $('open').className = 'close';
        loginState = 1;
    }
    else {
        new Effect.Parallel([
        new Effect.Move('toppanel', { sync: true, x: 0, y: -57, mode: 'relative' }),
        new Effect.Move('bigcontainer', { sync: true, x: 0, y: -57, mode: 'relative' }),
        new Effect.Move('logintab', { sync: true, x: 0, y: -57, mode: 'relative' })],
        { transition: Effect.Transitions.sinoidal, duration: 0.5 });
        $('open').className = 'open';
        loginState = 0;
    }
}

/* animation resources */
//TODO: Clean this mess up...
jQuery(function() {
    jQuery("ul#nav-main span").css("opacity", "0");
    jQuery("ul#nav-main span").hover(function() {
        jQuery(this).stop().animate({
            opacity: 1
        }, 'slow');
    },
	function() {
	    jQuery(this).stop().animate({
	        opacity: 0
	    }, 'slow');
	});
});

jQuery(function() {
    jQuery("dl#solutions span").css("opacity", "0");
    jQuery("dl#solutions span").hover(function() {
        jQuery(this).stop().animate({
            opacity: 1
        }, 'slow');
    },
	function() {
	    jQuery(this).stop().animate({
	        opacity: 0
	    }, 'slow');
	});
});

jQuery(function() {
    jQuery(".add-on-button span").css("opacity", "0");
    jQuery(".add-on-button span").hover(function() {
        jQuery(this).stop().animate({
            opacity: 1
        }, 'slow');
    },
	function() {
	    jQuery(this).stop().animate({
	        opacity: 0
	    }, 'slow');
	});
});

jQuery(function() {
    jQuery(".private-server-pricing span").css("opacity", "0");
    jQuery(".private-server-pricing span").hover(function() {
        jQuery(this).stop().animate({
            opacity: 1
        }, 'slow');
    },
	function() {
	    jQuery(this).stop().animate({
	        opacity: 0
	    }, 'slow');
	});
});

jQuery(function() {
    jQuery("#pricing span").css("opacity", "0");
    jQuery("#pricing span").hover(function() {
        jQuery(this).stop().animate({
            opacity: 1
        }, 'slow');
    },
	function() {
	    jQuery(this).stop().animate({
	        opacity: 0
	    }, 'slow');
	});
});

jQuery(function() {
    jQuery("#cta-security span").css("opacity", "0");
    jQuery("#cta-security span").hover(function() {
        jQuery(this).stop().animate({
            opacity: 1
        }, 'slow');
    },
	function() {
	    jQuery(this).stop().animate({
	        opacity: 0
	    }, 'slow');
	});
});

jQuery(function() {
    jQuery(".btn_learnmore span").css("opacity", "0");
    jQuery(".btn_learnmore span").hover(function() {
        jQuery(this).stop().animate({
            opacity: 1
        }, 'slow');
    },
	function() {
	    jQuery(this).stop().animate({
	        opacity: 0
	    }, 'slow');
	});
});

jQuery(function() {
    jQuery("#dedicated-pricing span").css("opacity", "0");
    jQuery("#dedicated-pricing span").hover(function() {
        jQuery(this).stop().animate({
            opacity: 1
        }, 'slow');
    },
	function() {
	    jQuery(this).stop().animate({
	        opacity: 0
	    }, 'slow');
	});
});

jQuery(function() {
    jQuery("#tas a#sap span").css("opacity", "0");
    jQuery("#tas a#sap span").hover(function() {
        jQuery(this).stop().animate({
            opacity: 1
        }, 'slow');
    },
	function() {
	    jQuery(this).stop().animate({
	        opacity: 0
	    }, 'slow');
	});
});

jQuery(function() {
    jQuery("#tas a#ays span").css("opacity", "0");
    jQuery("#tas a#ays span").hover(function() {
        jQuery(this).stop().animate({
            opacity: 1
        }, 'slow');
    },
	function() {
	    jQuery(this).stop().animate({
	        opacity: 0
	    }, 'slow');
	});
});

jQuery(function() {
    jQuery("#tas a#shp span").css("opacity", "0");
    jQuery("#tas a#shp span").hover(function() {
        jQuery(this).stop().animate({
            opacity: 1
        }, 'slow');
    },
	function() {
	    jQuery(this).stop().animate({
	        opacity: 0
	    }, 'slow');
	});
});



/* Add this widget for Share */

addthis_pub = 'firehost';
addthis_url = '[URL]';
addthis_title = '[TITLE]';


if(addthis_url===""||addthis_url==="[URL]"){
addthis_url=location.href;
}
if(addthis_title===""||addthis_title==="[TITLE]"){
addthis_title=document.title;
}


function openShare() {
    new Effect.Appear('share-box', { duration: 0 });
}

function closeShare() {
    new Effect.Fade('share-box', { duration: 0 });
}

/* Modal */
function showModalOverlay() {
    new Effect.Appear("modalOverlay", { from: 0, to: 0.85, duration: 0.3 });
}
function hideModalOverlay() {
    new Effect.Fade("modalOverlay", { from: 0.85, to: 0, duration: 0.3 });
}
function showModal(id) {
    showModalOverlay();
    cloneModalContent(id);
    $('contentOverlay').style.display = 'block';
    new Effect.Appear(id, { from: 0, to: 1, duration: 0.2 });
}
function closeModal(id) {
    hideModalOverlay();
    returnModalContent(id);
    $('contentOverlay').style.display = 'none';
    new Effect.Appear(id, { from: 1, to: 0, duration: 0.2 });
}
function cloneModalContent(id) {
    $("contentOverlay").appendChild($(id).cloneNode(true));
    for (var i = 0; i < $("modalContent").childNodes.length; i++) {
        if ($("modalContent").childNodes[i].id == id) {
            $("modalContent").removeChild($("modalContent").childNodes[i]);
        }
    }
}
function returnModalContent(id) {
    $("modalContent").appendChild($(id).cloneNode(true));
    $("contentOverlay").innerHTML = "";
}

// ACTIVA LIVE CHAT
// ACTIVA LIVE CHAT
var activaDeclinedChat = false;

jQuery(document).ready(function(){
	jQuery('#chat-proactive-accept').click(function(){
		_alc.startChat();
		return false;
	});
	
	jQuery('#chat-proactive-reject').click(function(){
		activaDeclinedChat = true;
		_alc.rejectInvite();
		return false;
	});
	
	jQuery('#chat-automated-accept').click(function(){
		_alc.startChat();
		return false;
	});
	
	jQuery('#chat-automated-reject').click(function(){
		activaDeclinedChat = true;
		_alc.clearAutoInvite();
		return false;
	});
});