//function calcHeight()
//{
  //find the height of the internal page
//  var the_height=
//    document.getElementById('ifrSc').contentWindow.
//      document.body.scrollHeight;
  //change the height of the iframe
//  document.getElementById('ifrSc').height=
//      the_height;
//}
$(document).ready( function() {
	
	
	if($("#hgt_stire") != undefined || $("#hgt_stire") != null && $(".ul_stiri_h2")) {
		var hgt = $("#hgt_stire").height();
		if($.browser.msie && $.browser.version.substr(0,1)<=7) {
			var abs_top = hgt + 125;
		}else {
			var abs_top = hgt + 135;
		}
		$(".ul_stiri_h2").attr("style","top: "+abs_top+"px;");
		var hgt_inst = $(".ul_stiri_h2").height();
		
		
	}
	
	$(".trigger_scor_fadein").click(function(){
		
		if($.browser.msie && $.browser.version.substr(0,1)<=7) {
			document.location = '/scoring/index';
			return false;
		}
		$(".trigger_scor_box").fadeIn("fast");
		
		$("body").append("<div id='blackBg'></div>");
		$("#blackBg").css({ "position":"absolute", "width":$("body").width(), "height":$("body").height()+475, 
					"background":"#999", "z-index":"100000", "top":"0px", "left":"0px", 
					"filter":"alpha(opacity=40)", "opacity":"0.40"});
		$(".view_none").css({ "display" : "block" });
		$('<iframe id="ifrSc" name="ifrSc" src="/scoring/index#mod=true" width="976" height="1500" scrolling="no" frameborder="0" style="margin: 0 0 -3px 1px"></iframe>').appendTo(".incarca_ifr");
	});

	// pozitionare elemente header in functie de leaderboard
	if($("#leaderboard_wrapper").height() > 0) {
		if ($("#getActionNameCnt").height() >= 0 && $("#getActionNameCnt").height() != null){
			$("#content").css("margin-top","170px");
		} else if ($(".menuzone").height() >= 0) {
			$("#content").css("margin-top","189px");
		} else {
			$("#content").css("margin-top","150px");
		} 
		//$("#content").css("margin-top","150px");
		$("#meniu_container").css("top", "-45px");
		$("#header a.logo").css("margin-top" , "70px");
		$("#meniu_container").css("top", "142px");
	} else {
		if ($("#getActionNameCnt").height() >= 0 && $("#getActionNameCnt").height() != null){
			$("#content").css("margin-top","100px");
		}else {
			$("#meniu_container").css("top", "77px");		
			$("#content").css("margin-top", "123px");
		}
	}
	
	// top-ul coloanei din dreapta, in funtie de boxul de filtrare
	if($(".filtrare").height() > 0) {
		$(".colright_170").css("top", "175px");
		$(".colright_170").css("margin-top", "0px");
	}else if ($(".filtrare").height() < 0 || $(".filtrare").height() == null || $(".filtrare").height() == undefined) {
		
		$(".colright_170").css("top", "60px");
		$(".colright_170").css("margin-top", "0px");
	}
	
	// ie6
	if( $.browser.msie && $.browser.version.substr(0,1) == 6) {
		if($(".col_listing").height() > $(".colright_170").height()) {
			$(".colright_170").height( $(".col_listing").height() );
		}
	}
	if($(".col_200").height() > $(".col_400").height()) {
		$(".col_400").height( $(".col_200").height() );
	}

/*	
	//MENIU PRINCIPAL OLD
	//
	// Mai intai scanez meniul orizontal pentru a sti care radio sa-l bifez
	$(".meniu_a").each( function (i) {
		if($(this).is(":visible")) {
			$("." + $(this).attr("id")).attr("checked", "checked");
			updateFormCautareHome($(this).attr("id"));
		}
	});
	
	// schimb meniul in fnctie de target
	$("#selectie_target input").click ( function () {
		$(".meniu_a").hide();
		$("#" + $(this).attr("class")).show();
		updateFormCautareHome($(this).attr("class"));
	});
	
	updateFormCautareHome('meniu_persoane_fizice');
	
	// activez dropul
	$('li.meniu.orizontal').hover(
		function() { $('ul', this).css('display', 'block'); },
		function() { $('ul', this).css('display', 'none'); 
	});
	
    //
	//END MENIU PRINCIPAL OLD
	//
*/

	
	//MENIU PRINCIPAL NEW
	
	$(".lft_meniu").each( function (i) {
		if($(this).is(":visible")) {
			$("." + $(this).attr("id")).attr("checked", "checked");
			updateFormCautareHome($(this).attr("id"));
		}
	});
	
		updateFormCautareHome('meniu_persoane_fizice');
	
	// activez dropul
		$('.lft_submeniu_box').css('display','none');
		$('ul.lft_meniu li.item').hover(function(){ 
			$('.lft_submeniu_box', this).css('display', 'block'); 
		}, function(){
			$('.lft_submeniu_box', this).css('display', 'none'); 
		});
		
		$('ul.rgt_meniu li.item').hover(function(){ 
			$('.rgt_pos_submeniu_box', this).css('display', 'block'); 
		}, function(){
			$('.rgt_pos_submeniu_box', this).css('display', 'none'); 
		});
		
	//MENIU PRINCIPAL NEW
		
		//tooltip calculatoare salarii
		$('.pos_abs_cntr', this).css('display', 'none');
		$('.qtip_img_box').hover(
		function(){
			$('.pos_abs_cntr', this).css('display', 'block');
		},
		function() {
			$('.pos_abs_cntr', this).css('display', 'none');
		}
		);
	

	
	//										BOX NEWSLETTER
	//
	$('#display_box_abonare_newsletter').click( function () {
		$('.login_box').slideUp(700);
		$('.newsletter_box').slideDown(700);
		$('.newsletter_box').addClass('overNewsletterBox');
		//$('.newsletter_box').show('slow');
	});
	
	// adaug o clasa care sa verifice daca am cursorul in input, iar la hoverOut ascund boxul dc nu are aceasta clasa
	$('.signupEmail').focus( function() {
		$('.signupEmail').addClass('focused');
	})
	$('.signupEmail').blur( function() {
		$('.signupEmail').removeClass('focused');
	})
	
	$('.close_news').click ( function () {
		$('.newsletter_box').slideUp(700);
		$('.login_box').slideUp(700);
	});	
/*	$('.newsletter_box').hover(
		function () {
			$('.newsletter_box').addClass('overNewsletterBox');
		}, 
		function() {
			$('.newsletter_box').removeClass('overNewsletterBox');
			if(!$('.newsletter_box').hasClass('overNewsletterBox') && !$('.signupEmail').hasClass('focused')) {
				$('.newsletter_box').slideUp(700);
			}
			//$('.newsletter_box').hide('slow');
		}
	); 
	$('body').click( function () {
		if(!$('.newsletter_box').hasClass('overNewsletterBox')) {
			$('.newsletter_box').slideUp(700);
		}
	});     */
	
	// actiunea de aplica
	$('#aboneaza_ma').click ( function () {
		$('.infoAbonare').show();

		var signupEmail = $('.signupEmail').val();
		var emailFilter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
		
		if(!emailFilter.test(signupEmail)){
			$('.infoAbonare').html('Email invalid!'); //addClass('smallError').
		} else {
			//$('.infoAbonare').html('Corect!');
			//window.location = '/newsletter/abonare'; 
			$.ajax({
				type: 'POST',
				dataType: "html",
				data: 'email=' + signupEmail,
				url: '/newsletter/signup',
				success: function(msg){
						trimMsg = trim(msg);
						if(trimMsg == 'succes') {
							$('.infoAbonare').html('Email inregistrat cu succes!');
							setTimeout(function () {
								$('.infoAbonare').hide();
								$('.signupEmail').val("");
								$('.newsletter_box').slideUp(700);
							}, 2000);
							return false;
						} else if (trimMsg == 'exista') {
							$('.infoAbonare').html('Email existent!');
							return false;
						} else {
							$('.infoAbonare').html('Eroare! Reincercati.');
							return false;
						}						
			   	}
			});
		}
	});
	//
	//									END BOX NEWSLETTER
	
	
	/*
	 * LOGIN UTILIZATOR
	 */
	$("#loginLink").click( function () {
		//$(".login_box").toggle();
		$('.newsletter_box').slideUp(700);
		$('.login_box').slideDown(700);
		$('.login_box').addClass('overLoginBox');
	});
	
	$("#emailLogin").focus( function () {
		$("#emailLogin").addClass("focused");
	});
	$("#parolaLogin").focus( function () {
		$("#parolaLogin").addClass("focused");
	});
/*	$('.login_box').hover(
			function () {
				$('.login_box').addClass('overLoginBox');
			}, 
			function() {
				$('.login_box').removeClass('overLoginBox');
				if(!$('.login_box').hasClass('overLoginBox') && !$("#emailLogin").hasClass("focused") && !$("#parolaLogin").hasClass("focused") ) {
					$('.login_box').slideUp(700);
				}
				//$('.newsletter_box').hide('slow');
			}
		);
	$('body').click( function () {
		if(!$('.login_box').hasClass('overLoginBox')) {
			$('.login_box').slideUp(700);
		}
	});   */
	/*
	 * END LOGIN UTILIZATOR
	 */
	
	// FORM CAUTARE
	//updateNrProduse("formCredite");// se updateaza la actualizarea meniului
	$(".listaProduse").change( function () {
		var idForm = $(this).parent().attr("id");
		
		updateNrProduse()
	});
	$(".inputSuma").change( function () {
		var idForm = $(this).parent().attr("id");
		
		updateNrProduse();
	});
	// END FORM CAUTARE
	
	/*************** banner expandabil alpha header **************/
	
		$('#leaderboard_wrapper').mouseover(function () {
			//$(this).css("height", '200px');			
			//$(this).css("position", 'relative');			
			//$(this).css("z-index", '1000');			
		});		
		
		$('#leaderboard_wrapper').click(function () {
			//$(this).css("height", '91px');		
		});	
	
		//schimbat buton de "Afiseaza" in filtre produse
		$("#id_inst, #sort").change(function () {
			$(".afiseaza").removeClass("afisare_listing");
			$(".afiseaza").addClass("afisare_listing_activ");
		});
		
		
		// /produse/infoCredite
		// run code
//	  	$(".put_listing").css("text-align", "center").html('<img src="/images/loader-8.gif" alt="loader" style="margin: 0 0 0 10px;"/>');
//	  	var list = $("#listPtS").val();
//	  	$.ajax({
//			type: "POST",
//			url: "/produse/ajaxGetListingInfo?list="+list,
//			dataType: "html",
//			success: function(html){
//				if($.browser.msie && $.browser.version.substr(0,1)<=7) {
//					document.getElementById("putListing").innerHTML = html;
//					$("span.aplica_listing").css("margin-left", "15px");
//				} else {
//					$(".put_listing").html(html);
//					$(".div_sortare").html("");
//					$(".pagination").css("display", "block");
//					$(".pagination ul li.1").addClass("currentpage");
//					$("label.vertical_text").css("width", "20px");
//					$(".colright_170").css("margin-top", "-940px");
//					$(".aplica_listing").css("margin-left", "15px");
//					$(".expand_prod_list_detalii").css("display", "none");
//				}
//			}
//		});
//  		$("#procent_avans").bind("keyup", function () { buttonRecalc($("#procent_avans").val()) });
//  		$("#id_currency").bind("click", function () { buttonRecalc($("#id_currency").val()) });
//  		$("#perioada_maxima").bind("click", function () { buttonRecalc($("#perioada_maxima").val()) });
//  		$("#emitent").bind("click", function () { buttonRecalc($("#emitent").val()) });
//  		$("#rata_dobanzii").bind("keyup", function () { buttonRecalc($("#rata_dobanzii").val()) });
//  		$("#suma_maxima").bind("keyup", function () { buttonRecalc($("#suma_maxima").val()) });
//  		$("#dae").bind("keyup", function () { buttonRecalc($("#dae").val()) });
//  		$("#valoare_bun").bind("keyup", function () { buttonRecalc($("#valoare_bun").val()) });
//  		$(".grad_indatorare").bind("keyup", function () { buttonRecalc($(".grad_indatorare").val()) });
//  		getQtip();
		
		if($.browser.msie && $.browser.version.substr(0,1)<=7 && $("#putListing").height() > 0 && $("#putListing").height() != null) {
			document.getElementById("putListing").innerHTML = html;
			$("span.aplica_listing").css("margin-left", "15px");
		} else if( $("#putListing").height() > 0 && $("#putListing").height() != null) {
			$(".div_sortare").html("");
			$(".pagination").css("display", "block");
			$(".pagination ul li.1").addClass("currentpage");
			$("label.vertical_text").css("width", "20px");
			$(".colright_170").css("margin-top", "-940px");
			$(".aplica_listing").css("margin-left", "15px");
			$(".expand_prod_list_detalii").css("display", "none");
			$(".detalii_prod_but").css({"margin" : "30px 0 0 14px", "display" : "block", "width": "55px"});
		} else if($.browser.msie && $.browser.version.substr(0,1)<=7 && $("#putListing").height() == null) {
			$(".colright_170").css({"position" : "relative", "top" : "0px"});
		}
});
function paginationAjax(pg) {
	var list = $("#listPtS").val();
	var maxPerPage = '10';
	$.ajax({
		type: "POST",
		url: "/produse/ajaxGetListingInfo?list="+list+"&page="+pg,
		dataType: "html",
		beforeSend: function(){
			$(".put_listing").css("text-align", "center").html('<img src="/images/loader-8.gif" alt="loader" style="margin: 0 0 0 10px;"/>');
//			$(".result1").html('<img src="/images/loader-7.gif" alt="loader" style="margin: 0 0 0 10px;"/>');
		},
		success: function(html){
			if($.browser.msie && $.browser.version.substr(0,1)<=7) {
				document.getElementById("putListing").innerHTML = html;
			} else {
				$(".put_listing").html(html);
				$(".div_sortare").html("");
				$(".pagination").css("display", "block");
				$(".pagination ul li").removeClass("currentpage");
				$(".pagination ul li."+pg).addClass("currentpage");
				$("label.vertical_text").css("width", "20px");
				$(".colright_170").css("margin-top", "-940px");
				$(".aplica_listing").css("margin-left", "15px");
				$(".expand_prod_list_detalii").css("display", "none");
			}
		}
	});
	//if
	//$("#Pagination").html('');
	

	
}

function setFlashHeight(){
	$('#leaderboard_wrapper').css("height", '91px');
	$('#leaderboard_wrapper').css("overflow", 'hidden');		
}
function setFlashOver(){
	$('#leaderboard_wrapper').css("height", '200px');
	$('#leaderboard_wrapper').css("position", 'relative');		
	$('#leaderboard_wrapper').css("z-index", '1000');		
}
function setBtnClose(){
	$('.close_button_flash').css("display", 'none');	
}

/*************** banner expandabil alpha header END **************/

function updateNrProduse(){
	// html loader
	htmlLoader = "<span><img src='http://static.efin.ro/imagesV2/loader.gif' /></span> OFERTE";
	$('.nr_oferte').html(htmlLoader);
	
	var idForm = $(".formCautare:visible").attr("id");
	
	// trag valoare drop
	var productCat = $("#" + idForm + " .listaProduse").val();
	
	// se selecteaza currency-ul pe credit
	//var arr_curr_credit = ['/credite/credite_nevoi_personale', '7','/credite/credite_de_consum_cu_ipoteca', '9','/credite/credite_rapide', '7', '/credite/credite_in_magazin', '7', '/credite/credite_auto', '9', '/credite/credite_ipotecare', '9', '/credite/credite_imobiliare', '9', '/credite/prima_casa', '9', '/credite/refinantare_consum', '7', '/credite/refinantare_ipotecar', '9', '/credite/credite_studii', '9', '/credite/credite_turistice', '7', '/credite/credite_tratamente_medicale', '9' ];
	//$("div #arr_currency:eq(0)").text(jQuery.inArray("/credite/credite_in_magazin", arr_curr_credit)).val();
	//var index_mon_credit = jQuery.inArray($('.activeSelect').attr("id"), arr_curr_credit) + 1;
	//$(".currency_form_credit").val(arr_curr_credit[index_mon_credit]);
	
	
	// se selecteaza currency-ul pe depozit
	//var arr_curr_depozit = ['/depozite_bancare/cont_de_acumulare', '7','/depozite_bancare/depozite_la_termen', '7'];
	//$("div #arr_currency:eq(0)").text(jQuery.inArray("/credite/credite_in_magazin", arr_curr_depozit)).val();
	//var index_mon_depozit = jQuery.inArray($('.activeSelect').attr("id"), arr_curr_depozit) + 1;
	//$(".currency_form_depozit").val(arr_curr_depozit[index_mon_depozit]);
	
	
	
	// trag valoare suma
	var suma = parseInt($("#" + idForm + " .inputSuma").val());	
	productPath = productCat + "?c_t=nrRezultate";
	if (/^\d+$/.test(suma)){
		productPath = productPath + '&suma_maxima=' + suma + '&commit=Afiseaza';
	} else {
		productPath = productPath + '&resetFilter=true';
	}
	
	$.ajax({
		type: 'GET',
		dataType: "html",
		//data: 'emailLogin=' + emailLogin + '&parolaLogin=' + parolaLogin,
		url: productPath,
		success: function(msg){
			$('.nr_oferte').html(msg);
			return false;
	   	}
	});
	//alert(productPath);
	//window.location = productPath;
}

function cautaProduse(formId) {
	var ptype = $("#" + formId + " .listaProduse").val();
	var suma = $("#" + formId + " .inputSuma").val();

	if(suma == '') {
		$(".infoFormProduse").html("<b>EROARE!</b> Trebuie sa completati suma!");
	} else if(suma.indexOf(".") != -1) {
		$(".infoFormProduse").html("<b>EROARE!</b> Caracter nepermis: <b>.</b>");
	} else if (suma.indexOf("%") != -1) {
		$(".infoFormProduse").html("<b>EROARE!</b> Caracter nepermis: <b>%</b>!");
	} else if (suma.length > 9 && /^\d+$/.test(suma)) {
		$(".infoFormProduse").html("<b>EROARE!</b> Introduceti maxim 9 cifre!");
	} else {
		if (!/^\d+$/.test(suma)){
			suma = '';
		}
		
	if($("#RezCurrCredit").text() != '') {
		if($("#RezCurrCredit").text() == 'RON') {
			var idCurr = 7;
		} else if($("#RezCurrCredit").text() == "EUR") {
			var idCurr = 9;
		}
		var searchPath = ptype + '?suma_maxima=' + suma + '&id_currency='+ idCurr + '&commit=Afiseaza';
	} else {
		var searchPath = ptype + '?suma_maxima=' + suma + '&commit=Afiseaza';
	}	
	
		window.location = searchPath;
		return false;
	}
}

function updateFormCautareHome(idTarget) {
	// dc nu e vizibil box-ul anulez executia functiei
	if( $("#box_cautare").size() < 1) {
		return false;
	}
	
	var arrayDropuriCredite = { 
			'meniu_persoane_fizice' : '<option value="/credite/credite_nevoi_personale">Nevoi Personale</option><option value="/credite/credite_de_consum_cu_ipoteca">Nevoi Personale cu Ipoteca</option><option value="/credite/credite_rapide">Rapide</option><option value="/credite/credite_in_magazin">Credite in Magazin</option><option value="/credite/credite_auto">Auto</option><option value="/credite/credite_ipotecare">Ipotecare</option><option value="/credite/credite_imobiliare">Imobiliare</option><option value="/credite/prima_casa">Prima Casa</option><option value="/credite/refinantare_consum">Refinantare Consum</option><option value="/credite/refinantare_ipotecar">Refinantare Ipotecar</option><option value="/credite/credite_studii">Studii</option><option value="/credite/credite_turistice">Turistice</option><option value="/credite/credite_tratamente_medicale">Tratamente Medicale</option>',
			'meniu_imm_pfa' : '<option value="/credite/linie_de_credit">Linii de credit</option><option value="/credite/credite_de_investitii_imm_pfa">Investitii</option><option value="/credite/credite_echipamente">Pentru echipamente</option><option value="/credite/credite_pe_termen_scurt_imm_pfa">Pe termen scurt</option><option value="/credite/credite_fara_garantii">Fara garantii</option><option value="/credite/fonduri_structurale_imm_pfa">Fonduri structurale</option>',
			'meniu_companii' : '<option value="/credite/linii_credit_companii">Linii de credit</option><option value="/credite/credite_de_investitii_companii">Investitii</option><option value="/credite/credite_pe_termen_scurt_companii">Pe termen scurt</option><option value="/credite/fonduri_structurale_companii">Fonduri structurale</option>'
	};
	var arrayDropuriDepozite = { 
			'meniu_persoane_fizice' : '<option value="/depozite_bancare/cont_de_acumulare">Cont de acumulare</option><option value="/depozite_bancare/depozite_la_termen" selected="selected">La termen</option>',
			'meniu_imm_pfa' : '<option value="/depozite_bancare/cont_curent_imm_pfa">Cont Curent</option><option value="/depozite_bancare/depozite_la_termen_imm_pfa">La termen</option>',
			'meniu_companii' : '<option value="/depozite_bancare/depozite_la_termen_companii">La termen</option>'
	};
	$("#listaCredite").html(arrayDropuriCredite[idTarget]);
	$("#listaDepozite").html(arrayDropuriDepozite[idTarget]);
	updateNrProduse();
}

function makeLogin() {
	$(".infoLogin").html("Incarc...");
	var emailLogin = $("#emailLogin").val();
	var parolaLogin = $("#parolaLogin").val();
	
	var emailFilter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var userFilter = /^[\+\(\)\_\.\s(a-z)\s(A-Z)\s(0-9)]{0,200}$/;

	if (userFilter.test(emailLogin) == true) {
		$.ajax({
			type: 'POST',
			dataType: "html",
			data: 'userLogin=' + emailLogin + '&parolaLogin=' + parolaLogin,
			url: '/utilizatori/shortAuth',
			success: function(msg){
				if(msg == 'redirect_login') {
					$('.infoLogin').html('Va rugam introduceti Utilizatorul si Parola corespunzatoare!');
					window.location = "/institutii/login";
					return false;
				} else if (msg == 'redirect_index') {
					window.location = "/superadmin/index";
					return false;
				} else if (msg == 'redirect') {
					window.location = "/index/index";
					return false;
				} else if (msg != '') {
					
					window.location = "/statistics/institutie/id/"+ msg;
					return false;	
				} else {
					$('.infoLogin').html('Eroare! Reincercati.');
					return false;
				}						
		   	}
		});
	} else if(!emailFilter.test(emailLogin)){
		$('.infoLogin').html('Email invalid!');
	} else if (emailLogin == '' || parolaLogin == '') {
		$('.infoLogin').html('Date invalide!');
	} else {
		$.ajax({
			type: 'POST',
			dataType: "html",
			data: 'emailLogin=' + emailLogin + '&parolaLogin=' + parolaLogin,
			url: '/utilizatori/shortAuth',
			success: function(msg){
					if(msg == 'succes') {
						$('.infoLogin').html('Autentificat cu succes!');
						window.location = "/utilizatori/tickets";
						return false;
					} else if (msg == 'autentificat') {
						$('.infoLogin').html('Esti deja autentificat! Vei fi redirectat..');
						return false;
					} else {
						$('.infoLogin').html('Eroare! Reincercati.');
						return false;
					}						
		   	}
		});
	}
	
}

// functie pt managementul taburilor
function openTab(idToOpen, classToClose, tabLinkClass, tabLinkId) {
	// ascund taburile de continut
	$("." + classToClose).hide();
	// deschid tab-ul asociat link-ului pe care s-a dat click
	$("#" + idToOpen).show();
	// sterg clasa link-ului default
	$("." + tabLinkClass).removeClass("activ");
	// adaug clasa de activ link-ului pe care s-a dat click
	$("#" + tabLinkId).addClass("activ");
}

//functie link-uri footer
function goTo(baseUrl, key) {
	var links = { 'feedback':'/info/feedback',
					'publicitate' : '/info/publicitate_cu_efin_ro',
					'contact' : '/info/servicii',
					'widget' : '/info/listing-credite',
					'termeni' : '/info/termeni-si-conditii',
					'use' : '/info/terms_of_use',
					'credite' : '/credite/credite_nevoi_personale',
					'carduri' : '/carduri/carduri_de_credit',
					'leasing' : '/leasing/leasing_auto',
					'depozite' : '/depozite_bancare/depozite_la_termen',
					'credite_imm' : '/credite/linie_de_credit',
					'carduri_imm' : '/carduri/carduri_de_credit_imm_pfa',
					'leasing_imm' : '/leasing/leasing_auto_imm_pfa',
					'depozite_imm' : '/depozite_bancare/depozite_la_termen_imm_pfa',
					'credite_companii' : '/credite/linii_credit_companii',
					'carduri_companii' : '/carduri/carduri_de_credit_companii',
					'leasing_companii' : '/leasing/leasing_auto_companii',
					'depozite_companii' : '/depozite_bancare/depozite_la_termen_companii',
					'factoring_companii' : '/factoring/factoring_companii',
					'stiri' : '/articole/stiri',
					'articole' : '/articole',
					'evenimente' : '/evenimente_financiare/',
					'institutii' : '/institutii_financiare/',
					'glosar' : '/glosar_economic/'
	};	
	window.location = baseUrl + links[key];
}
 
function goToAplica(id, referer, utmCampaign, utmMedium, utmSource, utmContent, perioada, suma, dae, emitent) {
	baseUrl = '/produse/aplica/';
	if(referer != '') {
		if(perioada != '0' || suma != '0' || dae != '0' || emitent != '0') {
			window.location = baseUrl + id + '?&referer=' + referer + '&utm_campaign=' + utmCampaign + '&utm_medium=' + utmMedium + '&utm_source=' + utmSource + '&utm_content=' + utmContent + '&perioada=' + perioada + '&suma=' + suma + '&dae=' + dae + '&emitent='+emitent;
		} else {
			window.location = baseUrl + id + '?&referer=' + referer + '&utm_campaign=' + utmCampaign + '&utm_medium=' + utmMedium + '&utm_source=' + utmSource + '&utm_content=' + utmContent;
		}
	} else if(referer == '' && perioada != '0' || suma != '0' || dae != '0' || emitent != '0') {
		window.location = baseUrl + id + '?&perioada=' + perioada + '&suma=' + suma + '&dae=' + dae + '&emitent='+emitent;
	} else {	
		window.location = baseUrl + id;
	}
}

function goToStire(link) {
	baseUrl = "http://www.efin.ro";
	window.location = baseUrl + link;
}

function goToCms(link, baseUrl) {
	if(!baseUrl) {
		baseUrl = "http://www.efin.ro";
	}
	window.location = baseUrl + link;
}

function goToProdus(link, perioada, suma, dae) {
	if(perioada != '0' || suma != '0' || dae != '0') {
		window.location = link+'?&perioada='+perioada+'&suma='+suma+'&dae='+dae;
	} else {
		window.location = link;
	}
}

function sortInst(link, id_inst, afisare, query) {
	if(id_inst != '0' && afisare == 'nu') {
		window.location = link + '?id_inst='+id_inst;
	} else {
		window.location = link + '?' + query + '&id_inst='+id_inst;
	}
}

// functie pentru executare la onSubmit
function onSubmitSearchForm(host) {
	window.location = host + "/" + document.searchForm.termen.value.replace(" " , "+") +"-.html";
}

//functie pentru grafic rambursare produse
function goToGraficRambursare(cat) {
	if(cat == 'credite') {
		suma = $('#amount-suma').val();
		perioada = $('#amount-perioada').val();
		dobanda = $(".showDob").val();
		link = '/credite/calculator-rate-credit';
		href=link + "?suma=" + suma + "&dobanda=" + dobanda + "&perioada_rambursare=" + perioada + "&load=true";
		window.open(this.href);
		
		
		//location.href='/credite/calculator-rate-credit?suma=$(\'#amount-suma\').val()&dobanda=<?php echo $dobanda; ?>&perioada_rambursare=<?php echo $perioada_rambursare; ?>&load=true'
	} else if (cat == 'depozite') {
		suma = $('#amount-suma').val();
		dobanda = $(".showDob").val();
		maturitate = $('#maturitate').val();
		link = '/depozite/calculator-depozite';
		window.location = link + "?suma=" + suma + "&dobanda=" + dobanda + "&maturitate=" + maturitate + "&load=true";
		
		//location.href='/depozite/calculator-depozite?suma=<?php echo $suma; ?>&dobanda=<?php echo $dobanda; ?>&maturitate=<?php echo $perioada_rambursare; ?>&load=true';"
	}
}

//functie pentru link catre pagina de lista ghiduri
function goToGhidList(title, link) {
	window.location = link;
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
