var isMSIE = /*@cc_on!@*/false;
var IE6=(navigator.userAgent.toLowerCase().indexOf('msie 6') != -1)
var IE7=(navigator.userAgent.toLowerCase().indexOf('msie 7') != -1)


$(function(){   
   $(".newsev ul li").hover(function(){  
        $(this).addClass("hoverS");  
    },
	function(){    
        $(this).removeClass("hoverS");  
    });
    
});

$(function(){   
   $(".tabs li").hover(function(){  
        $(this).addClass("hoverS");  
    },
	function(){    
        $(this).removeClass("hoverS");  
    });
    
});

$(function(){   
   $(".head2 ul.ul1 li").hover(function(){  
        $(this).addClass("hoverS");  
    },
	function(){    
        $(this).removeClass("hoverS");  
    });
    
});


$(function(){   
   $(".head2 ul.ul2 li").hover(function(){  
        $(this).addClass("hoverS");  
    },
	function(){    
        $(this).removeClass("hoverS");  
    });
    
});

$(function(){   
   $(".menuPage li").hover(function(){  
        $(this).addClass("hoverM");  
    },
	function(){    
        $(this).removeClass("hoverM");  
    });
    
});

 //SELECT BOX

jQuery.fn.extend({
	selectbox: function(options) {
		return this.each(function() {
			new jQuery.SelectBox(this, options);
		});
	}
});

if (!window.console) {
	var console = {
		log: function(msg) { 
	 }
	}
}

jQuery.SelectBox = function(selectobj, options) {	
	var opt = options || {};
	opt.inputClass = opt.inputClass || "selectbox";
	opt.containerClass = opt.containerClass || "selectbox-wrapper";
	opt.hoverClass = opt.hoverClass || "current";
	opt.currentClass = opt.selectedClass || "selected"
	opt.debug = opt.debug || false;
	
	var elm_id = selectobj.id;
	var active = -1;
	var inFocus = false;
	var hasfocus = 0;
	//jquery object for select element
	var $select = $(selectobj);
	// jquery container object
	var $container = setupContainer(opt);
	//jquery input object 
	var $input = setupInput(opt);
	// hide select and append newly created elements
	$select.hide().before($input).before($container);
	
	init();
	
	$input
	.click(function(){
    if (!inFocus) {
		  $container.toggle();
		}
	})
	.focus(function(){
	   if ($container.not(':visible')) {
	       inFocus = true;
	       $container.show();
	   }
	})
	.keydown(function(event) {	   
		switch(event.keyCode) {
			case 38: // up
				event.preventDefault();
				moveSelect(-1);
				break;
			case 40: // down
				event.preventDefault();
				moveSelect(1);
				break;
			//case 9:  // tab 
			case 13: // return
				event.preventDefault(); // seems not working in mac !
				$('li.'+opt.hoverClass).trigger('click');
				break;
			case 27: //escape
			  hideMe();
			  break;
		}
	})
	.blur(function() {
		if ($container.is(':visible') && hasfocus > 0 ) {
			if(opt.debug) console.log('container visible and has focus')
		} else {
			hideMe();	
		}
	});


	function hideMe() { 
		hasfocus = 0;
		$container.hide(); 
	}
	
	function init() {
		$container.append(getSelectOptions($input.attr('id'))).hide();
		//var width = $input.css('width');
		//$container.width(width);
    }
	
	function setupContainer(options) {
		var container = document.createElement("div");
		$container = $(container);
		$container.attr('id', elm_id+'_container');
		$container.addClass(options.containerClass);
		
		return $container;
	}
	
	function setupInput(options) {
		var input = document.createElement("input");
		var $input = $(input);
		$input.attr("id", elm_id+"_input");
		$input.attr("type", "text");
		$input.addClass(options.inputClass);
		$input.attr("autocomplete", "off");
		$input.attr("readonly", "readonly");
		$input.attr("tabIndex", $select.attr("tabindex")); // "I" capital is important for ie
		
		return $input;	
	}
	
	function moveSelect(step) {
		var lis = $("li", $container);
		if (!lis) return;

		active += step;

		if (active < 0) {
			active = 0;
		} else if (active >= lis.size()) {
			active = lis.size() - 1;
		}

		lis.removeClass(opt.hoverClass);

		$(lis[active]).addClass(opt.hoverClass);
	}
	
	function setCurrent() {	
		var li = $("li."+opt.currentClass, $container).get(0);
		var ar = (''+li.id).split('_');
		var el = ar[ar.length-1];
		$select.val(el);
		$input.val($(li).html());
		return true;
	}
	
	// select value
	function getCurrentSelected() {
		return $select.val();
	}
	
	// input value
	function getCurrentValue() {
		return $input.val();
	}
	
	function getSelectOptions(parentid) {
		var select_options = new Array();
		var div = document.createElement('div');
		var ul = document.createElement('ul');
		$select.children('option').each(function() {
			var li = document.createElement('li');
			li.setAttribute('id', parentid + '_' + $(this).val());
			li.innerHTML = $(this).html();
			if ($(this).is(':selected')) {
				$input.val($(this).html());
				$(li).addClass(opt.currentClass);
			}
			
			ul.appendChild(li);
			$(li)
			.mouseover(function(event) {
				hasfocus = 1;
				if (opt.debug) console.log('over on : '+this.id);
				jQuery(event.target, $container).addClass(opt.hoverClass);
			})
			.mouseout(function(event) {
				hasfocus = -1;
				if (opt.debug) console.log('out on : '+this.id);
				jQuery(event.target, $container).removeClass(opt.hoverClass);
			})
			.click(function(event) {
			  var fl = $('li.'+opt.hoverClass, $container).get(0);
				if (opt.debug) console.log('click on :'+this.id);
				$('li.'+opt.currentClass).removeClass(opt.currentClass); 
				$(this).addClass(opt.currentClass);
				setCurrent();
				hideMe();
			});
		});
		return ul;
	}
	
};

///RADIO BUTON CUSTOM PRODUCT PAGE

$(document).ready(function(){
    $("#license label").click(function () {
    $("#license label").removeClass("myradio").removeClass("onactive");
    $(this).addClass("myradio").css({});
    var title = '<input type="hidden" name="bifat" value="bifat" />';
    $(".RdSelect").html(title);
});

$("#license label").mouseover(
    function(){
    $(this).not(".myradio").addClass("onactive");
    });
    $("#license label").mouseout(
    function(){
    $(this).removeClass("onactive");
    });
});

///RADIO BUTON CUSTOM PRODUCT PAGE

$(document).ready(function(){
    $(".license label").click(function () {
    $(".license label").removeClass("myradio").removeClass("onactive");
    $(this).addClass("myradio").css({});
    var title = '<input type="hidden" name="bifat" value="bifat" />';
    $(".RdSelect").html(title);
});

$(".license label").mouseover(
    function(){
    $(this).not(".myradio").addClass("onactive");
    });
    $(".license label").mouseout(
    function(){
    $(this).removeClass("onactive");
    });
});

$(function() {
  $('.tabCale .filtrut .aria').hover(function(){
    $('.bccont', this).css('display', 'block');
	$('a', this).addClass("onactive");
	$('li a', this).removeClass("onactive");
	// $(".bccont").show("fast");
  },//
  function(){
    $('.bccont', this).css('display', 'none');
	$('a', this).removeClass("onactive");
	// $(".bccont").hide("fast");
  });
 });
 
 $(function() {
  $('.menuIntern .aria').hover(function(){
    $('.bccont', this).css('display', 'block');
	$('a', this).addClass("onactive");
	$('li a', this).removeClass("onactive");
	// $(".bccont").show("fast");
  },//
  function(){
    $('.bccont', this).css('display', 'none');
	$('a', this).removeClass("onactive");
	// $(".bccont").hide("fast");
  });
 });
 
 function swap_link(link) {
			$$('ul.360img li a').each(function (item) {
				item.style.color = '';
				item.getParent().style.color = '';
			});
			link.style.color = '#333';
			link.getParent().style.color = '#D60080';
			$$('.h3c').setStyle('display', 'none');
		}
		
function swap($src) {  $$('.h3c').setStyle('display', 'none'); $$('#'+$src).setStyle('display', 'block');}

//menu dropdown
$(function(){  
	 $('#tarife table').each(function(index,item) {
		$('table').addClass("table")
		$(item).addClass('tabel_'+index);
		$(item).find('tr').first().addClass('firstTr');
		$('#tarife tbody > tr:odd').addClass('rowOdd');
		$('#tarife tbody > tr:even').addClass('rowEven');
		$('#tarife tbody > tr > td:odd').addClass('tdOdd');
		$('#tarife tbody > tr > td:even').addClass('tdEven');
		
	})    
});


//TABS HOME
$(document).ready(function() {

	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("curent").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("curent"); //Remove any "active" class
		var activeRel = $(this).find("a").attr("rel"); //Add "active" class to selected tab
		$(this).addClass("curent"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});

});

//ajax tarife

$(function(){ 
	
	$('.loadTarife').live('click',function(){
		$("#tarife .boxAcc").hide();
		$(".afiseaza").show();
		$(".ascunde").hide();
		$($(this).parent().find('.loadTarife .afiseaza')).hide();
		$($(this).parent().find('.loadTarife .ascunde')).show();
		$($(this).parent().find('div.boxAcc')).load('http://www.arcadiamedical.ro/loadTarife/'+$(this).attr('rel')+'/').show();	
		
		_gaq.push(['_trackEvent', 'Tarife', ''+$(this).attr('rel')+'' ,'load']);
		
	});	
	
	$(function(){  
		$('.loadTarife .ascunde').click(function(){ 
			$("#tarife div.boxAcc").hide();
		}) 
	}); 
	
	$('.loadTarife .ascunde').toggle(function() {
	    $('.loadTarife .afiseaza').show();
		$('.loadTarife .ascunde').hide();
	}, function() {
	    $('.loadTarife .ascunde').hide();
	    $('.loadTarife .afiseaza').show();
	});
	
});	

//load medici

$(function(){ 
	
	$('.loadMedici').live('click',function(){
		$(".MediciListG").hide();
		$(".afiseaza").show();
		$(".ascunde").hide();
		$($(this).parent().find('.loadMedici .afiseaza')).hide();
		$($(this).parent().find('.loadMedici .ascunde')).show();
		$($(this).parent().find('div.MediciListG')).load('http://www.arcadiamedical.ro/loadMedici/'+$(this).attr('rel')+'/').show();	
		_gaq.push(['_trackEvent', 'Medici', ''+$(this).attr('rel')+'' ,'load']);
	});	
	
	$(function(){  
		$('.loadMedici .ascunde').click(function(){ 
			$(".MediciListG").hide();
		}) 
	});
 
	
	$('.loadMedici .ascunde').toggle(function() {
	    $('.loadMedici .afiseaza').show();
		 $('.loadMedici .ascunde').hide();
	}, function() {
	  $('.loadMedici .ascunde').hide();
	$('.loadMedici .afiseaza').show();
	});
});	

//tarife specialitate

$(function(){ 
	
	$('.openTarife').live('click',function(){
		$("#tarife .boxAcc").hide();
		$(".afiseaza").show();
		$(".ascunde").hide();
		$($(this).parent().find('.openTarife .afiseaza')).hide();
		$($(this).parent().find('.openTarife .ascunde')).show();
		$($(this).parent().find('div.boxAcc')).show();	
	});	
	
	$(function(){  
		$('.openTarife .ascunde').click(function(){ 
			$("#tarife div.boxAcc").hide();
		}) 
	}); 
	
	$('.openTarife .ascunde').toggle(function() {
	    $('.openTarife .afiseaza').show();
		$('.openTarife .ascunde').hide();
	}, function() {
	    $('.openTarife .ascunde').hide();
	    $('.openTarife .afiseaza').show();
	});
	
});	

//
/*
$(function(){  
	
	$("#tarife .boxAcc").hide();

	$('.boxTT h3').click(function(){ 
			    $("#tarife .boxAcc").removeClass("active"); //Remove any "active" class
				i = $('.boxTT h3').index($(this));		 
				$('.boxAcc').hide();
				$($('.boxAcc')[i]).show();
				$($('.boxTT h3')[i]).addClass("active"); //Activate first tab
				$($('.boxTT .boxAcc h3')[i]).removeClass("active"); //Activate first tab
	},
	function(){    	
		i = $('.boxTT h3').index($(this));		 
        $($('.boxTT h3')[i]).removeClass("active");  
    });	
	
});
*/

$(document).ready(function(){
  var section = new Array('.entry p','.entry li','.entry h2','.entry h3'); 
  section = section.join(',');

  // Reset Font Size
  var originalFontSize = $(section).css('font-size');
  $(".resetFont").click(function(){
    $(section).css('font-size', originalFontSize); 
  });

  // Increase Font Size
  $(".increaseFont").click(function(){
    var currentFontSize = $(section).css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*1.2;
	if (newFontSize<18){
    $(section).css('font-size', newFontSize);
	$(section).css('line-height',  '22px');
	}
    return false;
  });


  // Decrease Font Size
  $(".decreaseFont").click(function(){
    var currentFontSize = $(section).css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*0.9;
	if (newFontSize > 11){
    $(section).css('font-size', newFontSize);
	$(section).css('line-height',  '17px');
	}
    return false;
  });
});

function myprint()
{

window.print();
}

//for iframe

		$(document).ready(function() {			

			 $('#myselectbox').selectbox({debug: true});
	 
			 $("a.thickbox").fancybox({
				'scrolling'		: 'no',
				'titleShow'		: false,
				'onClosed'		: function() {
					$("#login_error").hide();
				}
			 });	
			 		 
			 $('a.iframe').each(function(){
				  var dWidth  = parseInt($(this).attr('href').match(/width=[0-9]+/i)[0].replace('width=',''));
				   var dHeight = parseInt($(this).attr('href').match(/height=[0-9]+/i)[0].replace('height=',''));
				   
				   $(this).fancybox({
						'width'			    : dWidth,
						'height'            : dHeight,
						'autoScale'     	: false,
						'titleShow'		    : false,
						'transitionIn'		: 'elastic',
						'transitionOut'		: 'elastic',
						'type'			    : 'iframe'
					});
	          });		 
		 });
 

var cTab=0;
var runSlide=1;
var hpnowDate = new Date();
var hpbeforeDate = new Date();
$(document).ready(function() {	

	$('.bulets a').click(function(){
		$('.bulets a').removeClass('curent');
		i=$('.bulets a').index($(this));		
		$(this).addClass('curent');
		$('.slides li').hide();
		$($('.slides li')[i]).show();
	});

	 $('.bntl').click(function() {
     runSlide=0;
		$('._selTab').removeClass('curent');
		cTab--;
		if (cTab<0)
			cTab=0;
		i=cTab;		
		$($('._selTab')[cTab]).addClass('curent');
		$('#sliders').animate({left: -i*695});  
   })   

  $('.bntr').click(function() {
	    runSlide=0;
		cTab++;
		if ($('._selTab').length<=cTab)
		  	cTab=0;	

		$('._selTab').removeClass('curent');
		i=cTab;		
		$($('._selTab')[cTab]).addClass('curent');
		$('#sliders').animate({left: -i*695});
   })
	

  autoChangeTab = function() {
    if (!runSlide)
      return;
	  hpnowDate = new Date();
	  var elapsedTime = (hpnowDate.getTime() - hpbeforeDate.getTime());
	  if(elapsedTime > 4500) 
      cTab+=Math.floor(1*(elapsedTime/4500));
	  else
      cTab++;
	  if ($('._selTab').length<=cTab)
	  	cTab=0;
 		$('._selTab').removeClass('curent');
		i=$('._selTab').index($($('._selTab')[cTab]));	
		$($('._selTab')[cTab]).addClass('curent');		
		$('#sliders').animate({left: -i*695},500,function(){ setTimeout("autoChangeTab()",4500); });
    hpbeforeDate = new Date();  
  } 

	setTimeout("autoChangeTab()",4500);		

	$('._selTab').click(function(){
    runSlide=0;
		$('._selTab').removeClass('curent');
		i=$('._selTab').index($(this));		
		cTab=i;
		$(this).addClass('curent');
		$('#sliders').animate({left: -i*695});
	});  

});


$(document).ready(function() {


var cTab1=0;
var runSlide1=1;

 $('#urma').click(function() {
     runSlide1=0;
		$('.imgr').removeClass('curent');
		cTab1--;
		if (cTab1<0)
			cTab1=0;
		i=cTab1;		
		$($('.imgr')[cTab1]).addClass('curent');
		$('.imgr').hide();
		$($('.imgr')[i]).show();
   })   

  $('#anter').click(function() {
	    runSlide1=0;
		cTab1++;
		if ($('.imgr').length<=cTab1)
		  	cTab1=0;	

		$('.imgr').removeClass('curent');
		i=cTab1;		
		$($('.imgr')[cTab1]).addClass('curent');
		 $('.imgr').hide();
		 $($('.imgr')[i]).show();
   }) 
});
