var forOrder = 0;
jQuery(document).ready(function(){
	/*
	 * there's added part for the controls of the feedback inside the popup
	 * 
	*/
        jQuery('body').append('<div class="highslide-html-content" id="registration" style="width: 600px; display: none; background-color: #fff;"><div class="highslide-header"><ul style="list-style: none; padding: 0; margin: 0; text-align: right"><li class="highslide-close"><span title="close" onclick="closePopup(this);" id="closeRegistration"><img src="/img/layout/button_x.jpg" border="0" /></span></li></ul></div>'+
            '<div class="highslide-body" style="background-color: fff; margin: 0 20px 20px;overflow:hidden;">'+
                '<div id="contentRegistration" style="margin-left:50px;">'+
                    '<div id="loginForm" class="popup_checkboxes">'+
                        '<div style="width: 510px; color: brown; font-size: 16px; font-weight:bold;"><br /><br />'+
                        '<div id="title_text" ></div></div>'+
                        '<!--<div class="required_dot">Required fields.</div>-->' +
/*start feedback*/    '<div class="form_main" id="feedback_fields_container" style="width: 510px;height:10px;">'+
	                        '<form id="feedback_form" action="" method="post" id="feedback">'+
		                        '<div class="form_container" id="feedback_fields" style="width:208px;display:none;padding: 0px 0px 0px;">'+
		                        '</div>'+
	                        '</form>'+
/*end feedback*/      '</div>'+
                        '<div style="float:left;">'+
                            '<div id="checkboxes" style="width:242px;margin-top:35px;">'+

                            '</div>'+
                        '</div>'+
                        '<div class="form_main" style="width:208px;height:250px;margin-top:25px;">'+
                            '<form id="special_form" action="/Login/?cmd=logInProcess&src=Order-cmd.order" method="post" id="register">'+
                            '<div class="form_container" id="fastname" style="width:208px;display:none;padding: 0px 0px 0px;">'+
                                '<div class="form_right_2" style="border: none">'+
                                    '<input name="name" type="text" class="form_text_field" id="name" style="width:195px;" value="first name" onclick = "if (this.value) this.value=\'\';" onblur="if (!this.value) this.value =\'first name\';"/>'+
                                    '<div class="error" id="nameError"></div>'+
                                '</div>'+
                            '</div>'+
                            '<div class="form_container" id="email_cont" style="width:208px;padding: 0px 0px 0px;">'+
                                '<div class="form_right_2" style="border-top:0px;">'+
                                    '<input name="email" type="text" class="form_text_field" id="fastemail" style="width:195px;" value="e-mail" onclick = "if (this.value) this.value=\'\';" onblur = "if (!this.value) this.value =\'e-mail\';"/>'+
                                    '<div class="error" id="emailError"></div>'+
                                '</div>'+
                            '</div>'+
                            '<div class="form_container" id="pass_cont" style="width:208px;padding: 0px 0px 0px;">'+
                                '<div class="form_right_2" style="border-top:0px;">'+
                                    '<input name="pass" type="text" class="form_text_field" id="pass" style="width:195px;" value="password" onclick = "passOnClick(this)"  onblur = "if (!this.value) {this.type=\'text\';this.value =\'password\';}"/>'+
                                    '<div class="error" id="passError"></div>'+
                                    '<div class="error" id="logInFormError"></div>'+
                                '</div>'+
                            '</div>'+
                            '<div class="form_container" id="register_fields" style="width:208px;display:none;padding: 0px 0px 0px;">'+
                                '<div class="form_right_2" style="border-top:0px;">'+
                                    '<input name="confirm" type="text" class="form_text_field" id="confirm" style="width:195px;" value="confirm password" onclick = "passOnClick(this)"  onblur = "if (!this.value) {this.type=\'text\';this.value =\'confirm password\';}"/>'+
                                    '<div class="error" id="confirmError"></div>'+
                                '</div>'+
                            '</div>'+
                            '<br style="clear: left;" />'+
                            '<div class="form_container" style="width:208px;padding: 0px 0px 0px;">'+
                                '<div class="form_right_2" style="border-top:0px;width:208px;padding:0px;">'+
                                    '<div style="float:left;clear: none;"><input id="fastsubmit" type="submit" value="Sign in" id="submit" class="button2" name="submit"/></div>'+
                                    '<div id="passRecovery" style="float: right;padding-right: 5px;"><a title="Password recovery" href="" style="text-decoration: underline;">Password recovery</a></div>'+

                                '</div>'+
                            '</div>'+
                            '</form>'+
                        '</div>'+
               '</div>'+
               '<div id="registrationComplete" style="display: none"></div>'+
           '</div>'+
       '</div>'
   +'</div>');
    jQuery('.my_account a').unbind();
    jQuery('.my_account a').bind('click', function(event){
    event.preventDefault();
                jQuery.ajax({
                    type: "POST",
                    url: "/Ajax/",
                    data: "checkLogin=1",
                    success: function(html) {
                        if(html == "1") {
                            location.href = '/Account';
                        }
                        else {
                            fastRegistration();
                        }
                    }
                });
    });

    jQuery('#__new_member').bind('click', function(event){
        event.preventDefault();
        fastRegistration(1);
    });

    jQuery('#_welcome_guest').bind('click', function(event){
        event.preventDefault();
        fastRegistration();
    });
    jQuery('#_pass_recov').bind('click', function(event){
        event.preventDefault();
        fastRegistration(0, 1);
    });
    /*
     * adding the new part of code that will show the pop up with the feedback controls
    */
    jQuery('#__feedback').bind('click', function(event){
        event.preventDefault();
        fastRegistration(0, 0, 1);
    });
});


function closePopup(ob){
    hs.close(ob);
    jQuery('#checkOut').text('Check Out >>');
}

function passOnClick(ob){
    if (ob.value) {
        ob.value = '';
        ob.type = 'password';
        ob.focus();
    }
}
/*
 * there's added new parameter "feedback" so only the feedback controls will be shown
 * 
*/
function fastRegistration(login, recovery, feedback) {

    jQuery(function()
    {
        //jQuery('body').append('<div class="highslide-html-content" id="registration" style="width: 600px; display: none; background-color: #fff"><div class="highslide-header"><ul style="list-style: none; padding: 0; margin: 0; text-align: right"><li class="highslide-close"><a title="close" href="" onclick="return hs.close(this)" id="closeRegistration"><img src="/img/layout/button_x.jpg" border="0" /></a></li></ul></div><div class="highslide-body" style="background-color: fff; margin: 0 20px 20px;"><div id="contentRegistration"><div id="registrationForm"><div class="deal_header_big" style="width: 510px">New Member</div><!--<div class="required_dot">Required fields.</div>--><div class="form_main"><form action="?cmd=registerProcess" method="post" id="register"><div class="form_container"><div class="form_left_required" style="border: none">First Name :</div><div class="form_right_2" style="border: none"><input name="name" type="text" class="form_text_field" id="name" size="25" value=""/><div class="error" id="nameError"></div></div></div><div class="form_container"><div class="form_left_required">E-mail :</div><div class="form_right_2"><input name="email" type="text" class="form_text_field" id="email" size="25" value=""/><div class="error" id="emailError"></div></div></div><div class="form_container"><div class="form_left_required">Password :</div><div class="form_right_2"><input name="pass" type="password" class="form_text_field" id="pass" size="25"/><div class="error" id="passError"></div></div></div><div class="form_container"><div class="form_left_required">Confirm password :</div><div class="form_right_2"><input name="confirm" type="password" class="form_text_field" id="confirm" size="25"/><div class="error" id="confirmError"></div></div></div><div class="form_container"><div class="form_left"></div><div class="form_right_2"><input type="submit" value="Submit" id="submit" class="button2" name="submit" style="margin-bottom: 10px" /><img src="/img/loadMedium.gif" title="loading..." class="loader" style="width: 12px; height: 12px; padding-left: 5px; display: none" /></div></div></form></div></div><div id="registrationComplete" style="display: none"></div></div></div></div>');

    	//if(!feedback){
    		jQuery("#title_text").html('Have you used myDelivery before?');
    		jQuery("#feedback_fields").html('');
	        if(!recovery){
	
	        if(login){
	            jQuery("#checkboxes").html(
	                                '<input id="reg" name="reg" type="radio" checked="true"/>'+
	                                '<label id="registerLabel" for="reg" class="font_BOLD">No I\'m a first timer <span class="free">Free!</span></label>'+
	                                '<p style="padding: 0px 18px 0px;margin-top:5px;">That\'s ok, just fill out the form and a new account will be created for you.</p>'+
	                               '<input id="fastlogin" name="login" type="radio"/>'+
	                                '<label id="loginLabel" for="login" class="font_BOLD">Yes I have</label>'+
	                                '<p style="padding: 0px 18px 0px;margin-top:5px;">Enter your e-mail and password.</p>'
	            );
	        } else {
	            jQuery("#checkboxes").html(
	                               '<input id="fastlogin" name="login" type="radio" checked="true"/>'+
	                                '<label id="loginLabel" for="login" class="font_BOLD">Yes I have</label>'+
	                                '<p style="padding: 0px 18px 0px;margin-top:5px;">Enter your e-mail and password.</p>'+
	                                '<input id="reg" name="reg" type="radio"/>'+
	                                '<label id="registerLabel" for="reg" class="font_BOLD">No I\'m a first timer <span class="free">Free!</span></label>'+
	                                '<p style="padding: 0px 18px 0px;margin-top:5px;">That\'s ok, just fill out the form and a new account will be created for you.</p>');
	        }
	
	        } else {
	            jQuery("#checkboxes").html(
	                               '<input id="fastlogin" name="login" type="radio"/>'+
	                                '<label id="loginLabel" for="login" class="font_BOLD">Yes I have</label>'+
	                                '<p style="padding: 0px 18px 0px;margin-top:5px;">Enter your e-mail and password.</p>'+
	                                '<input id="reg" name="reg" type="radio"/>'+
	                                '<label id="registerLabel" for="reg" class="font_BOLD">No I\'m a first timer <span class="free">Free!</span></label>'+
	                                '<p style="padding: 0px 18px 0px;margin-top:5px;">That\'s ok, just fill out the form and a new account will be created for you.</p>');
	        }
	        if (!recovery){
	            if(!login) {
	                jQuery("input#fastlogin").attr("checked", true);
	                if(feedback || forOrder){//for feedback
	                	jQuery('form#special_form').attr("action","/Login/?cmd=logInProcess");
	                	//jQuery('#fastsubmit').attr("type","button");
	                	//jQuery("#fastsubmit").val('Signing in');
	                	//jQuery("#fastsubmit").attr("onclick","alert(document.getElementById('fastemail').value + ' $ '+document.getElementById('pass').value);");
	                }
	                loginShow();
	            }
	            else {
	                jQuery("input#reg").attr("checked", true);
	                registerShow();
	            }
	        }
	        else
	        {
	            jQuery("input#fastlogin").attr("checked", false);
	            jQuery("input#reg").attr("checked", false);
	            passRecoveryShow();
	        }
    	//}
    	/*else
    	{
    		 
    		 // here's the code that will add the text box and the submit button to the popup
    		 
    		jQuery("#checkboxes").html('');
    		jQuery("#title_text").html('Add your feedback:');
    		jQuery("#feedback_fields").html(
    				'<div class="form_right_2" style="border-top:0px;">'+
                    '<textarea name="tb_feedback" class="textarea" id="tb_feedback" cols="55" rows="5"'+
                    'onclick = "if (this.value == \'Write somthing\') this.value=\'\';"  onblur = "if (!this.value) {this.type=\'text\';this.value =\'Write somthing\';}" >Write somthing</textarea>'+
                    '<br /><input id="feedback_submit" type="submit" value="Submit" id="feedback_submit" class="button2"/>'+
                    '</div>'
    		);
	   		 
	   		  // this method will hide any existing controls inside the popup
	   		 
    		feedbackShow();
    	}*/
        
        jQuery(':input').not('select').not('#testinput_xml').not('testinput_xmlTxt').focus(function(event)
        {
            jQuery(this).addClass('highlighted');
        })
        .blur(function(event)
        {
            jQuery(this).removeClass('highlighted');
        });

        hs.htmlExpand(this, {
            contentId: 'registration',
            align: 'center',
            dimmingOpacity: 0.75
        });

        jQuery('.error').css({"text-align":"left", "padding": "0px 0px 0px" });
        var loader = jQuery('#registration .loader');

  		 /*
  		  * this method will hide any existing controls inside the popup
  		 */
        function feedbackShow() {
            jQuery("#special_form").attr("action", "");
            jQuery("#recover_result").remove();
            jQuery("#registrationOK").remove();
            jQuery("#feedback_fields").slideDown("fast")
            jQuery("#email_cont").slideUp("fast");
            jQuery("#pass_cont").slideUp("fast");
            jQuery("#fastname").slideUp("fast");
            jQuery("#register_fields").slideUp("fast");
            jQuery("#fastsubmit").hide();
            jQuery(".error").empty();
            jQuery("#special_form").unbind("submit");
            jQuery("#passRecovery").hide();
            registerBind();
        }
        
        
        
        function regSlideUp(){
            jQuery("#fastemail").slideDown("slow", function(){
                jQuery("#pass_cont").slideDown("slow", function(){
                    jQuery("#register_fields").slideUp("slow", function(){
                        jQuery("#fastsubmit").slideDown("slow");
                    });
                });
            });
        }

        function loginBind(){
        jQuery("#special_form").bind("submit", function(event){
                        event.preventDefault();
                        
                        jQuery(".error").empty();

                        if(jQuery("input#fastemail").val() == "e-mail"){
                            jQuery("#emailError").html('should not be empty');
                            jQuery("#emailError").css({"text-align" : "left",
                                                        "padding-left": "0px"});

                            loader.hide();
                            return false;
                        }

                        if(jQuery("input#pass",jQuery('#special_form')).val() == "password"){
                            jQuery("#passError").html('should not be empty');
                            jQuery("#passError").css({"text-align" : "left",
                                                        "padding-left": "0px"});

                            loader.hide();
                            return false;
                        }

                        if(jQuery("input#pass",jQuery('#special_form')).val().length < 6){
                            jQuery("#passError").html('at least 6 characters');
                            jQuery("#passError").css({"text-align" : "left",
                                                        "padding-left": "0px"});

                            loader.hide();
                            return false;
                        }
                        
                        loader.show();
                        var expander = hs.getExpander(jQuery('#registration').get(0));
                        jQuery.getJSON('/Login/?cmd=logInProcess&ajax=1', jQuery(':input', this), function(data)
                        {
                            if (data.success)
                            {
                            	//for feedback, submit feedback form
                            	if(feedback){
                            		var feedbackForm = document.getElementById('myFeedbackForm');
                        			feedbackForm.submit();
                            	}else if(forOrder){
                            		loader.hide();
                                    location.href = '/Account/?cmd=profile&t=3&od='+jQuery('#deliveryOdrId').val();
                            	}else{
                                //jQuery('.popup_checkboxes').remove();
                                //jQuery('#registrationComplete').html('<div style="text-align: center; margin-top: 100px">' + data.message + '</div><div style="width: 39px; margin: auto"><span title="OK" id="registrationOK" onclick="closePopup(this);" class="btnSmall" style="margin-top: 15px">OK</span></div>').show();
                                loader.hide();
                                location.href = '/Order/?cmd=order';
                            	}
                            }
                            else
                            {
                                jQuery('#special_form .error').html('');

                                for (error in data.message)
                                {
                                    jQuery('#' + error + 'Error').html('wrong password');
                                }

                                expander.reflow();
                            }

                            loader.hide();
                        });

                        return false;
                    });
        }
        function loginShow() {
            jQuery("#reg").attr("checked", false);
            jQuery("#fastlogin").attr("checked", true);
            jQuery("#recover_result").remove();
            jQuery("#registrationOK").remove();
            jQuery("#email_cont").slideDown("fast")
            jQuery("#fastname").slideUp("slow", regSlideUp);
            jQuery("#passRecovery").show();
            jQuery(".error").empty();
            jQuery("#fastsubmit").val('Sign in');
            jQuery(".popup_checkboxes").attr("id", "loginForm");

            jQuery("#special_form").unbind("submit");
            loginBind();
        }

        jQuery("#fastlogin").click(loginShow);
        jQuery("#loginLabel").click(loginShow);


        function registerBind() {
            jQuery("#special_form").bind("submit", function(event){
                        event.preventDefault();
                        loader.show();
                        jQuery(".error").empty();

                        if(jQuery("input#name").val() == "first name"){
                            jQuery("#nameError").html('should not be empty');
                            jQuery("#nameError").css({"text-align" : "left",
                                                        "padding-left": "0px"});

                            loader.hide();
                            return false;
                        }

                        if(jQuery("input#fastemail").val() == "e-mail"){
                            jQuery("#emailError").html('should not be empty');
                            jQuery("#emailError").css({"text-align" : "left",
                                                        "padding-left": "0px"});

                            loader.hide();
                            return false;
                        }



                        if(jQuery("input#pass",jQuery('#special_form')).val() == "password"){
                            jQuery("#passError").html('should not be empty');
                            jQuery("#passError").css({"text-align" : "left",
                                                        "padding-left": "0px"});

                            loader.hide();
                            return false;
                        }

                        if(jQuery("input#pass",jQuery('#special_form')).val().length < 6){
                            jQuery("#passError").html('at least 6 characters');
                            jQuery("#passError").css({"text-align" : "left",
                                                        "padding-left": "0px"});

                            loader.hide();
                            return false;
                        }

                        if(jQuery("input#pass",jQuery('#special_form')).val() != jQuery("input#confirm",jQuery('#special_form')).val()) {
                            jQuery("#confirmError").html('does not match password');
                            jQuery("#confirmError").css({"text-align" : "left",
                                                        "padding-left": "0px"});

                            loader.hide();
                            return false;
                        }

                        var expander = hs.getExpander(jQuery('#registration').get(0));
                        jQuery.getJSON('/Registration/?cmd=registerProcess&ajax=1', jQuery(':input', this), function(data)
                        {
                            if (data.success)
                            {
                            	var tempmail = jQuery('input#fastemail').val();
                            	var temppass = jQuery('input#pass').val();
                                jQuery('.popup_checkboxes').remove();
                                jQuery('#registrationComplete').html('<div style="text-align: center; margin-top: 100px">' + data.message + '</div><div style="width: 39px; margin: auto"><span title="OK" id="registrationOK" onclick="closePopup(this);" class="btnSmall" style="margin-top: 15px">OK</span></div>').show();
                                
                                jQuery.getJSON('/Login/?cmd=logInProcess&src=Order-cmd.order&ajax=1&email=' + tempmail + '&pass=' + temppass , function(data)
                                {
                                    if (data.success)
                                    {
                                    	//for feedback, submit feedback form
                                    	if(feedback){
                                    		var feedbackForm = document.getElementById('myFeedbackForm');
                                			feedbackForm.submit();
                                    	}else if(forOrder){
                                    		loader.hide();
                                            location.href = '/Account/?cmd=profile&t=3&od='+jQuery('#deliveryOdrId').val();
                                    	}else{
                                        //jQuery('.popup_checkboxes').remove();
                                        //jQuery('#registrationComplete').html('<div style="text-align: center; margin-top: 100px">' + data.message + '</div><div style="width: 39px; margin: auto"><span title="OK" id="registrationOK" onclick="closePopup(this);" class="btnSmall" style="margin-top: 15px">OK</span></div>').show();
                                        loader.hide();
                                        location.href = '/Order/?cmd=order';
                                    	}
                                        //jQuery('#registrationComplete').html('<div style="text-align: center; margin-top: 100px">' + data.message + '</div><div style="width: 39px; margin: auto"><span title="OK" id="registrationOK" onclick="closePopup(this);" class="btnSmall" style="margin-top: 15px">OK</span></div>').show();
                                        //location.href = '/Order/?cmd=order';
                                    }
                                });
                            }
                            else
                            {
                                jQuery('#registrationForm .error').html('');

                                for (error in data.message)
                                {

                                    jQuery('#' + error + 'Error').html(data.message[error]);

                                }

                                expander.reflow();
                            }

                            loader.hide();
                        });

                        return false;
                    });
        }
        function regSlideDown(){
            jQuery("#fastemail").slideDown("slow", function(){
                jQuery("#pass_cont").slideDown("slow", function(){
                    jQuery("#register_fields").slideDown("slow", function(){
                        jQuery("#fastsubmit").slideDown("slow");
                    });
                });
            });
        }

        function registerShow() {
            jQuery("#special_form").attr("action", "");
            jQuery("#recover_result").remove();
            jQuery("#registrationOK").remove();
            jQuery(".popup_checkboxes").attr("id", "registrationForm");
            jQuery("#fastlogin").attr("checked", false);
            jQuery("#fastname").slideDown("slow", regSlideDown);
            jQuery("#fastsubmit").val('Sign up');
            jQuery(".error").empty();
            jQuery("#special_form").unbind("submit");
            jQuery("#passRecovery").hide();
            registerBind();
        }
        
        jQuery("#reg").click(registerShow);
        jQuery("#registerLabel").click(registerShow);

        function passRecoveryShow() {
            jQuery("#fastname").slideUp();
            jQuery("#pass_cont").slideUp("slow");
            jQuery("#register_fields").slideUp();
            jQuery("#passRecovery").hide();
            jQuery(".error").empty();
            jQuery("#fastlogin").attr("checked", false);
            jQuery("#reg").attr("checked", false);
            jQuery("#fastsubmit").val('Submit');
            jQuery("#special_form").unbind("submit");
            jQuery(".popup_checkboxes").attr("id", "recoveryForm");

            jQuery("#special_form").bind("submit", function(event){

                        event.preventDefault();
                        loader.show();
                        jQuery(".error").empty();

                        if(jQuery("input#fastemail").val() == "e-mail"){
                            jQuery("#emailError").html('should not be empty');
                            jQuery("#emailError").css({"text-align" : "left",
                                                        "padding-left": "0px"});

                            loader.hide();
                            return false;
                        }

                        var expander = hs.getExpander(jQuery('#registration').get(0));
                        jQuery.getJSON('/Password/?cmd=claimProcess&ajax=1', jQuery(':input', this), function(data)
                        {

                            if (data.success)
                            {
                                jQuery('#fastemail').slideUp();
                                jQuery('#fastsubmit').slideUp();

                                jQuery('.form_main').append('<div id="recover_result" style="text-align: left; margin-top: 10px; font-size: 12px;">' + data.message + '</div><input id="registrationOK" type="submit" value="OK" id="submit" class="button2" name="submit" style="margin-left: 55px;"/>').show();
      

                                jQuery("#registrationOK").click(function(){
                                    loginShow();
                                });

                            }
                            else
                            {
                                 jQuery("#emailError").html('email is not available');
                                 jQuery("#emailError").css({"text-align" : "left",
                                                            "padding-left": "0px"});
                                expander.reflow();
                            }

                            loader.hide();
                        });

                        return false;
                    });            
        }

        jQuery("#passRecovery").click(function(event){
            event.preventDefault();
            passRecoveryShow();
            });

        jQuery("input#name").blur(function(){
            jQuery("#nameError").empty();
           if (!jQuery(this).val()) {
               jQuery(this).val('first name');
               jQuery("#nameError").html('should not be empty');
               jQuery("#nameError").css({"text-align" : "left",
                                                       "padding-left": "0px"})
           }
        });

        jQuery("input#pass").blur(function(){
            jQuery("#passError").empty();
            jQuery("#confirmError").empty();
                        if(jQuery("input#pass").val() == "password"){
                            jQuery("#passError").html('should not be empty');
                            jQuery("#passError").css({"text-align" : "left",
                                                        "padding-left": "0px"});

                            return false;
                        }

                        if(jQuery("input#pass").val().length < 6){
                            jQuery("#passError").html('at least 6 characters');
                            jQuery("#passError").css({"text-align" : "left",
                                                        "padding-left": "0px"});

                            return false;
                        }


        });
        jQuery("input#confirm").blur(function(){
            jQuery("#passError").empty();
            jQuery("#confirmError").empty();
                        if(jQuery("input#pass").val() != jQuery("input#confirm").val()) {
                            jQuery("#confirmError").html('does not match password');
                            jQuery("#confirmError").css({"text-align" : "left",
                                                        "padding-left": "0px"});

                           return false;

                        }
        });
        jQuery("input#fastemail").blur(function(){
        if(jQuery("input#fastemail").val() != "e-mail"){
            if (jQuery(".popup_checkboxes").attr("id") == "registrationForm") {
                jQuery.ajax({
                    type: "POST",
                    url: "/Ajax/",
                    data: "email=" +jQuery("input#fastemail").val(),
                    success: function(html) {
                        if(html != "1") {
                            if (html == "wrong email format")
                                jQuery("#emailError").html(html);
                            else
                                jQuery("#emailError").html('e-mail is not available');
                            
                        }
                        else {
                            jQuery("#emailError").empty();
                        }
                    }
                });
            }
            else {
                 jQuery.ajax({
                    type: "POST",
                    url: "/Ajax/",
                    data: "email=" +jQuery("input#fastemail").val(),
                    success: function(html) {
                        if(html != "1" && html != "wrong email format") {
                            jQuery("#emailError").empty();
                        }
                        else {
                            if (html == "wrong email format")
                                jQuery("#emailError").html(html);
                            else
                                jQuery("#emailError").html('e-mail is not available');

                            jQuery("#emailError").css({"text-align" : "left",
                                                       "padding-left": "0px"})
                        }
                    }
                });
            }
        } else {
            jQuery("#emailError").html('should not be empty');
            jQuery("#emailError").css({"text-align" : "left",
                                       "padding-left": "0px"})
        }
        });
        
    });
}