
$(document).ready(function(){
	
/* HEADER CAROUSEL */
	$("#headerCarousel").jCarouselLite({
        btnNext: "#headerCarouselRight",
        btnPrev: "#headerCarouselLeft",
        speed: 800,
        //auto: 3000,
       	start: 0,
       	//vertical: true,
        mouseWheel: false,
        easing: "backout",
        circular: true,
        visible: 4,
        scroll: 4
    });
    
/* PROFILE CAROUSEL */
	$("#profileCarousel").jCarouselLite({
        btnNext: "#profileCarouselBottom",
        btnPrev: "#profileCarouselTop",
        speed: 800,
        //auto: 3000,
       	//start: 0,
       	vertical: true,
        //mouseWheel: false,
        easing: "backout",
        circular: false,
        visible: 3,
        scroll: 1
    });    
    
/* DROP DOWN MENU 
	$('ul.horizMenu').NavDropDown({
       duration:300,
       hoverElement:'li',
       hoverClass:'hover',
       dropHolder:'div',
       showEffect:'fade' // slide, fade, slide&fade
    }); */
    
/* DROP LINE MENU */
 $(".horizMenu").superfish({ 
	 	hoverClass:  'hover',
         pathClass:  'open',
         delay: 300,
         animation: {opacity:'show'},
         speed: 'normal',
         autoArrows:  false
   });  

/* PRETTY PHOTO */	
	$("a[rel^='prettyPhoto']").prettyPhoto({			
			animationSpeed: 'normal', /* fast/slow/normal */
			opacity: 0.80, /* Value between 0 and 1 */
			showTitle: false, /* true/false */
			allowresize: true, /* true/false */
			default_width: 500,
			default_height: 344,
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'facebook', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
			hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
			wmode: 'opaque', /* Set the flash wmode attribute */
			autoplay: true, /* Automatically start videos: True/False */
			modal: false, /* If set to true, only the close button will close the window */
			changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
			callback: function(){} /* Called when prettyPhoto is closed */			
	}); 

/* LOAD SLIDER */
	$(".headerCarouselCont").attr("style", "");
	
/* LOAD HORIZMENU */
	$(".horizMenu").attr("style", "");
	
});

/* CUFON */

Cufon.replace('h1', { fontFamily: 'Myriad Pro' });
Cufon.replace('.cufonFont', { fontFamily: 'Myriad Pro' });

function searchSubmit()
{
	var oForm= document.getElementById("searchGalleryForm");
	var ageFrom = new Number(oForm.age_from.value);
	var ageTo = new Number(oForm.age_to.value); 
	var heightFrom = new Number(oForm.height_from.value);
	var heightTo = new Number(oForm.height_to.value); 
	var weightFrom = new Number(oForm.weight_from.value);
	var weightTo = new Number(oForm.weight_to.value); 
	
	if(ageFrom > ageTo) 
	{
		alert("\"Age from\" can not be more \"Age to\" !");
		return;
	}
	else if(heightFrom > heightTo)
	{
		alert("\"Height from\" can not be more \"Height to\" !");
		return;
	}
	else if(weightFrom > weightTo)
	{
		alert("\"Weight from\" can not be more \"Weight to\" !");
		return;
	}
	
	oForm.submit();
}

function searchReset()
{
	var oForm = document.getElementById('searchGalleryForm');
	
	var ageToLength = oForm.age_to.length - 1;
	var heightToLength = oForm.height_to.length - 1;
	var weightToLength = oForm.weight_to.length - 1;
	
	oForm.age_from[0].selected = "true";
	oForm.age_to[ageToLength].selected = "true";
	oForm.height_from[0].selected = "true";
	oForm.height_to[heightToLength].selected = "true"; 
	oForm.weight_from[0].selected = "true"; 
	oForm.weight_to[weightToLength].selected = "true";
	oForm.children[0].selected = "true";
	oForm.sort[0].selected = "true";
}

function searchIdSubmit()
{
	var oForm= document.getElementById("searchByIdForm");
	oForm.action = "woman_profile/" + oForm.women_id.value + "/";
	
	if(oForm.women_id.value.length == 0)
	{
		alert("Field \"ID\" is empty !");
		return;
	}
	
	oForm.submit();
}

function ageIntervalSubmit()
{
	var oForm= document.getElementById("ageIntervalForm");
	
	if(oForm.age_interval.value == "false")
	{
		alert("Age interval not selected !");
		return;
	}
	
	oForm.submit();
}

function addToCart(articleId, articlePrice)
{
	var oForm= document.getElementById("catalogForm");
	
	oForm.article_id.value = articleId;
	oForm.article_price.value = articlePrice;
	oForm.lady_id.value = document.getElementById(articleId + "LadyId").value;

	oForm.action = window.location;

	oForm.submit();
}

function calculatPrice(priceId, price, oSelect)
{
	var oPrice = document.getElementById(priceId);
	var oForm= document.getElementById("orderForm");
	
	var num = oSelect.value;

	num = ++num;
	
	oPrice.innerHTML = price * num + " $";
}

function articleDel(trId)
{
	var oTr = document.getElementById(trId);
	
	oTbody = oTr.parentNode;
	oTbody.removeChild(oTr);	
}

function womenDel(womenId)
{
	var oForm = document.getElementById("selectionForm");
	
	oForm.lady_id.value = womenId;
	
	oForm.submit();
}

function membershipPrice(oSelect, key, price_1, price_2)
{
	var oTd = document.getElementById("memberPrice"+key);	
	var price = (oSelect.value == 2) ? price_2 : price_1;
	
	oTd.innerHTML = price+"$";
}

function tourSelect()
{
	var oForm = document.getElementById("tourForm");
	var oSumDiv = document.getElementById("sumTour");
	var sum = parseFloat(0);
	
	for(var i = 0; i < oForm.length; i++)
	{
		if(oForm.elements[i].checked == true)
		{
		 	sum = sum + parseFloat(oForm.elements[i].value);
		}
	}
	
	var pay = (sum / 100) * 30; 
	
	if(sum > 0)
	{
		 oForm.add_tour.style.visibility = "visible";
		 oSumDiv.innerHTML = "Sum: " + sum + " $<br>Preliminary payment: " + pay + " $";
		 oForm.sum.value = pay;
	}
	else {
		oForm.add_tour.style.visibility = "hidden";
		oSumDiv.innerHTML = "";
	}				
}

function tourChangeNum(name, value)
{
	var oForm = document.getElementById("tourForm");
	var oCheckbox = document.getElementById(name);
	var oSpan = document.getElementById(name + "Html");
	var oSelect = document.getElementById(name + "Select");
	
	var price = value * (parseFloat(oSelect.value) + 1);
	
	oSpan.innerHTML = price;
	oCheckbox.value = price;
	
	tourSelect();
}

function popUpPhoto(URL, w, h) 
{
	day = new Date();
	id = day.getTime();
	w=w+20;
	h=h+20;
	
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width="+w+",height="+h+",left = 240,top = 212');");
}

function actionResumeButton(oDiv, action)
{	
	if(action == "over") 
	{
		oDiv.style.backgroundColor = "#5DB27F";
	}
	else if(action == "out") 
	{
		oDiv.style.backgroundColor = "#A1DFBA";
	}
}

function actionSelectionButton(oButton, action)
{	
	if(action == "over") 
	{
		oButton.style.backgroundColor = "#91A197";
	}
	else if(action == "out") 
	{
		oButton.style.backgroundColor = "ABBDB2";
	}
}



