
// top menu
jQuery(function () {jQuery('.dropdown').each(function () {jQuery(this).parent().eq(0).hover(function () {jQuery('.dropdown:eq(0)', this).show();}, function () {jQuery('.dropdown:eq(0)', this).hide();});});});


function homeFlashBanners_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

function winsRotateBanner_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};



function homePhotos_loadCallback(carousel)
{
	 $('div#slideshow_main_bannerPhotos li').removeClass('active');        
	 var maxItems = $('#slideshow_main_bannerPhotos li').length;
	 var selectedIndex = carousel.first;
	 if(selectedIndex < 0)
	 {
		 if(selectedIndex *-1> maxItems)
			 selectedIndex = selectedIndex - Math.round(selectedIndex / maxItems) * maxItems;
		 selectedIndex = maxItems - (selectedIndex*-1); 
	 }
	 else if(selectedIndex > maxItems)
		 selectedIndex = selectedIndex - Math.round(selectedIndex / maxItems) * maxItems;
	 $('div#slideshow_main_bannerPhotos li.p' + (selectedIndex + 1)).addClass('active'); 
}
function homeLottory_loadCallback(carousel)
{
	 $('div#slideshow_main_bannerLottory li').removeClass('active');        
	 var maxItems = $('#slideshow_main_bannerLottory li').length;
	 var selectedIndex = carousel.first;
	 if(selectedIndex < 0)
	 {
		 if(selectedIndex *-1> maxItems)
			 selectedIndex = selectedIndex - Math.round(selectedIndex / maxItems) * maxItems;
		 selectedIndex = maxItems - (selectedIndex*-1); 
	 }
	 else if(selectedIndex > maxItems)
		 selectedIndex = selectedIndex - Math.round(selectedIndex / maxItems) * maxItems;
	 $('div#slideshow_main_bannerLottory li.L' + (selectedIndex+1)).addClass('active'); 
}
function homePhotos_initCallback(carousel) 
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
};
function homePhotos_UpdateMainImage() { 
	$('div#slideshow_main_bannerPhotos li').removeClass('active');        
	$('div#slideshow_main_bannerPhotos li.' + $(this).attr('rel')).addClass('active');	
	
	return false;
}



$(document).ready(function() {
	var userAgent = navigator.userAgent + " ";
    userAgent = userAgent.toLowerCase();
    
	//chrome setup
	 
	if (userAgent.indexOf("chrome") >= 0 || userAgent.indexOf("safari") >= 0) {
		browsersChrome();	
    }
	
}); 

function browsersChrome() {
  
	
	var arr = new Array();
	arr = $('.hoverIcon');
	if(arr != null)
	{
		for (i =0; i<arr.length; i++)
		{
			arr[i].style.margin = "60px 35px";  
		}
	}
}

 

/*
* vertical news ticker
* Tadas Juozapaitis ( kasp3rito@gmail.com )
* http://plugins.jquery.com/project/vTicker
*/
(function($){
$.fn.vTicker = function(options) {
	var defaults = {
		speed: 700,
		pause: 4000,
		showItems: 3,
		animation: '',
		mousePause: true,
		isPaused: false,
		direction: 'up',
		height: 251
	};

	var options = $.extend(defaults, options);

	moveUp = function(obj2, height, options){
		if(options.isPaused)
			return;
		
		var obj = obj2.children('ul');
		
    	var clone = obj.children('li:first').clone(true);
		
		if(options.height > 0)
		{
			height = obj.children('li:first').height();
		}		
		
    	obj.animate({top: '-=' + height + 'px'}, options.speed, function() {
        	$(this).children('li:first').remove();
        	$(this).css('top', '0px');
        });
		
		if(options.animation == 'fade')
		{
			obj.children('li:first').fadeOut(options.speed);
			if(options.height == 0)
			{
			obj.children('li:eq(' + options.showItems + ')').hide().fadeIn(options.speed);
			}
		}

    	clone.appendTo(obj);
	};
	
	moveDown = function(obj2, height, options){
		if(options.isPaused)
			return;
		
		var obj = obj2.children('ul');
		
    	var clone = obj.children('li:last').clone(true);
		
		if(options.height > 0)
		{
			height = obj.children('li:first').height();
		}
		
		obj.css('top', '-' + height + 'px')
			.prepend(clone);
			
    	obj.animate({top: 0}, options.speed, function() {
        	$(this).children('li:last').remove();
        });
		
		if(options.animation == 'fade')
		{
			if(options.height == 0)
			{
				obj.children('li:eq(' + options.showItems + ')').fadeOut(options.speed);
			}
			obj.children('li:first').hide().fadeIn(options.speed);
		}
	};
	
	return this.each(function() {
		var obj = $(this);
		var maxHeight = 0;

		obj.css({overflow: 'hidden', position: 'relative'})
			.children('ul').css({position: 'absolute', margin: 0, padding: 0})
			.children('li').css({margin: 0, padding: 0});

		if(options.height == 0)
		{
			obj.children('ul').children('li').each(function(){
				if($(this).height() > maxHeight)
				{
					maxHeight = $(this).height();
				}
			});

			obj.children('ul').children('li').each(function(){
				$(this).height(maxHeight);
			});

			obj.height(maxHeight * options.showItems);
		}
		else
		{
			obj.height(options.height);
		}
		
    	var interval = setInterval(function(){ 
			if(options.direction == 'up')
			{ 
				moveUp(obj, maxHeight, options); 
			}
			else
			{ 
				moveDown(obj, maxHeight, options); 
			} 
		}, options.pause);
		
		if(options.mousePause)
		{
			obj.bind("mouseenter",function(){
				options.isPaused = true;
			}).bind("mouseleave",function(){
				options.isPaused = false;
			});
		}
	});
};
})(jQuery);







var deviceS60 = "series60";
var deviceSymbian = "symbian";
var engineWebKit = "webkit";
var deviceIphone = "iphone";
var deviceIpod = "ipod";
var deviceAndroid = "android";
var deviceWinMob = "windows ce";
var deviceBB = "blackberry";
var devicePalm = "palm";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// Detects if the current device is an iPhone.
function DetectIphone()
{
   if (uagent.search(deviceIphone) > -1)
      return true;
   else
      return false;
}

//**************************
// Detects if the current device is an iPod Touch.
function DetectIpod()
{
   if (uagent.search(deviceIpod) > -1)
      return true;
   else
      return false;
}

//**************************
// Detects if the current device is an iPhone or iPod Touch.
function DetectIphoneOrIpod()
{
    if (DetectIphone())
       return true;
    else if (DetectIpod())
       return true;
    else
       return false;
}

function changeContentForSmartPhones()
{
	if(DetectIphoneOrIpod()) {
		jQuery('#homeFlashBanners li').remove();
		jQuery('#homeFlashBanners').append('<li><img src="/resourcesv2/images/homepage/homepage_smartphone_service.jpg" alt="" /></li>');
	}	
}
function addBookmark(title, url) {

	if (window.sidebar) { // firefox

	window.sidebar.addPanel(title, url,"");

	} else if( document.all ) { //MSIE

	window.external.AddFavorite( url, title);
	} else {

	alert("Sorry, your browser doesn't support this");

	}

	}



function InitializePollResults(pollId, rate1, rate2, rate3, rate4, rate5)
{ 
	var maxVal = Math.max(rate1, rate2, rate3, rate4, rate5); 
	var pHeight=100/maxVal;
	if (rate5 == -1)
	{
		jQuery('.' + pollId + ' .red').css('height', pHeight * rate1 + 'px');
		jQuery('.' + pollId + ' .green').css('height', pHeight * rate2 + 'px');
		jQuery('.' + pollId + ' .blue').css('height', pHeight * rate3 + 'px');
		jQuery('.' + pollId + ' .yellow').css('height', pHeight * rate4 + 'px');
	}
	jQuery('.' + pollId + ' .red').css('height', pHeight * rate1 + 'px');
	jQuery('.' + pollId + ' .green').css('height', pHeight * rate2 + 'px');
	jQuery('.' + pollId + ' .blue').css('height', pHeight * rate3 + 'px');
	jQuery('.' + pollId + ' .yellow').css('height', pHeight * rate4 + 'px');
	jQuery('.' + pollId + ' .purple').css('height', pHeight * rate5 + 'px');
}

