var imgcounter = 0;	

function closeBoxBanner() {
    
    if ($('#push-down-ad').html().indexOf('817-grey.gif') < 0) {
        // no ad       
        $.each($('#banner-link-box a'), function() {
        var $tID = $(this).attr("id"); 
            
            switch($tID)
            {
            case 'banner-link-top':
                $tp1 = "-8px -4px";
                $tp2 = "top-content"
                break;
            case 'banner-link-best':
                $tp1 = "-8px -33px";
                $tp2 = "best-content";
                break;
            case 'banner-link-destination':
                $tp1 = "-8px -62px";
                $tp2 = "destination-content";
                break; 
            case 'banner-link-featured':
                $tp1 = "-8px -91px";
                $tp2 = "featured-content";
                break;
            case 'banner-link-sponsor':
                $tp1 = "-8px -120px";
                $tp2 = "sponsor-content";
                break;
            default:
                $tp1 = "-8px -4px;";
                $tp2 = "top-content";
            }   
            
            $('#'+$tID).css('width','220px');
            $('#'+$tID).css('backgroundPosition', $tp1);
            $('#'+$tp2).hide();
            $('#banner-white-box').hide();
        
        }); 
    
    } else {      	   
        // ad exists		
   	} 
}

function closeBoxBanner2() {        
    $.each($('#banner-link-box a'), function() {
    var $tID = $(this).attr("id"); 
        
        switch($tID)
        {
        case 'banner-link-top':
            $tp1 = "-8px -4px";
            $tp2 = "top-content"
            break;
        case 'banner-link-best':
            $tp1 = "-8px -33px";
            $tp2 = "best-content";
            break;
        case 'banner-link-destination':
            $tp1 = "-8px -62px";
            $tp2 = "destination-content";
            break; 
        case 'banner-link-featured':
            $tp1 = "-8px -91px";
            $tp2 = "featured-content";
            break;
        case 'banner-link-sponsor':
            $tp1 = "-8px -120px";
            $tp2 = "sponsor-content";
            break;
        default:
            $tp1 = "-8px -4px;";
            $tp2 = "top-content";
        }   
        
        $('#'+$tID).css('width','220px');
        $('#'+$tID).css('backgroundPosition', $tp1);
        $('#'+$tp2).hide();
        $('#banner-white-box').hide();
    
    }); 
}

function trackCurrentSlideShowImage() {
			
			var clientInfo = (images[imgcounter][2] ? images[imgcounter][2] : images[imgcounter][1]);       
       //if (window.LL && LL.evt) {
			//			LL.evt("CLICK", "client", clientInfo  + "_IMPRESSION_slideshow_slot_" + imgcounter);
			//			LL.evt("CLICK", "client_" + clientInfo, "IMPRESSION_slideshow_slot_" + imgcounter);
      // }
			 $("#img-banner").parent().attr("class", "converttrack_site|" + clientInfo + "_slideshow clicktrack_client_" + clientInfo + "|slideshow_slot_" + imgcounter + " clicktrack_client|" + clientInfo  + " clicktrack_client|" + clientInfo  + "_slideshow_slot_" + imgcounter + " clicktrack_site|home_slideshow_slot_" + imgcounter);
			
}//trackCurrentSlideShowImage

function changePhoto() {
	$.ajax({
		url: images[imgcounter][0],
		complete: function() {

			trackCurrentSlideShowImage();
			$("#img-banner").attr("src", images[imgcounter][0]);
			$("#img-banner").parent().attr("href", images[imgcounter][1]);
			$('#img-banner').animate({
			    opacity: 1
			}, 500, function() {
				timePhoto();
			});
		}
	});   
}

function changeOpacity() {        
	$('#img-banner').animate({
	    opacity: 0.00
	}, 500, function() {
		setTimeout('changePhoto()', 100);
	});
   //$("#img-banner").animate({opacity: 0.00});
}

function timePhoto () {	
	if (imgcounter <= maxcounter) {
		imgcounter++;	
	} else {
		imgcounter = imgcounter - imgcounter;
	}
    setTimeout('changeOpacity()', 4000);
	//changeOpacity();
}

$().ready(function() {      
    
		trackCurrentSlideShowImage();

    $("#nav ul").mouseover(
		function () {
		    $(this).prev('a').addClass('phover');
		}
    );
    
	$("#nav ul").mouseout(
		function () {
		      //if $(this).prev('ul').
			$(this).prev('a').removeClass('phover');		
		}
	);
	
	$('.openHelp').live('click', function() {
		var helpwindow = window.open('/LL/home_help.php','helpwindow','width=680,height=530,resizable=0');
		helpwindow.focus();
	});
    
    
    $('#banner-link-box a').bind('click', function() {  
        
        var $varID = $(this).attr("id");
        var $p1;
        var $p2;
        
        switch($varID)
        {
        case 'banner-link-top':
            $p1 = "-8px -4px";
            $p2 = "-481px -4px";
            break;
        case 'banner-link-best':
            $p1 = "-8px -33px";
            $p2 = "-481px -33px";
            break;
        case 'banner-link-destination':
            $p1 = "-8px -62px";
            $p2 = "-481px -62px";
            break; 
        case 'banner-link-featured':
            $p1 = "-8px -91px";
            $p2 = "-481px -91px";
            break;
        case 'banner-link-sponsor':
            $p1 = "-8px -120px";
            $p2 = "-481px -120px";
            break;
        default:
            $p1 = "-8px -4px";
            $p2 = "-481px -4px";
        }    
        
        if ($('#'+$varID).css('width') == '238px') {
            $('#'+$varID).css('backgroundPosition', $p1);
            $('#'+$varID).css('width','220px');
            $('#banner-white-box').hide();
        
        } else {
           
            $('#'+$varID).css('backgroundPosition', $p2);
            $('#'+$varID).css('width','238px');
            
            $('#banner-white-box').show();
            
            $.each($('#banner-link-box a'), function() {
               var $tID = $(this).attr("id"); 
               
               switch($tID)
                    {
                    case 'banner-link-top':
                        $tp1 = "-8px -4px";
                        $tp2 = "top-content"
                        break;
                    case 'banner-link-best':
                        $tp1 = "-8px -33px";
                        $tp2 = "best-content";
                        break;
                    case 'banner-link-destination':
                        $tp1 = "-8px -62px";
                        $tp2 = "destination-content";
                        break; 
                    case 'banner-link-featured':
                        $tp1 = "-8px -91px";
                        $tp2 = "featured-content";
                        break;
                    case 'banner-link-sponsor':
                        $tp1 = "-8px -120px";
                        $tp2 = "sponsor-content";
                        break;
                    default:
                        $tp1 = "-8px -4px;";
                        $tp2 = "top-content";
                    } 
               
               if ($tID != $varID) {                      
                    $('#'+$tID).css('width','220px');
                    $('#'+$tID).css('backgroundPosition', $tp1);
                    $('#'+$tp2).hide();
               } else {
                    $('#'+$tp2).show();
               }
            });
            
        }
	});
    
    $('#banner-link-box a').bind('mouseover', function() {
        
        var $varID = $(this).attr("id");
        var $p1;
        
        switch($varID)
        {
        case 'banner-link-top':
            $p1 = "-239px -4px";
            
            break;
        case 'banner-link-best':
            $p1 = "-239px -33px";
            
            break;
        case 'banner-link-destination':
            $p1 = "-239px -62px";
           
            break; 
        case 'banner-link-featured':
            $p1 = "-239px -91px";
          
            break;
        case 'banner-link-sponsor':
            $p1 = "-239px -120px";
          
            break;
        default:
            $p1 = "-239px -4px;";
            
        }    
        
                
        if ($('#'+$varID).css('width') == '238px') {            
        } else {
            $('#'+$varID).css('backgroundPosition', $p1);
            $('#'+$varID).css('width','230px');
        }    
	});
    
    $('#banner-link-box a').bind('mouseout', function() {
        
        var $varID = $(this).attr("id");
        var $p1;
        
        switch($varID)
        {
        case 'banner-link-top':
            $p1 = "-8px -4px";
            
            break;
        case 'banner-link-best':
            $p1 = "-8px -33px";
            
            break;
        case 'banner-link-destination':
            $p1 = "-8px -62px";
           
            break; 
        case 'banner-link-featured':
            $p1 = "-8px -91px";
          
            break;
        case 'banner-link-sponsor':
            $p1 = "-8px -120px";
          
            break;
        default:
            $p1 = "-8px -4px;";
            
        }    
        
                
        if ($('#'+$varID).css('width') == '238px') {            
        } else {
            $('#'+$varID).css('backgroundPosition', $p1);
            $('#'+$varID).css('width','220px');
        }    
	});
    
    $('.closeBox').bind('click', function() { 
        closeBoxBanner2();
    });
            
    $('table').bind('click', function() {
        closeBoxBanner();
    });  
    
    $('#navContainer').bind('click', function() {
        closeBoxBanner();
    });   
    
    $('h5').bind('click', function() {
        closeBoxBanner();
    }); 
    
    $('#left-link').bind('click', function() {
        closeBoxBanner();
    });
    
    $('#left-best').bind('click', function() {
        closeBoxBanner();
    });
    
    $('#left-destination').bind('click', function() {
        closeBoxBanner();
    });
    
    $('#top-destination').bind('click', function() {
        closeBoxBanner();
    });
    
    $('#left-world').bind('click', function() {
        closeBoxBanner();
    });
    
    $('#rightBox').bind('click', function() {
        closeBoxBanner();
    });
    
    //call photo slide banner set to 5000   
    timePhoto();      
      
});

