$(document).ready(function() {
	$('.subm input').hover(
		function () {
			$(this).addClass('hover');
		},
		function () {
			$(this).removeClass('hover');
		}
	);
});

$(document).ready(function()
{
	$(".handle").toggle
	(
		function()
		{
			$('#contactbar').animate({right:'0px'}, {queue:false,duration:300});
			$('#contactbar > .handle').addClass('out');
		}
		,function()
		{
			$('#contactbar').animate({right:'-292px'}, {queue:false,duration:200});
			$('#contactbar > .handle').removeClass('out');
		}
	);

});

function fill_models(make_id, select_models, ajax_url, cur_model, isBuild) {
	var request = "data[make_id]="+make_id;
	if(isBuild)
		request += "&data[is_build]=1";
	$.ajax({
		url: ajax_url,
		data: request,
		dataType: "json",
		type: "POST",
		cache: false,
		success: function (data, textStatus) {
			//var select_models = $('#'+select_model_id);
			var default_option = select_models.children(":first");
			var options = '<option value="'+default_option.val()+'">'+default_option.text()+'</option>';
			var selected_id = cur_model;

			select_models.attr("disabled", true);
			if(data != ''){
				$.each(data, function(i, val) {
					var selected = '';
					if(selected_id == i)
						selected = 'selected="selected"';
					options += '<option '+selected+' value="'+i+'">'+val+'</option>';
				});
			}
			select_models.empty().append(options);
			select_models.attr("disabled", false);
		}
	});
}

function liveCurrency() {
	//2 = GBP/USD, 516 = GBP/EUR
	$.ajax({
		url: "http://freeserv.dukascopy.com/qt/prc.php",
		data: "aData[id]=2,516",
		dataType: "script",
		type: "GET",
		cache: false,
		success: function (data, textStatus) {
			setTimeout("liveCurrency()", 20000);
		}
	});
}

function sr(countryId, currency) {
	updateCurrencies(countryId, currency);
}

var $liveCurrency;
function updateCurrencies(countryId, currency) {
	$("#country_"+countryId, $liveCurrency).text(currency);
}

/*
var scroller, actualheight;
var pauseit=1;
  var scrollerwidth="200px";
  var scrollerheight="250px";
  var scrollerspeed=1;
  var copyspeed=scrollerspeed;
  var pausespeed=(pauseit==0)? copyspeed: 0;

$(document).ready(function(){



  $('.testimonials_block').html("<div id='scroller' style='position:absolute;left:0px;top:0px;width:100%;'>"+$('.testimonials_block').html()+"</div>");
  $(".testimonials_block").attr('onmouseover', 'copyspeed=scrollerspeed');

  if (document.getElementById("scroller"))
  {
      scroller = document.getElementById("scroller");
      actualheight=scroller.offsetHeight;
      //alert(actualheight);
      lefttime=setInterval("scrollscroller()",75);
      //scrollscroller();
  }
});

function scrollscroller()
{
    if (parseInt(scroller.style.top)>(actualheight*(-1)+8))
       scroller.style.top=parseInt(scroller.style.top)-copyspeed+"px";
    else
    {
        //alert(scroller.style.top);
        scroller.style.top="0px";
    }
}
*/

function ChangeTestimonial()
{
         $.ajax({
        		url: "/testimonials/testimonials_ajax",
        		dataType: "script",
        		type: "GET",
        		cache: false,
        		success: function (data, textStatus) {
                $("#scroller").html(data);
        		}
        	});
}

$(document).ready(function(){
  $('#view_testimonial').click(function(){ChangeTestimonial();  return false;});
  setTimeout("ChangeTestimonial()", 60000);
});


function isValidEmail( sField )
{
	var emailRegEx = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/
	return( emailRegEx.test( sField ) );
}



