
$(window).resize(function() {
	if($(window).width() < 1100){
		$('.SideBarWrapper').hide();
		$('.ToolBarTopHolder').slideDown();
	} else {
		$('.SideBarWrapper').show();
		$('.ToolBarTopHolder').slideUp();
	}
});


// for acordion
var accordionOptions = {
	  header: "h3",
	  active: false,
	  fillSpace: false,
	  collapsible: true,
	  autoHeight: false,
	  disabled: false,
	  animated: "slide"
	 }
	 
 if($.browser.msie){
	accordionOptions = {
		  header: "h3",
		  active: false,
		  fillSpace: false,
		  collapsible: true,
		  autoHeight: false,
		  disabled: false,
		  animated: false
		 }
 }
 
 //for colapsable module by clicking the header
var actionId = '';
var contentId = '';
var moduleContentId = '';
function clickAction(caller){	
	actionId = $(caller).parent().children('.colapsableAction').children('a').attr('id');
	contentId = $(caller).parent().parent().children('.colapsableContent').attr('id');
	moduleContentId = contentId.substr(0, contentId.lastIndexOf("_")) + "_ModuleContent";
	if (__dnn_ContainerMaxMin_OnClick(document.getElementById(actionId), moduleContentId)) return false;
}

//download document .pdf
function download(portalUrl, caller, subfolder, extension){
	if(caller.options[caller.selectedIndex].value != "-1"){
		var file_link = portalUrl + 'documents/'+subfolder+'/' + caller.options[caller.selectedIndex].value  + '.' + extension;
		win = window.open(file_link,'fileWindow');
		if (window.focus) {win.focus();}
	}
}

var elementWidth = 0;
$(document).ready(function(){
	$(".slider").each(function(index) { makeSlider($(this))});	
	if($(window).width() < 1100){
		$('.SideBarWrapper').hide();
		$('.ToolBarTopHolder').show();
	}
});
function makeSlider(target){
	var elementNo = $(target).children(".viewPort").children(".elementsHolder").children(".slideElement").length;
	elementWidth = $(target).children(".viewPort").children(".elementsHolder").children(".slideElement:first-child").outerWidth(true);
	$(target).children(".viewPort").children(".elementsHolder").css("width", elementNo * elementWidth + "px");
	$(target).children('.sliderRight').click(function(){
		var scrollValue = $(this).parent().children('.viewPort').scrollLeft();
		if(scrollValue <= $(this).parent().children('.viewPort').children('.elementsHolder').outerWidth() - $(this).parent().children('.viewPort').outerWidth()){
			$(this).parent().children('.viewPort').animate({scrollLeft: scrollValue + elementWidth }, 500);
		}
	});
	$(target).children('.sliderLeft').click(function(){
		var scrollValue = $(this).parent().children('.viewPort').scrollLeft();
		$(this).parent().children('.viewPort').animate({scrollLeft: scrollValue - elementWidth }, 500);
	});	
}


$(document).ready(function () {
	jQuery("a.fancyLink").fancybox({
		'width': 600,
		'height': 400		
	});
	
	jQuery("a.fancyBoxbig").fancybox({
		'width': 950,
		'height': 400		
	});
});
function PopUp1(URL) {var l = 121;var t = 119;var w = 600;var h = 500;
	if($.browser.mozilla){
		var windowprops = "location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes" + ",left=" + l + ",top=" + t + ",width=" + w + ",height=" + h;
		popup = window.open(URL,"MenuPopup",windowprops);
	} else {
		$("#fancy-box").attr("href", URL);
		$("#fancy-box").click();
	}	
}

function displayTab(index, caller) {
    var nrOfItems = $(caller).parent().children().length;
    for(var i = 0; i < nrOfItems; i++){
		if(i != index){
			$("#tabNumber\\.id\\[" + i + "\\]").slideUp("slow", function(){
				$("#tabNumber\\.id\\[" + index + "\\]").slideDown();
			});
		}
		
        $("#tabLink\\.id\\[" + i + "\\]").removeClass("tabSelected");
    }
	
    $("#tabLink\\.id\\[" + index + "\\]").addClass("tabSelected");
}

function recomandPage(email, subject, message){
	if(subject == "")
		subject = encodeURIComponent(document.title);
	if(message == "")
		message = "V-a fost recomandat urmatorul link:%0D%0D" + location.href;	
	var mailto_link = 'mailto:'+$(document.getElementById(email)).val()+'?subject='+subject+'&body='+message;
	
	
	win = window.open(mailto_link,'emailWindow');
	if (win && win.open &&!win.closed) win.close();
}
/*
function showArticle(caller, groupClassName){
	var pruductCount = $(".ProductShortInfo:first-child").parent().children(".ProductShortInfo").length;
	if(pruductCount % 2 == 0){
		$(".ProductShortInfo").addClass("Wider");
	}
	//todo: move to another function;
	
	$(".productArt").parent().parent().parent().parent().hide();
	$("."+groupClassName+"").parent().parent().parent().parent().show();
	if($(caller)[0].nodeName == "A"){
		$(caller).parent().parent().parent().children('.ProductShortInfo').children('.ProductName').removeClass("SelectedProduct");
		$(caller).parent().parent().children(".ProductName").addClass("SelectedProduct");
	} 
	
}
*/
function showArticle(caller, groupClassName){
		var pruductCount = $(".ProductShortInfo:first-child").parent().children(".ProductShortInfo").length;
		if(pruductCount % 2 == 0){
			$(".ProductShortInfo").addClass("Wider");
		}
		//todo: move to another function;
		
		$(".productArt").parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent('.DnnModule-dtAccordionModule').slideUp();
		$("div."+groupClassName+"").parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent('.DnnModule-dtAccordionModule').slideDown();
		
		if($(caller)[0].nodeName == "A"){
			$(caller).parent().parent().parent().children('.ProductShortInfo').children('.ProductName').removeClass("SelectedProduct");
			$(caller).parent().parent().parent().children('.ProductShortInfo').fadeTo('fast', 0.3);
			$(caller).parent().parent().children(".ProductName").addClass("SelectedProduct");
			$(caller).parent().parent().fadeTo('fast',1);
			//change page image
			$('img.PageImage').slideUp();
			$('img[forproduct*='+groupClassName+']').slideDown();

			//var ttimer=setTimeout("window.location.hash='mostBottom'",500);
			var ttimer=setTimeout("$(document).scrollTop(($(window).height() + 1000))",500);
			
		} 
		
		
		
		
	} 

function convertMoney(){
	var tvaRate = 0.24;
/*
	var rateEur = $("#eur").text();
	var rateUsd = $("#usd").text();
	var rateAud = $("#aud").text();
	*/
	fromCurr = $("#fromCurr").val();
	toCurr = $("#toCurr").val();
	ammount = parseFloat($("#ammount").val(), 10);
	var rates = [];
	rates['RON'] = 1;
	rates['EUR'] = $("#EUR").text();
	rates['USD'] = $("#USD").text();
	rates['BGN'] = $("#BGN").text();
	rates['CHF'] = $("#CHF").text();
	rates['HUF'] = $("#HUF").text();
	rates['MDL'] = $("#MDL").text();
	rates['RUB'] = $("#RUB").text();
	rates['TRY'] = $("#TRY").text();
	rates['JPY'] = $("#JPY").text();
	
	//alert('fromCurr: '+fromCurr+ '; toCurr: '+toCurr+ '; ammount: '+ ammount + '; rates["eur"]: '+ rates['eur']);
		
	var result = ammount * rates[fromCurr]/rates[toCurr];
	
	if(result.toString() != 'NaN'){
		$('#result').val(result.toFixed(4));
		$('#tva').val((result * tvaRate).toFixed(4));
	}
}
/* butoane control spot casco */
function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}
function StopFlashMovie()
{
	var flashMovie=getFlashMovieObject("spot");
	flashMovie.StopPlay();
	$(".flashPlayBtn").show();
	$(".flashStopBtn").hide();
}
 
function PlayFlashMovie()
{
	var flashMovie=getFlashMovieObject("spot");
	flashMovie.Play();
	$(".flashPlayBtn").hide();
	$(".flashStopBtn").show();
}
































