jQuery(document).ready(function(){
	jQuery(".cgv_connect").live("click", function() {
		var box = jQuery(this).parents().find(".cgv_callContent");
		var name = jQuery(box).find(".cgv_callMeName").val();
		var phone = jQuery(box).find(".cgv_callMeNumber").val();
		var wid =  jQuery(box).find(".cgv_wid").val();
        var code = jQuery(box).find(".cgv_countryCode").val();
		jQuery.post(window.location.href, {
			gvc_action: 1,
			"action":"send",
			"contact":name,
			"phone":phone,
			"wid":wid,
            "countryCode":code
			}, function(data) {
				jQuery("input",box).removeClass('error');
				if(data.error) {
				   jQuery.each(data.err, function(i,v) {
    					if(!jQuery(v,box).hasClass('error')) {
							jQuery(v,box).addClass('error');
						}
					});
                }
                switch(data.status) {
                    case 1:
                    case 3:
                        jQuery(box).replaceWith(data.html);
                        break;
                }
                
		  }, "json"
		);
		return false;
	});

});

