var d = document, imgs = new Array(), zInterval = null, current = 0, nextbanner = 1, waitbanner = 0,bn_count=0, pause = false;

var bannerTimer;
var autoTime = 4; //saniye

var aktif_menu = 0;

function menu(mn_id){


//alert (mn_id);
if (aktif_menu != 0){
	
	document.getElementById('mn_' + aktif_menu).style.display='none';
	
}
	document.getElementById('mn_' + mn_id).style.display='block';
	aktif_menu = mn_id;

}

function as_init() {
    autoTime = autoTime * 1000;
    if (!d.getElementById || !d.createElement) return;

    imgs = d.getElementById('rotator').getElementsByTagName('div');

    if (imgs.length > 1) {
        
        bn_count = imgs.length;
        
        for (i = 1; i < imgs.length; i++) {
            imgs[i].xOpacity = 0;
            imgs[i].style.display = 'none';
          
        }
        imgs[0].style.display = 'block';
        imgs[0].xOpacity = .99;
                    
        bannerTimer = setTimeout(as_xfade, autoTime);
    } else if (imgs.length == 1) {
        imgs[0].style.display = 'block';
       
    }
}

function as_nextbanner() {
    t_next = nextbanner + 1;
    if (t_next > bn_count) {
        t_next = 1;
    }

    as_setbanner(t_next);

}

function as_prevbanner() {
    t_prev = current;
    if (t_prev < 1) {
        t_prev = bn_count;
    }
    as_setbanner(t_prev);

}

function as_setbanner(bnrid) {
    if (waitbanner == 0 && bnrid - 1 != current) {


        nextbanner = bnrid - 1;
     
        clearTimeout(bannerTimer);
        //stopBanner=0;
        as_xfade();
        //stopBanner=1;
        //setTimeout(as_xfade,autoTime);
     
    }
}

function as_xfade() {
    waitbanner = 1;
    cOpacity = imgs[current].xOpacity;
    //nIndex = imgs[current+1]?current+1:0;
    nIndex = nextbanner;
    nOpacity = imgs[nIndex].xOpacity;

    cOpacity -= .05;
    nOpacity += .05;

    imgs[nIndex].style.display = 'block';
        

    imgs[current].xOpacity = cOpacity;
    imgs[nIndex].xOpacity = nOpacity;
     

    setOpacity(imgs[current]);
    setOpacity(imgs[nIndex]);
    

    if (cOpacity <= 0) {
        imgs[current].style.display = 'none';
     
        current = nIndex;
        nextbanner = imgs[current + 1] ? current + 1 : 0;
        waitbanner = 0;
        bannerTimer = setTimeout(as_xfade, autoTime);
    }
    else {
        setTimeout(as_xfade, 30);
    }

    function setOpacity(obj) {
        if (obj.xOpacity > .99) {
            obj.xOpacity = .99;
            return;
        }

        obj.style.opacity = obj.xOpacity;
        obj.style.MozOpacity = obj.xOpacity;
        obj.style.filter = 'alpha(opacity=' + (obj.xOpacity * 100) + ')';
    }


}

function showdiv(divid){
if (document.getElementById('d_' + divid).style.display== 'none'){
document.getElementById('d_' + divid).style.display= 'block';}else{
document.getElementById('d_' + divid).style.display= 'none'}
}
