function hideHeart(){
	$(".rHeart").attr("src","http://www.findyoursalon.info/client/img/r_0.gif");
}

function showHeart(r){
	for(i=1; i <= 10; i++) {
		if(i <= r) $("#r"+i).attr("src","http://www.findyoursalon.info/client/img/r_1.gif");
		else $("#r"+i).attr("src","http://www.findyoursalon.info/client/img/r_0.gif");
	}
}

function setHeart(i, r){
	$.post('http://www.findyoursalon.info/ajax.php', {action:"setSalonRaiting", i:i, c:r}, function(data){
		window.location.reload(false);
	});
}

function sendRequest(){
	var n, e, c, t, b, s;
	var n = $("#reqName").val();
	var e = $("#reqEmail").val();
	var c = $("#reqCity").val();
	var t = $("#reqContact").val();
	var b = $("#reqBudget").val();
	var s = $("#reqComments").val();
	$.post('http://www.findyoursalon.info/ajax.php', {action:"sendRequest", n:n, e:e, c:c, t:t, b:b, s:s}, function(data){
		if (data == 'OK') $("#requestWebForm").hide();
			
	});
}

function sendEmailToSalon(){
	$("#sendErrors").hide();
	var i, n, e, t, c;
	var i = $("#sendSalonID").val();
	var n = $("#sendSalonName").val();
	var e = $("#sendSalonEmail").val();
	var t = $("#sendSalonText").val();
	var c = $("#sendSalonCode").val();
	$.post('http://www.findyoursalon.info/ajax.php', {action:"sendEmailToSalon", i:i, n:n, e:e, t:t, c:c}, function(data){
		if (data == 'OK') $('#dialog').jqmHide();
		else {
			$("#sendErrors").html(data);
			$("#sendErrors").show();
		}
	});
}

function NewsLetter(status) {
	if (status == 'on') {
		$("#newsLetter").show();
	} else if(status == 'off') {
		if ($("#newsLetterEmail").val() == "") $("#newsLetter").hide();
	}
}

function NewsLetterSubscribe(oForm) {
	var e, g1, g2;
	e = $('#newsLetterEmail').val();
	g1 = $('#newsLetterGroup1').val();
	g2 = $('#newsLetterGroup2').val();
	$.post('ajax.php', {action:"addToNewsletter", email:e, group1:g1, group2:g2}, function(data){
		alert(data);
	});
}

function menuButton(i){
	$("td[id^='menu_']").css("background-image", "url(http://www.findyoursalon.info/client/img/spacer.gif)");
	$("#menu_"+i).css("background-image", "url(http://www.findyoursalon.info/client/img/menuButton.gif)");
}

function Registation() {
	var u, e;
	u = $('#regUsername').val();
	e = $('#regEmail').val();
	$.post('http://www.findyoursalon.info/ajax.php', {action:"addNewSalon", e:e, u:u}, function(data){
		alert(data);
	});
}

function ChangePassword() {
	var u, o, p1, p2;
	u = $('#regUsername').val();
	o = $('#regOldPass').val();
	p1 = $('#regNewPass1').val();
	p2 = $('#regNewPass1').val();
	e = $('#regEmail').val();
	$.post('http://www.findyoursalon.info/ajax.php', {action:"changePassword", u:u, o:o, p1:p1, p2:p2, e:e}, function(data){
		alert(data);
	});
}

function RemindPassword(){
	var e;
	e = $('#remEmail').val();
	$.post('http://www.findyoursalon.info/ajax.php', {action:"remindPassword", e:e}, function(data){
		alert(data);
	});
}

$(function() {
	var e = document.createElement('script'); e.async = true;
	e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
	document.getElementById('fb-root').appendChild(e);
	setInterval("slideSwitch()", 3000);
});

function goCategory(l, v){
	window.location.href='http://www.findyoursalon.info/'+l+v;
}

function slideSwitch() {
	$max = 0;
	a = $("#slideshow > .holder > a > .image");
	for (var i = 0; i < a.size(); i++){
		$max += a.attr("scrollWidth");
	}
	$cur = $("#slideshow").attr("scrollLeft");
	$pos = $cur + 200;
	if ($pos > $max - 700) $pos = 0;
	$("#slideshow").scrollLeft($pos);
}

function initializeStreetView() {
	var StreetView = new google.maps.LatLng(37.869260, -122.254811);
	var StreetViewOptions = {
	  position:StreetView,
	  pov: {
		heading: 165,
		pitch:0,
		zoom:1
	  }
	};
	var StreetViewID = new google.maps.StreetViewPanorama(document.getElementById("placeStreetView"), StreetViewOptions);
	StreetViewID.setVisible(true);
}

function changeProductImage(url) {
	document.getElementById("img01").style.background = "#FFFFFF url(http://www.findyoursalon.info/images/products/220_180_"+url+".jpg) no-repeat center";
	document.getElementById("hrefshow").href = "http://www.findyoursalon.info/images/products/500_500"+url+".jpg"; 
}	

function getContent(id) {
	if(id != eid) {
		if(id != 1)	document.getElementById('tabl_'+id).innerHTML = '<img src="http://www.findyoursalon.info/client/img/title_left_.gif" alt="" />';
		else document.getElementById('tabl_'+id).innerHTML = '<img src="http://www.findyoursalon.info/client/img/title_left.gif" alt="" />';
		document.getElementById('tabc_'+id).className = 'a';
		document.getElementById('tabr_'+id).innerHTML = '<img src="http://www.findyoursalon.info/client/img/title_right.gif" alt="" />';
		document.getElementById('tabl_'+eid).innerHTML = '';
		document.getElementById('tabc_'+eid).className = 'b';
		document.getElementById('tabr_'+eid).innerHTML = '';
		document.getElementById('cont_'+eid).style.display = 'none';
		document.getElementById('cont_'+id).style.display = 'block';
		eid = id;
	}
}

function getProducts(i, p){
	$.post('http://www.findyoursalon.info/ajax.php', {action:"showSalonProducts", i:i, p:p}, function(data){
		$("#salonProducts").html(data);
	});
}

function changeCur(c, l){
	if (c != l){
		$.post('http://www.findyoursalon.info/ajax.php', {action:"changeCurrency", l:l}, function(data){
			window.location.reload(false);
		});
	}
}

function goProductFilter(l, k, p){
	c = $('#selectProductFilterCountry').val();
	if (c != '') c = c + '/';
	if (p == 'on') {
		s = $('#selectProductFilterSeller').val();
		if (s != undefined) s = s + '/';
		o = $('#selectProductFilterSort').val();
		if (o != undefined) o = o + '/';
		window.location.href='http://www.findyoursalon.info/'+l+'/'+c+k+'/f/'+s+o;
	} else {
		window.location.href='http://www.findyoursalon.info/'+l+'/'+c+k;
	}
}

$(window).scroll(function() {
    $('#onTopBar').css('top', $(this).scrollTop() + "px");
});
