$(document).ready(function(){
    $('.slide-out-div').tabSlideOut({
            tabHandle: '.handle',                     //class of the element that will become your tab
            pathToTabImage: BASE_URL+ 'images/opportunities.png', //path to the image for the tab //Optionally can be set using css
            imageHeight: '127px',                     //height of tab image           //Optionally can be set using css
            imageWidth: '45px',                       //width of tab image            //Optionally can be set using css
            tabLocation: 'left',                      //side of screen where tab lives, top, right, bottom, or left
            speed: 300,                               //speed of animation
            action: 'click',                          //options: 'click' or 'hover', action to trigger animation
            topPos: '155px',                          //position from the top/ use if tabLocation is left or right
            leftPos: '20px',                          //position from left/ use if tabLocation is bottom or top
            fixedPosition: false                      //options: true makes it stick(fixed position) on scroll
        });

        
     $(".cancel_feedback").click(function(){
     	 $('.handle').trigger('click');
         return false;
     });
        
        
     $("#reset_feedback").click(function(){
		$("#TopicFirstName").val('');
		$("#ErrorFirstName").html('*');
		
		$("#TopicLastName").val('');
		$("#ErrorLastName").html('*');
		
		$("#TopicPreferredPhone").val('');
		$("#ErrorPreferredPhone").html('*');
		
		$("#TopicHomePhone").val('');
		$("#ErrorHomePhone").html('*');
		
		$("#TopicEmailAddress").val('');
		$("#ErrorEmailAddress").html('*');
		
		$("#TopicResidentialAddress").val('');	
		$("#ErrorResidentialAddress").html('*');
		
		$("#TopicCurentEmployer").val('');
		$("#ErrorCurentEmployer").html('*');
		
	        $("#TopicCode").val('');
	        $("#ErrorCode").html('*');
     	return false;
     });

    $("#submit_feedback").click(function(){
		$(".error").html("");
		var hasError = false;
		
		var TopicFirstNameVal = $("#TopicFirstName").val();
		if(TopicFirstNameVal == '') {
			$("#ErrorFirstName").html('*');
			hasError = true;
		}
		var TopicLastNameVal = $("#TopicLastName").val();
		if(TopicLastNameVal == '') {
			$("#ErrorLastName").html('*');
			hasError = true;
		}
		
		var TopicPreferredPhoneVal = $("#TopicPreferredPhone").val();
		if(TopicPreferredPhoneVal == '') {
			$("#ErrorPreferredPhone").html('*');
			hasError = true;
		}
		
		var TopicHomePhoneVal = $("#TopicHomePhone").val();
		if(TopicHomePhoneVal == '') {
			$("#ErrorHomePhone").html('*');
			hasError = true;
		}
		
		var TopicEmailAddressVal = $("#TopicEmailAddress").val();
		if(TopicEmailAddressVal == '') {
			$("#ErrorEmailAddress").html('*');
			hasError = true;
		}
		
		var TopicResidentialAddressVal = $("#TopicResidentialAddress").val();
		if(TopicResidentialAddressVal == '') {
			$("#ErrorResidentialAddress").html('*');
			hasError = true;
		}
		var TopicCurentEmployerVal = $("#TopicCurentEmployer").val();
		if(TopicCurentEmployerVal == '') {
			$("#ErrorCurentEmployer").html('*');
			hasError = true;
		}
		
	        var TopicCodeVal = $("#TopicCode").val();
	        if(TopicCodeVal == '') {
	            $("#ErrorCode").html('*');
	            hasError = true;
	        }		
		
		if(hasError == false) {
			$(this).hide();
			$.post(BASE_URL+"contact_us/slidefeedback",
   				{ TopicFirstName: TopicFirstNameVal, TopicLastName: TopicLastNameVal, TopicPreferredPhone: TopicPreferredPhoneVal, TopicHomePhone:TopicHomePhoneVal , TopicEmailAddress:TopicEmailAddressVal, TopicResidentialAddress:TopicResidentialAddressVal, TopicCurentEmployer:TopicCurentEmployerVal, TopicCode:TopicCodeVal },
   					function(data){
						$(".myformx").slideUp("normal", function() {
							$(".myformx").before('<h3>Success</h3><p>Thank you for your message, we will contact you shortly.</p>.      <br> <input type="submit" value=" CLOSE " id="cancel_feedback" class="cancel_feedback submit_button open" onClick="javascript: $(\'.handle\').trigger(\'click\'); return false;" name="fld_send">');
						});
   					}
				 );
		}

		return false;
	});

});
