jQuery(document).ready(function() {
    
    
    jQuery('.blog:last').css('border-bottom','none');
    pic1= new Image(); 
    pic1.src="images/login_h.gif";
    pic2= new Image(); 
    pic2.src="images/login_left_h.gif";
    pic3= new Image(); 
    pic3.src="images/login_right_h.gif";
    pic4= new Image(); 
    pic4.src="images/sbtn_h.gif";
    pic5= new Image(); 
    pic5.src="images/sbtn_left_h.gif";
    pic6= new Image(); 
    pic6.src="images/sbtn_right_h.gif";
    pic7= new Image(); 
    pic7.src="images/buttons/btn_link_blue_h.gif";
    pic8= new Image(); 
    pic8.src="images/buttons/btn_link_blue_left_h.gif";
    pic9= new Image(); 
    pic9.src="images/buttons/btn_link_blue_right_h.gif";
    pic10= new Image(); 
    pic10.src="images/buttons/btn_link_h.gif";
    pic11= new Image(); 
    pic11.src="images/buttons/btn_link_left_h.gif";
    pic12= new Image(); 
    pic12.src="images/buttons/btn_link_right_h.gif";
    
    jQuery('#countrycodes').click(function() { return false; });
    jQuery('.closeCountryCodes').click(function() {
        hideCountryCodes();
        return false;
    });
    jQuery('.show_areacodes').click(function(event) {
        event.stopPropagation();
        jQuery('#countrycodes').show();
       
        $(document).bind('click',hideCountryCodes);
        return false;
    });
    jQuery('#countrycodes table a').click(function(){
        var parent = $(this).parents('tr').get(0);
        
        if($(this).hasClass('real_code')) { $('.areacode_input').val($(this).html()); }
        else {
            var real_code = $(parent).children('.last');
            real_code = real_code.children('.real_code').html();
            $('.areacode_input').val(real_code);
        }
        var flag_ico = $(parent).children('.first');
        flag_ico = flag_ico.children('img').attr('src');
        
        $('.areacode_input').css('background-image','url(\''+flag_ico+'\')');
        hideCountryCodes();
    });
    
    
    
	//jQuery('#number_form_select').selectbox();
	
	var boxes = jQuery('.scrollbox-inner');
	scrollbox_count = boxes.length;
	
	if(boxes.length > 0) {
        jQuery(boxes[0]).show();
    }
	
	jQuery('#scroll-next').click(function() {
	    if(scrollbox_position < scrollbox_count-1) {
	        jQuery(boxes[scrollbox_position]).fadeOut('fast', function() {
	            scrollbox_position++;
	            jQuery(boxes[scrollbox_position]).fadeIn('fast');
	        });
	    }
	    return false;
	});
	jQuery('#scroll-prev').click(function() {
	    if(scrollbox_position > 0) {
	        jQuery(boxes[scrollbox_position]).fadeOut('fast', function() {
	            scrollbox_position--;
	            jQuery(boxes[scrollbox_position]).fadeIn('fast');
	        });
	    }
	    return false;
	});
	
	
	jQuery('#country-select').change(function() {
	    var flag = jQuery("#country-select option:selected").attr('rel');
	    jQuery('#flag_ico').attr('src',flag);
	});
});

var scrollbox_count = 0;
var scrollbox_position = 0;


// TOOLTIP

jQuery(document).ready(function() {
   
    jQuery('.tooltip').mouseover(function(e) {
        
        var $tooltip = jQuery(this);
        var id = $tooltip.attr('id');
        var id_nr = id.substring(8);
        
        var $tooltipbox = jQuery('#tooltipbox-'+id_nr);
        $tooltipbox
    	    .css("top",(e.pageY - 20) + "px")
			.css("left",(e.pageX - 20) + "px")
    		.fadeIn("fast");
    		
    });
    
    jQuery('.tooltipbox').hover(function(e) {
        
    },function() {
        jQuery(this).fadeOut(); 
    });
    
    jQuery('.tooltip-close').click(function() {
        var parent = jQuery(this).parents('.tooltipbox').get(0);
        jQuery(parent).fadeOut(); 
        return false;
    });
});
jQuery(document).ready(function() {
	var front3 = jQuery("#front3");
	if (front3.length > 0)
	{
		var lochash = location.hash.replace(/#/, "");
		if (lochash.length > 0)
		{
			jQuery("#front3_nav li").removeClass('active');
			jQuery("#front3_cont div").removeClass('active');
			jQuery("#front3_cont div."+lochash).addClass('active');
			var anc = jQuery("#front3_nav a."+lochash).parent();
			jQuery(anc).addClass('active');
			jQuery("#front3_cont div.active").hide();
			jQuery("#front3_cont div."+lochash).show();
		}
		 jQuery("#front3_nav a").click(function() {
			 var ancli = jQuery(this).parent();
			 jQuery("#front3_nav .active").removeClass('active');
			 jQuery(ancli).addClass('active');
  var box = jQuery(this).attr('class');
  if (jQuery("#front3 div."+box).hasClass('active')) {
  return false;
  }
  else {
  jQuery("#front3_cont div.active").fadeOut("medium", function() {
	jQuery("#front3_cont div."+box).fadeIn("medium",function() {
		jQuery("#front3_cont div.active").removeClass("active");
		jQuery("#front3_cont div."+box).addClass("active");
	});
  });
  }
 });
	}
	jQuery("#cse-search-submit").mouseover( function() {
		jQuery(this).css('background',"url('images/front_searchbox_submit_mouseover_bg.gif') no-repeat left top");
	});
	jQuery("#cse-search-submit").mouseout( function() {
		jQuery(this).css('background',"url('images/front_searchbox_submit_bg.gif') no-repeat left top");
	});
});


function hideCountryCodes() {
    jQuery('#countrycodes').hide();
    $(document).unbind('click',hideCountryCodes);
}