jQuery.noConflict();
function advert() {
    //Set the opacity of all images to 0
    jQuery('ul#advert li').css({
        opacity: 0.0
    });
    //Get the first image and display it (gets set to full opacity)
    jQuery('ul#advert li:first').css({
        opacity: 1.0
    });
    //Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
    setInterval('rotatee()',5000);
} 

function rotatee() {
    //Get the first image
    var current = (jQuery('ul#advert li.show')? jQuery('ul#advert li.show') : jQuery('ul#advert li:first'));
    //Get next image, when it reaches the end, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().hasClass('show')) ? jQuery('ul#advert li:first') :current.next()) : jQuery('ul#advert li:first'));
    //Set the fade in effect for the next image, the show class has higher z-index
    next.css({
        opacity: 0.0
    })
    .addClass('show')
    .animate({
        opacity: 1.0
    }, 1000);
    //Hide the current image
    current.animate({
        opacity: 0.0
    }, 1000)
    .removeClass('show');
} 

jQuery(document).ready(function() {
    
    
    

    
    
    advert();  
    autoOur();
    jQuery(".paging").show();
    jQuery(".paging a:first").addClass("active");
    var imageWidth = jQuery(".window").width();
    var imageSum = jQuery(".image_reel img").size();
    var imageReelWidth = imageWidth * imageSum;
    jQuery(".image_reel").css({
        'width' : imageReelWidth
    });
    rotate = function(){	
        var triggerID = $active.attr("rel") - 1;
        var image_reelPosition = triggerID * imageWidth;
        jQuery(".paging a").removeClass('active');
        $active.addClass('active');
        jQuery(".image_reel").animate({ 
            left: -image_reelPosition
        }, 500 );
    }; 
    rotateSwitch = function(){		
        play = setInterval(function(){
            $active = jQuery('.paging a.active').next();
            if ( $active.length === 0) {
                $active = jQuery('.paging a:first');
            }
            rotate();
        }, 7000);
    };
    rotateSwitch();
    jQuery(".image_reel a").hover(function() {
        clearInterval(play); 
    }, function() {
        rotateSwitch();
    });	
    jQuery(".paging a").click(function() {	
        $active = jQuery(this);
        clearInterval(play);
        rotate();
        rotateSwitch();
        return false;
    });	
});




var timeout = 100;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open(){
    jsddm_canceltimer();
    jsddm_close();
    ddmenuitem = jQuery(this).find('ul').eq(0).css('visibility', 'visible');
}
function jsddm_close(){
    if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
}
function jsddm_timer(){
    closetimer = window.setTimeout(jsddm_close, timeout);
}
function jsddm_canceltimer(){
    if(closetimer){
        window.clearTimeout(closetimer);
        closetimer = null;
    }
}
jQuery(document).ready(function()
{
    jQuery('#nav > li').bind('mouseover', jsddm_open);
    jQuery('#nav > li').bind('mouseout', jsddm_timer);
});
document.onclick = jsddm_close; 

var nowid=1;
function autoOur(){
    setInterval('nextRotate()',6000);
}
function nextRotate() {
    var maxPr = jQuery('#ourUl li').length;  
    if( nowid== maxPr)
    {
        nowid=0;
         jQuery('#rightArrow a').css('display','block');
         jQuery('#leftArrow a').css('display','none'); 
    }
         if((nowid+1) <= maxPr)
    {
        jQuery('#pr'+nowid).css('display','none');
        nowid = nowid+1;
        jQuery('#pr'+nowid).css('display','block');
    }
    if(nowid == maxPr)
    {
        jQuery('#rightArrow a').css('display','none'); 
    }
    if(nowid>1){
        jQuery('#leftArrow a').css('display','block');
    }
    
    // nowid=1;
} 
function nextPr()
{
    var maxPr = jQuery('#ourUl li').length;  
    if((nowid+1) <= maxPr)
    {
        jQuery('#pr'+nowid).css('display','none');
        nowid = nowid+1;
        jQuery('#pr'+nowid).css('display','block');
    }
    if(nowid == maxPr)
    {
        jQuery('#rightArrow a').css('display','none'); 
    }
    if(nowid>1){
        jQuery('#leftArrow a').css('display','block');
    }
} 
function backPr()
{
    var maxPr = jQuery('#ourUl li').length;  
    
    if((nowid-1) >= 1)
    {
        jQuery('#pr'+nowid).css('display','none');
        nowid = nowid-1;
        jQuery('#pr'+nowid).css('display','block');
    }
    if(nowid == 1)
    {
        jQuery('#leftArrow a').css('display','none'); 
    }
    if(nowid<maxPr){
        jQuery('#rightArrow a').css('display','block');
    }
} 

