$(document).ready(function(){
	
var productNav = $('#products-block');
var productBut = $('#products-link');
productNav.hide();
productBut.click(function(){
productNav.slideToggle('fast');
$(this).toggleClass('active');
return false;
})

//add support for IE6 -------------- //

if( getClient() == 'IE6' ) {
	$('input[type=text]').addClass('text');
}


// gridConnect bar
hoverFade($('#gridconnectBar'));
$('#gridconnectBar').click(function(){window.location='http://www.es-pv.co.uk/';});


// off grid quote form ------------
$('#offGridQuote_submit').click(function(){ 
	sendForm({
		url: '../_inc/ssi/mail.php',
		data: $('form').serialize()
	});
	return false;
});


});// end ready

// global functions ----------------------------------------- 

function hoverFade(obj) {
	obj.hover(function(){$(this).stop().animate({opacity:0.7},400);},
	function(){	$(this).stop().animate({opacity:1},200); })
}

var sendForm = function(props){
	$.ajax({
		url:props.url,
		type: 'POST',
		data: props.data,
		success: function(data){ $('#feedback').html(data).addClass('active'); }
	});
	return false;
}

function getClient() {
	var agent = navigator.userAgent;
	if ( (agent.match(/iPhone/i)) || (agent.match(/iPad/i)) || (agent.match(/iPod/i)) ) {
		return 'iPhone';
	}
	else if ( agent.match(/MSIE 7/i) ) {
		return 'IE7';
	}
	else if ( agent.match(/MSIE 8/i) ) {
		return 'IE8';
	}
	else if ( agent.match(/MSIE 6/i) ) {
		return 'IE6';
	} 
	else {
		return agent;
	}
}
