var url = "http://"+document.domain+"/";
var curFeadback = 0;
jQuery(document).ready(function() {
    //var regEmail = /\/([a-zA-Z0-9\-\.]+)\.m\.([a-zA-Z0-9\-\.]+)\/([a-zA-Z]{2,6})\//g;
    //document.body.innerHTML = document.body.innerHTML.replace(regEmail, '$1@$2.$3');
	$("a[rel='lightbox-item']").colorbox({transition:"fade"});
	$("select.country").bind("change", function() {
		var num = $(this).attr("value")*1;
		if (!num) {
			
			$("tr.dealer").fadeIn("slow");
		} else {
			$("tr.dealer[rel!="+num+"]").fadeOut("slow");
			$("tr.dealer[rel="+num+"]").fadeIn("slow");
		}
	});
	$("#fba").validationEngine();
	$(".feadback").hide();
	$($(".feadback")[0]).show();
	
	$(".fbprev").bind("click", function() {
		fbnav(-1);
		return false;
	});
	$(".fbnext").bind("click", function() {
		fbnav(1);
		return false;
	});
	
	$(".mmm").bind("mouseover", function(){
		var rel = $(this).attr("rel");
		if ($("div.patron[rel="+rel+"]").length) {
			$("div.patron").addClass("hide");
			$("div.patron[rel="+rel+"]").removeClass("hide");
		}
		if ($("div.slogon[rel="+rel+"]").length) {
			$("div.slogon").addClass("hide");
			$("div.slogon[rel="+rel+"]").removeClass("hide");
		}
	})
	$(".mmm").bind("mouseout", function(){
		var rel = $(this).attr("rel");
		if ($("div.patron[rel="+rel+"]").length) {
			$("div.patron").addClass("hide");
			$("div.patron[rel=0]").removeClass("hide");
			$("div.spl img").hide();
			$($("div.spl img")[curspl]).show();
		}
		if ($("div.slogon[rel="+rel+"]").length) {
			$("div.slogon").addClass("hide");
			$("div.slogon[rel=0]").removeClass("hide");
		}
	})
	
	if ($("div.spl").length) {
		var curspl = 0;
		$($("div.spl img")[curspl]).fadeIn("slow");
		setInterval(function(){
			$($("div.spl img")[curspl]).fadeOut("slow");
			curspl++;
			if (curspl == $("div.spl img").length) curspl = 0;
			$($("div.spl img")[curspl]).fadeIn("slow");
		}, 3000);
	}
});

function fbnav(step) {
	var fblist = $(".feadback");
	curFeadback+=step;
	if (curFeadback<0) curFeadback = fblist.length-1;
	if (curFeadback>=fblist.length) curFeadback = 0;
	fblist.hide();
	$(fblist[curFeadback]).fadeIn("slow");
}

function showHide(el) {
	if (el.data('currentState') == "on") {
		el.data('currentState', 'off');
		el.slideUp("slow");
		
	}
	else {
		el.data('currentState', 'on');
		el.slideDown("slow");
		
	}
}
