$(document).ready(function(){	
	var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent));
	var badBrowserBrother = (/MSIE (7)/.test(navigator.userAgent));
	
	if(badBrowser){
		$("#servers").css({"margin-top" : "3px"});
	}
	
	$("ul.top-nav li").hoverIntent(function() { 
			//Following events are applied to the sub-nav itself (moving sub-nav up and down)
			$(this).find("ul.sub-nav").slideDown(100); //Drop down the sub-nav on hover
			if(badBrowser || badBrowserBrother){
				$("#content").css({'zIndex' : '-9999'});
			}
		},
		function (){
			$(this).find("ul.sub-nav").slideUp(100); 
			if(badBrowser || badBrowserBrother){
				$("#content").css({'zIndex' : '1'});
			}
		}
	);
	
	//form handling specifics for the Partner forms
	// bind form using ajaxForm 
    $('#partnersContactForm').ajaxForm({ 
        // target identifies the element(s) to update with the server response 
        target: '#formResponse', 
 
        // success identifies the function to invoke when the server response 
        // has been received; here we apply a fade-in effect to the new content 
        success: function() { 
    		$('#partnersContactForm').hide();
            $('#formResponse').fadeIn('slow'); 
        } 
    }); 
    
    //form handling specifics for the survey forms
	// bind form using ajaxForm 
    $('#cloudComputingSurveyForm').ajaxForm({ 
        // target identifies the element(s) to update with the server response 
        target: '#formResponse', 
 
        // success identifies the function to invoke when the server response 
        // has been received; here we apply a fade-in effect to the new content 
        success: function() { 
    		$('#cloudComputingSurveyForm').hide();
            $('#formResponse').fadeIn('slow'); 
        } 
    }); 
    
    //form handling specifics for the events forms
	// bind form using ajaxForm 
    $('#eventsRegisterForm').ajaxForm({ 
        // target identifies the element(s) to update with the server response 
        target: '#formResponse', 
 
        // success identifies the function to invoke when the server response 
        // has been received; here we apply a fade-in effect to the new content 
        success: function() { 
    		$('#eventsRegisterForm').hide();
            $('#formResponse').fadeIn('slow'); 
        } 
    }); 
    
    $(".screencast:odd").css({"margin-left" : "20px"});
	
    $(".play-button").hide();
    
    $("#featuredScreencast").hover(function(){
    	$(this).find("img.play-button").show();
    },
    function(){
    	$(this).find("img.play-button").hide();
    });
    
    $(".screencast").hover(function(){
    	$(this).find("img.play-button").css({"margin-top" : "-50px", "margin-left" : "-25px", "width" : "50px"}).show();
    },
    function(){
    	$(this).find("img.play-button").hide();
    });
    
    $("#featuredScreencast a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_square'});
    $(".screencast a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_square'});

    $("select[name='screencast-filter']").change(function (){
	    if($("select[name='screencast-filter'] :selected").length > 0){
	    	var filterOption = $("select[name='screencast-filter'] :selected").attr("value");
	    	$(".screencast-meta").each( function(){
	    		var searchIn = $(this).text();
	    		if(filterOption == "View All"){
	    			$(this).parent().show();
	    			return;
	    		}
	    		if(searchIn.search(filterOption) != -1){
	    			$(this).parent().show();
	    		}
	    		else{
	    			$(this).parent().hide();
	    		}

	    	});
	    	$(".screencast:visible:odd").css({"margin-left" : "20px"});
	    	$(".screencast:visible:even").css({"margin-left" : "0px"});
	    }
    });
    
    //front page tabs
    $(function() {
    	$("#tab-news-ticker").tabs({ajaxOptions: { async: false } });
    
    });
   
    
    
});

//email writing functions

function salesEmail(){
	var name = "sales";
	var at = "@";
	var url = "reliacloud.com";
	var displayText = name + at + url;
	
	document.write("<a href=" + "mail" + "to:" + name + at + url + ">" + displayText + "</a>");
}

function marketplaceEmail(){
	var name = "marketplace";
	var at = "@";
	var url = "reliacloud.com";
	var displayText = "Let us know";
	var subject = "I'm interested in being a marketplace partner";
	
	document.write("<a href=\"" + "mail" + "to:" + name + at + url + "?subject=" + subject + "\">" + displayText + "</a>");
}





