/* 
 * Author : Apoorv Parijat
 */

// Executes script on page load.
var windowHeight = 0;
var highlighted = 0;
var closed = false;
function executeScript(){
    jQuery("document").ready(function(){ 
            windowHeight = jQuery(window).height();
            setTimeout(show,12000);
            jQuery(".close").click(hide);
            jQuery(window).scroll(scrolled);
	    
    });
}

function show()
{
    if(jQuery(".notify-container").css("display") == "none"){
        jQuery(".notify-container").show("bounce", 400);
    }
}

function hide()
{
    jQuery(".notify-container").hide("slide",{direction : "down"},300);
    jQuery(window).unbind("scroll");
}

function scrolled()
{
    scrollHeight = jQuery(window).scrollTop();
    //jQuery(".close").html("Scrolled : " + scrollHeight + "/" + windowHeight + ". Ratio : " + (scrollHeight/windowHeight));
    if(scrollHeight/windowHeight >= 0.6){
        if(jQuery(".notify-container").css("display") != "none"){
            if(highlighted < 1){
                highlightElement();
                highlighted++;
            }
        }else
        {
            show();
        }
    }else
    {
        highlighted = 0;
    }
}

function highlightElement()
{
    jQuery(".register-link").effect("highlight",{color : "red"},2000);
}
executeScript();

