function $sa(id) {
	return document.getElementById(id);
}

function sa_getbyid(id) {
	itm = null;
	if (document.getElementById) {
		itm = document.getElementById(id);
	} else if (document.all)	{
		itm = document.all[id];
	} else if (document.layers) {
		itm = document.layers[id];
	}
	return itm;
}

function showhide(obj) {
	$sa(obj).style.display = $sa(obj).style.display == 'none' ? 'block' : 'none';
}
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]); } });

/* cookies */
function WriteCookie(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 ClearCookie(name) {
    createCookie(name, "", -1);
}

/* 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("#Beijing-pricing span").css("opacity", "0");
    jQuery("#Beijing-pricing span").hover(function() {
        jQuery(this).stop().animate({
            opacity: 1
        }, 'slow');
    },
	function() {
	    jQuery(this).stop().animate({
	        opacity: 0
	    }, 'slow');
	});
});

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

jQuery(function() {
    jQuery(".btn-tiny-vps span").css("opacity", "0");
    jQuery(".btn-tiny-vps 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
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();
        WriteCookie('activaDeclined', '1', 1);
        return false;
    });

    jQuery('#chat-automated-accept').click(function() {
        _alc.startChat();
        return false;
    });

    jQuery('#chat-automated-reject').click(function() {
        activaDeclinedChat = true;
        _alc.clearAutoInvite();
        WriteCookie('activaDeclined', '1', 1);
        return false;
    });

    activaDeclinedChat = (ReadCookie('activaDeclined') == '1') ? true : false;
});