 
var Common = {
                
        submitform:function (page) 
        {
           document.myform.whichpage.value = page;
           document.myform.submit();
		}
       ,
        Close_Window:function()
        {
        self.close();
        }
       ,
        Location_href:function(page_url) 
        {
 
               document.location.href = page_url;
		}

}
var DesignScript = {

    change_css_class_name: function(ElementID, css_class_name) {
        var ele = null;
        ele = $(ElementID);
        ele.className = css_class_name
        

    }
}

$(document).ready(
 function() {
     $("#BtnCommant").click(
            function() {
                var isValid = true;

                var txtName = $('#txtName');
                if (txtName.val().length == 0) {
                    isValid = false;
                    txtName.css({ "border": "1px solid red" });
                }
                else {
                    txtName.removeAttr('style');
                }

                var txtEmail = $('#txtEmail');
                if (!isValidEmailAddress(txtEmail.val())) {
                    isValid = false;
                    txtEmail.css({ "border": "1px solid red" });
                }
                else {
                    txtEmail.removeAttr('style');
                }
               

                var txtCommant = $('textarea#txtCommant').val();
                txtCommant = jQuery.trim(txtCommant);
                var lblCommant = $('#lblCommant');

                if (txtCommant.length == 0 || txtCommant.length > 500) {
                    isValid = false;
                    lblCommant.html('תגובה - מקסימום 500 תווים ');
                    lblCommant.css({ "color": "red" });
                }
                else {
                    lblCommant.html('תגובה ');
                    lblCommant.removeAttr('style');
                }

                
                if (isValid) {

                    var txtUrl = $('#txtUrl');
                    txtUrl.val(document.location.href);
                    
                    document.formCommant.submit();
                        
                }

            }
 )
 });
 
function isValidEmailAddress(emailAddress) {  
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);  
return pattern.test(emailAddress);  
}

$(document).ready(
 function() {
$("#add_commant").click(
            function() {

                var commantContainer = $('#div_Commant');

                commantContainer.slideToggle(2000);
              }
 )
 });
 



