// JavaScript Document
jQuery(document).ready(function(){
						   
//jQuery.noConflict();

//$(".comparisonTable tr:odd").addClass("darkRow");



var inputTextShowHide = "";
$('.yourInvestmentFieldsetCol .inputName, .yourInvestmentFieldsetCol .inputEmail, .yourInvestmentFieldsetCol .inputPhone, .yourInvestmentFieldsetCol .inputWeddingDate hasDatepicker, .yourInvestmentFieldsetCol .inputWeddingLocation').focus(function(){
	inputTextShowHide = $(this).attr('Value')
	$(this).attr('Value', '')
});

$('.yourInvestmentFieldsetCol .inputName, .yourInvestmentFieldsetCol .inputEmail, .yourInvestmentFieldsetCol .inputPhone, .yourInvestmentFieldsetCol .inputWeddingDate hasDatepicker, .yourInvestmentFieldsetCol .inputWeddingLocation').blur(function(){
	if ($(this).attr('Value') ==''){
		$(this).attr('Value', inputTextShowHide)
	}
});

$(".teaser").hover(function(){
	$(this).children('teaserHoverBorder').show();
}, function(){
	$(this).children('teaserHoverBorder').hide();
})

var inputClientLoginValue = "";
$(".weddingsClientLoginInputTxt").focus(function(){
	inputClientLoginValue = $(this).attr('Value');
	$(this).attr('Value', '');
});

$(".weddingsClientLoginInputTxt").blur(function(){
	if ($(this).attr('Value') ==''){
		$(this).attr('Value', inputClientLoginValue);
	}
});

$(".weddingsClientLoginBtn").click(function(){
	$("#weddingsClientLogin").append('<div id="clientLoginDivErrorMessage">Parola incorecta!</div>')
	return false;
})


$(".teaser, #animGoLeft, #animGoRight, #teaserNavBtns, .teaserHWrapper, #weddingsClientLogin .weddingsClientLoginBtn").hover(function(){
		$(this).addClass("hover");
	}, function(){
		$(this).removeClass("hover");
})



var inputFocus = "";
$('.contactForm > input').focus(function(){
	inputFocus = $(this).attr('Value')
	$(this).attr('Value', '')
});

$('.contactForm > input').blur(function(){
	if ($(this).attr('Value') ==''){
		$(this).attr('Value', inputFocus)
	}
});

var btnContactFormTxt = "";
$('.submitPost > label > input').focus(function(){
	btnContactFormTxt = $(this).attr('Value')
	$(this).attr('Value', '')
});

$('.submitPost > label > input').blur(function(){
	if ($(this).attr('Value') ==''){
		$(this).attr('Value', btnContactFormTxt)
	}
});
/*
$('.btnContactForm').click(function(){

	if ($('.contactForm .inputName').attr('value') == "Nume"){
		$('.contactForm .inputName').attr('value', '')
		return false;
	}
	if ($('.contactForm .inputEmail').attr('value') == "Email"){
		$('.contactForm .inputEmail').attr('value', '')
		return false;
	}
	if ($('.contactForm .inputSubject').attr('value') == "Subiect"){
		$('.contactForm .inputSubject').attr('value', '')
		return false;
	}
	if (($('.contactForm .inputName').attr('value') == "Nume") || ($('.contactForm .inputEmail').attr('value') == "Email") || ($('.contactForm .inputSubject').attr('value') == "Subiect")){
	return false;
	}
})

*/
/*
$('.postSubmit').click(function(){

	if ($('.submitPost .inputName').attr('value') == "Nume"){
		$('.submitPost .inputName').attr('value', '')
		return false;
	}

	if ($('.submitPost .inputEmail').attr('value') == "Email"){
		$('.submitPost .inputEmail').attr('value', '')
	}
	if ($('.submitPost .inputWebsite').attr('value') == "Website"){
		$('.submitPost .inputWebsite').attr('value', '')
	}
		*/
/*
	if (($('.contactForm .inputName').attr('value') == "Nume") || ($('.contactForm .inputEmail').attr('value') == "Email") || ($('.contactForm .inputSubject').attr('value') == "Subiect")){
	return false;
	}
})
*/


	


//var appendSelectedOptions = false;
var selectedOptionsTxt = '';
$('.yourInvestmentFooter p.sendOptions').click(function(){
//	if (appendSelectedOptions == false){
//		appendSelectedOptions = true;
//	}
		$('#yourInvestmentContent .yourInvestmentLeftCol h3').each(function(){
			selectedOptionsTxt += $(this).html() + "        ---        ";
		})
		$('.selectedOptionsFormItem').html(selectedOptionsTxt);
});


/*
$("#teaserNavArrows").before('<div id="teaserNavBtns"><span id="animGoLeft"> <img src="/images/arrow_animation_left.gif"  alt="slide left" /> </span> <span id="animGoRight"> <img src="/images/arrow_animation_right.gif"  alt="slide right" /> </span></div>');

$("#storyTimeline").after('<div id="teaserVNavBtns"><span id="animVGoLeft"> <img src="/images/arrow_animation_left.gif"  alt="slide left" /> </span> <span id="animVGoRight"> <img src="/images/arrow_animation_right.gif"  alt="slide right" /> </span></div>');
*/


$("#teaserNavArrows").before('<div id="teaserNavBtns"><span id="animGoLeft">  </span> <span id="animGoRight">  </span></div>');
$("#storyTimeline").after('<div id="teaserVNavBtns"><span id="animVGoLeft"> <img src="/images/arrow_animation_left.gif"  alt="slide left" /> </span> <span id="animVGoRight"> <img src="/images/arrow_animation_right.gif"  alt="slide right" /> </span></div>');




$(".articleCommentariesList dd").after('<br style="clear: both;font-size: 0px;line-height: 0px;height: 0px;" />');

var teaserX = 0;
var teaserWidth = 314;
var teaserCurrentNr = 0;
var nrOfTeasers = $(".teasersHTimeline .teaser").size();
var curentTeaserPosition = $(".teasersHTimeline .teaser").index($("#currentPostTeaser"));
var teasersHTimelineWidth = (teaserWidth * nrOfTeasers) + 20 + "px";
/*
if ((curentTeaserPosition > 1) && (curentTeaserPosition < nrOfTeasers-1)){
	$(".teasersHTimeline").css({left: -((curentTeaserPosition-1)*teaserWidth)+"px"});
}else if(curentTeaserPosition = nrOfTeasers-1){
	$(".teasersHTimeline").css({left: -((curentTeaserPosition-2)*teaserWidth)+"px"});
}
*/
/*
if ((curentTeaserPosition<nrOfTeasers+1) > nrOfTeasers){
	$(".teasersHTimeline").css({left: -((curentTeaserPosition-1)*teaserWidth)+"px"});
}
*/
$(".teasersHTimeline").css({'width' : teasersHTimelineWidth});

$("#animGoLeft").addClass('disableArrow');
$("#animGoRight").click(function(){
	//alert(teaserCurrentNr);
	if (teaserCurrentNr >= nrOfTeasers-4){
		//teaserCurrentNr = 0;
		$("#animGoRight").addClass('disableArrow');
	}else{
		$("#animGoRight").removeClass('disableArrow');
		$("#animGoLeft").removeClass('disableArrow');
	}
	if (teaserCurrentNr == nrOfTeasers-3){
	}else{
		teaserCurrentNr++;
	}		
	teaserX = -(teaserCurrentNr * teaserWidth);
	$(".teasersHTimeline").stop().animate( { left: teaserX+"px" }, 1500, "swing" )
});

$("#animGoLeft").click(function(){
	if (teaserCurrentNr <= 1){
		//teaserCurrentNr = nrOfTeasers-3;
		$("#animGoLeft").addClass('disableArrow');
	}else{
		$("#animGoLeft").removeClass('disableArrow');
		$("#animGoRight").removeClass('disableArrow');
	}	
	if (teaserCurrentNr == 0){
	}else{
		teaserCurrentNr--;
	}	
	teaserX = -(teaserCurrentNr * teaserWidth);
	$(".teasersHTimeline").stop().animate( { left: teaserX+"px" }, 1500, "swing" )
});


/*
$("#animGoRight").hover(function(){
		if (teaserCurrentNr == nrOfTeasers-3){
			$("#animGoRight").addClass('disableArrow');
		}
	}, function(){
		if (teaserCurrentNr == nrOfTeasers-3){
			$("#animGoRight").removeClass('disableArrow');
		}
})

$("#animGoLeft").hover(function(){
		if (teaserCurrentNr == nrOfTeasers-3){
			$("#animGoLeft").addClass('disableArrow');
		}
	}, function(){
		if (teaserCurrentNr == nrOfTeasers-3){
			$("#animGoLeft").removeClass('disableArrow');
		}
})
*/




var teasersVX = 0;
var teaserVWidth = 337;
var teaserVCurrentNr = 0;
var nrOfTeasersV = $(".teasersVTimeline .teaser").size();





/* YOUR INVESTMENT */


$(".inputWeddingDate").datepicker();

var inputbtnSubmit = "";
$('#yourInvestmentFieldset > input').focus(function(){
	inputbtnSubmit = $(this).attr('Value')
	$(this).attr('Value', '')
});

$('#yourInvestmentFieldset > input').blur(function(){
	if ($(this).attr('Value') ==''){
		$(this).attr('Value', inputbtnSubmit)
	}
});

/*
$('#yourInvestmentFieldset .btnSubmit').click(function(){

	if ($('.inputName').attr('value') == "Nume"){
		$('.inputName').attr('value', '')
		return false;
	}
	if ($('.inputEmail').attr('value') == "Email"){
		$('.inputEmail').attr('value', '')
		return false;
	}
	if ($('.inputPhone').attr('value') == "Telefon"){
		$('.inputPhone').attr('value', '')
		return false;
	}
	if ($('.inputWeddingDate').attr('value') == "Data nuntii"){
		$('.inputWeddingDate').attr('value', '')
		return false;
	}
	if ($('.inputWeddingLocation').attr('value') == "Locatia"){
		$('.inputWeddingLocation').attr('value', '')
		return false;
	}
	if (($('.contactForm .inputName').attr('value') == "Nume") || ($('.contactForm .inputEmail').attr('value') == "Email") || ($('.contactForm .inputSubject').attr('value') == "Subiect")){
	return false;
	}
})
*/
if ($('#yourInvestmentFieldset > div').hasClass('submitMessageError')){
	$("#optionsStep1").hide();
	$("#optionsStep2").show();
}

if ($('#yourInvestmentFieldset > div').hasClass('submitMessageSuccess')){
	$("#optionsStep1").hide();
	$("#optionsStep2").show();
}
	
if ($(".submitMessageError").length > 0){
	$.scrollTo('#blogCommentsArea,#yourInvestmentContent');
}
	
if ($(".submitMessageSuccess").length > 0){
	$.scrollTo('#blogCommentsArea,#yourInvestmentContent');
}



// YOUR INVESTMENT CALCULATOR
var newOption = 0;
var newOptionClass;
$("#yourInvestmentContent .yourInvestmentRightCol h3").click(function(){
	if ($(this).hasClass("optionSelected")){
		$(this).removeClass("optionSelected");
		newOption = Number($(this).children().children("strong").html());
		$('.yourInvestmentFooter .yourInvestmentFooterLeftCol p span').html( Number($('.yourInvestmentFooter .yourInvestmentFooterLeftCol p span').html()) - newOption )
		newOptionClass = $(this).parent().attr("class");
	

		$(".selectedOptions li").each(function (i) {
			if($(this).hasClass(newOptionClass)){
				$(this).remove();
			}
		});

	}else{
		newOption = Number($(this).children().children("strong").html());
		$('.yourInvestmentFooter .yourInvestmentFooterLeftCol p span').html( Number($('.yourInvestmentFooter .yourInvestmentFooterLeftCol p span').html()) + newOption )
		$(this).addClass("optionSelected");
		$(".selectedOptions").append($(this).parent().clone());
		$('#optionsStep2 .yourInvestmentLeftCol h2 strong').html($(".yourInvestmentFooter .yourInvestmentFooterLeftCol p span").html());
	}
})
$(".yourInvestmentFooter .yourInvestmentFooterRightCol  p.sendOptions").click(function(){
	$("#optionsStep1").hide();
	$("#optionsStep2").show();
});

// -------------------------------------------------------------
/* SOCIAL MEDIA LINK */
$(".socialLinks li a, .frontPageSocialMediaLinks h3 a").hover(function(){
		$(this).children('img').hide();
		$(this).children('img.socialMediaLinkHover').show();
	},function(){
		$(this).children('img').show();
		$(this).children('img.socialMediaLinkHover').hide();
});




/*
-----------------------------------------------
/ Equalize height of the Graphic Teasers on the same line
-----------------------------------------------
*/ 
/*
jQuery(".teasers .textTeaser").each(function (i) {								

		teaserTitleHeight = jQuery(".textTeaser h3").eq(i).height();
		if (teaserTitleHeight < jQuery(".textTeaser h3").eq(i+1).height()){
			teaserTitleHeight = jQuery(".textTeaser h3").eq(i+1).height();
		}
		if (teaserTitleHeight < jQuery(".textTeaser h3").eq(i+2).height()){
			teaserTitleHeight = jQuery(".textTeaser h3").eq(i+2).height();
		}		
		jQuery(".textTeaser h3").eq(i).height(teaserTitleHeight + "px");
		jQuery(".textTeaser h3").eq(i+1).height(teaserTitleHeight + "px");
		jQuery(".textTeaser h3").eq(i+2).height(teaserTitleHeight + "px");		
		
		teaserBodyHeight = jQuery(".textTeaser .textTeaserTxt").eq(i).height();
		if (teaserBodyHeight < jQuery(".textTeaser .textTeaserTxt").eq(i+1).height()){
			teaserBodyHeight = jQuery(".textTeaser .textTeaserTxt").eq(i+1).height();
		}
		if (teaserBodyHeight < jQuery(".textTeaser .textTeaserTxt").eq(i+2).height()){
			teaserBodyHeight = jQuery(".textTeaser .textTeaserTxt").eq(i+2).height();
		}		
		jQuery(".textTeaser .textTeaserTxt").eq(i).height(teaserBodyHeight + "px");
		jQuery(".textTeaser .textTeaserTxt").eq(i+1).height(teaserBodyHeight + "px");
		jQuery(".textTeaser .textTeaserTxt").eq(i+2).height(teaserBodyHeight + "px");


});
*/


/*
-----------------------------------------------
/ Equalize height of the Text Teasers on the same line
-----------------------------------------------
*/ 








// if there are less than three teasers on a row, we need to clear the content or it won't take into consideration the .graphicTeaser{margin-bottom: 10px;}
if(jQuery.browser.msie){
     jQuery(".teasers").append('<br style="clear: both; />"');
}

});