$(document).ready( function(e){
	$("#slideShow .activeSlideShow").cycle({
		fx: 'fade',
		speed: 'slow',
		timeout: 5000
	});
		
	if(jQuery.browser.msie){
		$('#rightPuzzleContainer').ifixpng();
		
		$('img[src$=.png]').each(function(){
			$(this).ifixpng();
		});
	}
	
	if (jQuery.browser.chrome || jQuery.browser.safari || jQuery.browser.opera || (jQuery.browser.mozilla && jQuery.browser.version.toString() == "1.9.1") ){
		$("#webSteroids").css({top:"-7px"});
	}
	
	
	if(jQuery.browser.msie && jQuery.browser.version == 6.0)
	{				
		$(".containerHover").mouseover( function(e){
			var image = $("img[guid='" + $(this).attr("guid") + "']");
			$(image).attr("src", $(image).attr("simg"));
			$(image).ifixpng();
			$("#" + this.id + " > div > a > p").css({color:"#B11C00"});
			$("#" + this.id + " > div > a > h3").css({color:"#B11C00"});
		}).mouseout( function(e){
			var image = $("img[guid='" + $(this).attr("guid") + "']");
			$(image).attr("src", $(image).attr("img"));
			$(image).ifixpng();
			$("#" + this.id + " > div > a > p").css({color:"#124B85"});
			$("#" + this.id + " > div > a > h3").css({color:"#7F88BA"});
		});
		
	}
	else
	{
		$(".topRightContainer").mouseover( function(e){
			var image = $("img[guid='" + $(this).attr("guid") + "']");
			$(image).attr("src", $(image).attr("simg"));
			$(image).ifixpng();
			$("#" + this.id + " > div > a > p").css({color:"#B11C00"});
			$("#" + this.id + " > div > a > h3").css({color:"#B11C00"});
		}).mouseout( function(e){
			var image = $("img[guid='" + $(this).attr("guid") + "']");
			$(image).attr("src", $(image).attr("img"));
			$(image).ifixpng();
			$("#" + this.id + " > div > a > p").css({color:"#124B85"});
			$("#" + this.id + " > div > a > h3").css({color:"#7F88BA"});
		});
	}
	
	
	
	$(".noPuzzle").hover( function(e){
			$(this).addClass("rightPuzzle");
		}, function(e){
			$(this).removeClass("rightPuzzle");
		}
	)

	$(".menuItem").mouseover(function() {
		$("#" + this.id + " > .submenu").show();
	});
	 $(".menuItem").mouseout(function() {
		$("#" + this.id + " > .submenu").hide();
	});

	$(".hashedEmail").each( function() {
			var link = this.rel;
			$(this).text($.base64Decode(link));
			$(this).attr("href", "mailto:" + $.base64Decode(link));			
	});	
	
	$(".need").click(function(){
		if ($(this).hasClass("collapsed")) {
			$(this).removeClass("collapsed");
			$(this).addClass("expanded");							
			$(".solution[guid='" + $(this).attr("guid")+"']").slideDown("slow");
		} else {
			$(this).removeClass("expanded");
			$(this).addClass("collapsed");							
			$(".solution[guid='" + $(this).attr("guid")+"']").slideUp("slow");
		}
		
		return false;
	});
	
	$("input:checkbox").each( function() {
		(this.checked) ? $("#repl"+this.id).addClass('replchecked') : $("#repl"+this.id).removeClass('replchecked');
		$(this).hide();		
	});
	$(".replcheck").click(function(){
		($(this).hasClass('replchecked')) ? $(this).removeClass('replchecked') : $(this).addClass('replchecked');		
		$(this.hash).trigger("click");
		return false;
	});
	
	$(".delete").click(function(){
		var selectedID = $(this).attr("guid");
		var selectedValue = $("p[id='selSol_" + selectedID + "']  > .selectedSolution").text();
		$("p[id='selSol_" + selectedID + "']").hide();
		$("p[id='selSol_" + selectedID + "'] > input[type='hidden']").attr("name", "");
		
		$("#fldOtherOffers > option").each(function() {
	
			if (($(this).text() > selectedValue) && ($(this).text() != ""))
			{				
				$(this).before('<option value="' + selectedID + '" id="sol_' + selectedID + '">' + selectedValue + '</option>');				
				return false;
			}
		});
		
	});
		
	$("#fldOtherOffers").change(function(){
		var selectedID = this.value;
		if (selectedID == "")
			return;
		
		$("p[id='selSol_" + selectedID  + "']").show();
		$("p[id='selSol_" + selectedID  + "'] > input[type='hidden']").attr("name", "fldSolution_" + selectedID );
		$("#sol_" + selectedID).remove();		
		$("#fldOtherOffers").val("");							
		
	});
	
	$("#frmOfferRequest > input[name='fldName']").blur(function(){
		showOptionalFields();
	});
	
	$("#frmOfferRequest > input[name='fldPhone']").blur(function(){
		showOptionalFields();
	});
	
	$("#frmContact > input[name='fldName']").blur(function(){
		showOptionalFields2();
	});
	
	$("#frmContact > input[name='fldPhone']").blur(function(){
		showOptionalFields2();
	});
	
	$("#frmContact > textarea[name='fldMessage']").blur(function(){
		showOptionalFields2();
	});
	
	$("input[name='fldEmail']").blur(function(){
		showOptionalFields();
	});
	
	function showOptionalFields()
	{
		if (
			($("input[name='fldName']").attr("value") != "") &&
			($("input[name='fldPhone']").attr("value") != "")
		   )
		{
			 $("#optionalFields").show();
		}
		
		if ($("input[name='fldEmail']").attr("value") != "")
			$("#newsletter").show();
	}
	
	function showOptionalFields2()
	{
		if (
			($("input[name='fldName']").attr("value") != "") &&
			($("input[name='fldPhone']").attr("value") != "") &&
			($("textarea[name='fldMessage']").attr("value") != "")
		   )
		{
			 $("#optionalFields").show();
		}
	}
	
	$("#frmOfferRequest").ready( function(){
		$("#additionalOffers").show();		
		$("#optionalFields").hide();
		$("#newsletter").hide();		
		showOptionalFields();				
	});

	$("#frmNewsletterForm").ready( function () {
		var field = $("#frmNewsletterForm .error").each(function (index, element) {
			if ($(element).html() != "") {
				$(element).focus();
				return false;
			}			
		});
	});

	$(".solution").hide();
});

function handleClickol1() {
	document.location="/ro/financiar";
}
function handleClickol2() {
	document.location = "/ro/operational";
}
function handleClickol3() {
	document.location = "/ro/piata";
}
function handleClickol4() {
	document.location = "/ro/resurse-umane";
}
function handleClickol5() {
	document.location = "/ro/strategie";
}
function handleClickol6() {
	document.location="/ro/managementul-performantei-organizationale";
}
function handleClickol7() {
	document.location = "/ro/managementul-cunostintelor";
}
function handleClickol8() {
	document.location = "/ro/managementul-informatiilor";
} 