function service_slide() {
	/*if ($.browser.msie && (parseFloat($.browser.version) < 7)) {
		$(".services .block .block_wrapper").addClass("ie-closed");
	}*/
	
   $('a.close').live('click',function(){
      var $this = $(this);
      $('div#' + $(this).attr('rel')).toggle('normal',function(){
         $this.hide();
         $('a.open[rel="'+$this.attr('rel')+'"]').show();
         
         if ($.browser.msie && (parseFloat($.browser.version) < 7)) {
        	 $(this).parent().addClass("ie-closed");
         }
      });
      
      return false;
   });
   
   $('a.open').live('click',function(){
      var $this = $(this);
      $('div#' + $(this).attr('rel') + ' div.cols').show();
      $('div#' + $(this).attr('rel')).toggle('normal',function(){
         $this.hide();
         $('a.close[rel="'+$this.attr('rel')+'"]').show();
      });
      
      if ($.browser.msie && (parseFloat($.browser.version) < 7)) {
    	 $('div#' + $(this).attr('rel')).parent().removeClass("ie-closed");
      };
      
      return false;
   });   
   
   $('h3.service_toggle').live('click',function(){
      var $this = $(this);
      $('div#' + $(this).attr('rel') + ' div.cols').show();
      $('div#' + $(this).attr('rel')).toggle('normal',function() {
    	 $('a.open[rel="'+$this.attr('rel')+'"]').toggle();
         $('a.close[rel="'+$this.attr('rel')+'"]').toggle();
      });
      
      if ($.browser.msie && (parseFloat($.browser.version) < 7)) {
    	 $('div#' + $(this).attr('rel')).parent().removeClass("ie-closed");
      };
      
      return false;
   });
}

function service_slideUp() {
   $('a.close').hide();
   $('a.open').show();
   $('div.add_info div.cols').hide();
   $('div.add_info').slideUp();
   
}

function carousel() {
    $('#carousel').jcarousel({
        // Configuration goes here
    });
}


function ajax_news() {
   $('a.ajax').live('click', function(){
      var url = $(this).attr('href');
      var context = $('div#'+$(this).attr('rel'));
      
      var loading_wrapper = document.createElement('div');
      $(loading_wrapper).addClass('ajax_news_loading_wrapper');
      
      var loading = document.createElement('div');
      $(loading).addClass('ajax_news_loading');
      
      loading.style.width = $(context).width() + 'px';
      loading.style.height = $(context).height() + 'px';
      loading.style.top = '-' + $(context).height() + 'px';
      
      loading_wrapper.appendChild(loading);
      
      $(context).append(loading_wrapper);
      
      $.ajax({
         context : context,
         url : url,
         type : 'POST',
         success : function(data, textStatus, XMLHttpRequest) {
            $(this).html(data);
         }
      });
      
      return false;
   });   
}

function colored () {

	$('table.colored tr').filter(':even').addClass('even');
	
	
	$('ul.colored').each(function(){
		$(this).children('li').filter(':even').addClass('even rc4');
								})
}

function news_images_rc() {
	$(".current_news img").each(function() {
		var rounded = $("<div class=\"rounded rc10\"></div>")
			.css({
				"width" : $(this).width() + "px",
				"height" : $(this).height() + "px",
				"border" : "6px solid #fff",
				"background" : "#fff url(" + $(this).attr("src") + ") no-repeat 50% 50%"
			});
		var wrap = $("<div class=\"wrap\"></div>");
		var rcAlign = $(this).attr("align");
		
		if (rcAlign) {
			switch(rcAlign) {
				case "left": {
					$(wrap).css("float", "left");
					break;
				}
				
				case "right": {
					$(wrap).css("float", "right");
					break;
				}
				
				case "center": {
					$(wrap).css({
						"float" : "none",
						"margin" : "0 auto"
					});
					break;
				}
			}
		}
		
		$(wrap).append(rounded);
		$(this).replaceWith(wrap);
	});
}

function link_icons() {
	$("a[href$='.doc']").addClass("file doc");
	$("a[href$='.xls']").addClass("file xls");
	$("a[href$='.pdf']").addClass("file pdf");
	$("a[href$='.jpg']").addClass("file jpg");
	$("a[href$='.gif']").addClass("file gif");
}

$(window).load(function() {
	$(".rounded").each(function() {
		rocon.update(this);
	});
	/*var shape = new ictinus.Shape("M1.44,0H58.8c0.8,0,1.44,0.64,1.44,1.44v33c0,0.8-0.64,1.44-1.44,1.44H1.44c-0.8,0-1.44-0.64-1.44-1.44v-33C0,0.64,0.64,0,1.44,0z");
	var img = document.getElementById("news_img");
	
	shape.strokeWidth = 10;
	shape.strokeColor = '#FFFFFF';
	//shape.setScaleGrid(10, 100, 10, 100);
	shape.updateSizeBy(img);
	shape.decorate(img);
	ictinus.roundCorners.RADIUS = 6;
	ictinus.roundCorners.DRAW_PARAMS = {
		strokeWidth: 2,
		strokeColor: "#ffffff"
	};
	ictinus.roundCorners(document.getElementById('news_img'));*/
});



function toggleStatus() {
	$(".fincalc .period input[type=radio]").click(function() {
		var isOtherChecked = $(".fincalc .period .toglle").is(":checked") ? false : true
		$(".fincalc .period input.dis").attr("disabled", isOtherChecked);
	});
	
	$(".fincalc .period input.dis").click(function() {
		$(".fincalc .period .toglle").attr("checked", true);
		$(this).attr("disabled", false);
	});
}

$(document).ready(function(){
	service_slide();
	carousel(); 
	ajax_news();
	colored();
	news_images_rc();
	link_icons();
	toggleStatus();
});

