function hoverIn_MSIE(element){
	jQuery.each(jQuery.browser, function(i, val) {
		if (i=='msie' && jQuery.browser.version.substr(0,1)=='6'){
			if (element.hasClass('foreway_fleet')){
				element.children('a').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/menu/menu_foreway_fleet_hover.png",sizingMethod="crop")');
			}
			if (element.hasClass('service')){
				element.children('a').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/menu/menu_management_services_hover.png",sizingMethod="crop")');
			}
			if (element.hasClass('green')){
				element.children('a').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/menu/menu_green_hover.png",sizingMethod="crop")');
			}
			if (element.hasClass('technology')){
				element.children('a').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/menu/menu_technology_hover.png",sizingMethod="crop")');
			}
			//if (element.hasClass('request_quote')){
			//	element.children('a').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/menu/menu_request_quote_hover.png",sizingMethod="crop")');
			//}
			if (element.hasClass('no_flag')){
				element.children('a').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/menu/menu_request_quote_wo_flag_hover.png",sizingMethod="crop")');
			}
		}
	});
}

function hoverOut_MSIE(element){
	jQuery.each(jQuery.browser, function(i, val) {
		if (i=='msie' && jQuery.browser.version.substr(0,1)=='6'){
			if (element.hasClass('foreway_fleet')){
				element.children('a').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/menu/menu_foreway_fleet.png",sizingMethod="crop")');
			}
			if (element.hasClass('service')){
				element.children('a').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/menu/menu_management_services.png",sizingMethod="crop")');
			}
			if (element.hasClass('green')){
				element.children('a').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/menu/menu_green.png",sizingMethod="crop")');
			}
			if (element.hasClass('technology')){
				element.children('a').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/menu/menu_technology.png",sizingMethod="crop")');
			}
			//if (element.hasClass('request_quote')){
			//	element.children('a').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/menu/menu_request_quote.png",sizingMethod="crop")');
			//}
			if (element.hasClass('no_flag')){
				element.children('a').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="images/menu/menu_request_quote_wo_flag.png",sizingMethod="crop")');
			}
		}
	});
}

function makeTall() {
			hoverIn_MSIE($(this));
			$(this).children('a').children('img.normal').css('display','none');
			$(this).children('a').children('img.hover').css('display','block');
			//$(this).children('ul').css('display','block');
			$(this).children('ul').slideDown(300);

			$(this).children('div.current').css('display','none');
}

function makeShort() {
			hoverOut_MSIE($(this));
			$(this).children('a').children('img.hover').css('display','none');
			$(this).children('a').children('img.normal').css('display','block');
			//$(this).children('ul').css('display','none');
			$(this).children('ul').slideUp();

			$(this).children('div.current').css('display','block');
}

$(document).ready(function () {

	//alert();
	var randBannerNo = Math.floor(Math.random()*3) + 1;
	$('.banner'+ randBannerNo).css("display","block");
	
	//var currli = $('#menu li').find('.current').parent();
	//$('#menu li').find('.current').parent().find('.sub_menu').show();
	
	var hover_config = {    
		 sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 15, // number = milliseconds for onMouseOver polling interval    
		 over: makeTall, // function = onMouseOver callback (REQUIRED)    
		 timeout: 15, // number = milliseconds delay before onMouseOut    
		 out: makeShort // function = onMouseOut callback (REQUIRED)    
	};

	$("#menu li").hoverIntent( hover_config );

});

function isFormCompleted(){
    
    var inputsIds = isFormCompleted.arguments;
    var input = null;
    
    for(var i = 0; i < inputsIds.length; i ++){
        input = document.getElementById(inputsIds[i]);
        if( input.type == "text" && (input.value.trim() == "" || input.value == null) ){
            alert("Please, complete all required field(s) first.");
            
            return false;
        }
    }
    
    return true;
}


//function to check valid email address
function isValidEmail(emailInputId){

    var validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
    var strEmail = document.getElementById(emailInputId).value;
    
    // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) {
        alert('A valid e-mail address is required.\nPlease amend and retry');
        
        return false;
    } 
    
    return true; 
}