$(document).ready(function(){
    
    $("#contactLink").click(function(){
        if ($("#contactForm").is(":hidden")){
            $("#contactForm").slideDown("slow");
        }
        else{
            $("#contactForm").slideUp("slow");
        }
    });
    
    $("#close_form").click(function(){
        $("#contactForm").slideUp("slow");
    });

    $("#contactForm").validate
    ({ 
        rules: 
        { 
            contact_fname: {required:true},
            contact_email: {required: true, email: true},
            contact_message: {required:true}
        },
        
        submitHandler: function(form) {
            sendContactParams();
        }
    });

   
});

function sendContactParams(){
        var fname = htmlToEncode($("#contact_fname").val());
        var email = $("#contact_email").val();
        var msg = htmlToEncode($("#contact_message").val());
        //alert("contactAdd.asp?fname="+fname+"&email="+email+"&msg="+msg);
        $("#req").load("http://www.big-blue.co.il/contactAdd.asp?fname="+fname+"&email="+email+"&msg="+msg, closeForm());

}

function closeForm(){
    $("#messagesent").show("slow");
    setTimeout('$("#messagesent").hide();$("#contactForm").slideUp("slow")', 4000);
}

function addBookmark(title,url){
    if (window.sidebar) { 
    window.sidebar.addPanel(title, url,""); 
    } else if( document.all ) {
    window.external.AddFavorite( url, title);
    } else if( window.opera && window.print ) {
    return true;
    }
}


function htmlToEncode(strVal) {
	encodedHtml = escape(strVal);
	encodedHtml = encodedHtml.replace(/\//g,"%2F");
	encodedHtml = encodedHtml.replace(/\?/g,"%3F");
	encodedHtml = encodedHtml.replace(/=/g,"%3D");
	encodedHtml = encodedHtml.replace(/&/g,"%26");
	encodedHtml = encodedHtml.replace(/@/g,"%40");
	//encodeHtml.htmlEncoded.value = encodedHtml;
	return encodedHtml;
}
