
$(document).ready(function(){
	$("#nav-one li").hover(
	function(){ $("ul", this).fadeIn("fast"); },
	function() { }
	);
	if (document.all) {
		$("#nav-one li").hoverClass ("sfHover");
	}
});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover(
		function() { $(this).addClass(c);  },
		function() { $(this).removeClass(c); }
		);
	});
};

function checkAll(value) {
	var field = document.globikeForm.elements['sup_id[]'];
	for (i = 0; i < field.length; i++)
	field[i].checked = value ;
}

sendPhone = function(){
	return {
		validate: function() {
			var phone = YAHOO.util.Dom.get('phone');
			var clean = YAHOO.util.Dom.get('clean').value;
			var title = YAHOO.util.Dom.get('popup_title').value;
			
			if(phone.value == '' || clean == 0) {
				dialog.showInfo(title,YAHOO.util.Dom.get('popup_empty').value);
			} else {
				
				var handleSuccess = function(o){
					if(o.responseText == 'contact@ckt-carbon.com'){
						dialog.showInfo(title,YAHOO.util.Dom.get('popup_good').value);
						phone.value = '';
					} else {
						handleFailure();
					}
				};
				var handleFailure = function(o){
					dialog.showInfo(title,YAHOO.util.Dom.get('popup_bad').value);
				};
				var callback = {  
					success:handleSuccess,
				  	failure:handleFailure
				};
				var postData = "phone="+phone.value;
				YAHOO.util.Connect.asyncRequest('POST', 'call_me.php', callback, postData);
			}
		},
		clean: function() {
			var clean =  YAHOO.util.Dom.get('clean');
			if(clean.value == 0) {
				clean.value = 1;
				YAHOO.util.Dom.get('phone').value = '';
			}
		},
		enterPress: function(e) {
			var keycode = 0;
			if(window.event) {
				keycode = window.event.keyCode;
			} else if (e) {
				keycode = e.which;
			}
			if(keycode == 13) {
				this.validate();
			}
		}
	};
}();

		
YAHOO.namespace("ckt");

dialog = function(){
	return {
		showInfo: function(dialogTitle,dialogText) {
			var handleNo = function() {
				this.hide();
			};
			YAHOO.ckt.infoDialog = new YAHOO.widget.SimpleDialog("infoDialog",
			{
				width: "20em",
				effect:{effect:YAHOO.widget.ContainerEffect.FADE,
						duration:0.3},
				fixedcenter: true,
				visible : false,
				modal: true,
				draggable:false,
				iframe: true,
				constraintoviewport: true,
				underlay: "shadow"
			} );

			YAHOO.ckt.infoDialog.setHeader(dialogTitle);
			YAHOO.ckt.infoDialog.setBody(dialogText);

			YAHOO.ckt.infoDialog.render('infoDialogCont');
			YAHOO.ckt.infoDialog.show();
			
			YAHOO.ckt.infoDialog.header.style.fontSize = "12px"; 
			YAHOO.ckt.infoDialog.body.style.fontSize = "12px"; 
		}
	};
}();

function checkLandingForm(){
        $('#temp_error').hide();
        var error_string = '';

        if($('#first_name').val() == ''){
            error_string += '<b>Votre nom</b> obligatoire<br />';
        }
        if($('#last_name').val() == ''){
            error_string += '<b>Votre pr&eacute;nom</b> obligatoire<br />';
        }
        if($('#from_id').val() == ''){
            error_string += '<b>Email</b> obligatoire<br />';
        }else if(!validator_email($('#from_id').val())){
            error_string += 'Le format de l\'Email est invalide<br />';
        }
        
        if(error_string == ''){
            $('#quote').submit();
        }else{
            $('#temp_error').fadeIn('slow').html(error_string);
        }
}

