var offerCount = 3;
var offerTimer = null;
var currentLyr = 0;

  function move_in(img_name,img_src) {
    if(document[img_name]){
      document[img_name].src=img_src;
    }
  }

  function move_out(img_name,img_src) {
    if(document[img_name]){
      document[img_name].src=img_src;
    }
  }
 

  function getElemRefs(id) {
    var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
    if (el) el.css = (el.style)? el.style: el;
    return el;
  }
  
  
  function showLayer(id) {
    var lyr = getElemRefs(id);
    if (lyr && lyr.css) {
      lyr.css.display = "block";
      lyr.css.visibility = "visible";
    }
  }

  function hideLayer(id) {
    var lyr = getElemRefs(id);
    if (lyr && lyr.css) {
      lyr.css.display = "none";
      lyr.css.visibility = "hidden";
    }
  }
  
  function showOffer(offerID, killTimer) {
    hideAllOffers();
    hideAllOfferButtons();
    //move_in('num'+offerID,'/images/news_num'+offerID+'_on.gif');

    showLayer('lyr'+offerID);
    
    if (killTimer) {
      if(offerTimer) clearTimeout(offerTimer);
    } 
  }
  
  function hideAllOffers() {
    for (i = 1; i <= offerCount; i++) {
      hideLayer('lyr'+i);
    } 
  }
  
  function hideAllOfferButtons() {
    for (i = 1; i <= offerCount; i++) {
      //move_out('num'+i,'/images/news_num'+ i +'_off.gif');    
    }   
  } 
  
  function offerSwitcher(currentOffer,totalOffer) {
    
    next(totalOffer);
    	
    if(offerTimer) clearTimeout(offerTimer);
    offerTimer = setTimeout("offerSwitcher("+ currentOffer + "," + totalOffer + ")", 7000); 
		
  }

  //ADVANCE TO NEXT OFFER UP TO TOTAL OFFERS, THEN RETURN TO BEGINNING
  function next (totalOffer) {
		if (currentLyr < totalOffer){
			showOffer(currentLyr+1,1);
			currentLyr++;
			changeLyrText(currentLyr);
			
			
		}
		else if (currentLyr == totalOffer) {
			currentLyr = 1;
			showOffer(currentLyr,1);
			changeLyrText(currentLyr);
		}
	}
	
	function previous (totalOffer) {
		if (currentLyr > 1){
			showOffer(currentLyr-1,1);
			currentLyr--;
			changeLyrText(currentLyr);
		}
		else if (currentLyr == 1) {
			currentLyr = totalOffer;
			showOffer(currentLyr,1);
			changeLyrText(currentLyr);
		}
	}

	function changeLyrText(id) {
		
		document.getElementById('news-num').innerHTML = "(" + id + "-" + offerCount + ")" + "&nbsp;<IMG SRC=\"/us_english/images/home/left_button.gif\" WIDTH=\"11\" HEIGHT=\"11\" class=\"clickable\" onclick=\"previous(3);\" style=\"vertical-align:bottom;\" BORDER=\"0\" />&nbsp;<IMG SRC=\"/us_english/images/home/right_button.gif\" WIDTH=\"11\" HEIGHT=\"11\" class=\"clickable\" onclick=\"next(3);\" style=\"vertical-align:bottom;\" BORDER=\"0\" />";
		//document.all['news-num'].innerHTML = id + "-" + offerCount;
	}