/********* Adverts slideshow *************/
function advertChange() {
  if (adverts_list && $(advert_current)) {
	  el_id = advert_current;
	  isactive = found = false;
	  $H(adverts_list).each (
	    function ( pair ) {
	      code = pair.value;
	      index = pair.key;
	      if (isactive) {
	        advert_current = index;
	        isactive = false;
	      }
	      if (index == el_id) { isactive = found = true; }
	    }
	  );
	  if (isactive && found) $H(adverts_list).each (
      function ( pair ) {
        code = pair.value;
        index = pair.key;
	      if (isactive) {
	        advert_current = index;
	        isactive = false;
	      } 
	      if (index == el_id) { isactive = found = true; }
	    }
	  );
	  $(el_id).hide();
	  oddeven = ($(el_id).hasClassName('odd')) ? 'even' : 'odd';
	  $(el_id).replace( adverts_list[ advert_current ] );
	  $(advert_current).hide();
	  $(advert_current).addClassName(oddeven);
	  new Effect.Appear(advert_current, { 'duration': 0.3 });
	  setTimeout('advertChange()',advertSpeed);
  }
}
/********* Quotes slideshow **************/
function quoteChange() {
  el_id = quoteActive;
  isactive = found = false;
  quotes.each ( function (index) {
    if (isactive) {
      quoteActive = index;
      isactive = false;
    } 
    if (index == el_id) { isactive = found = true; }
  });
  if (isactive && found) quotes.each ( function (index) {
    if (isactive) {
      quoteActive = index;
      isactive = false;
    } 
    if (index == el_id) { isactive = found = true; }
  });
  $(el_id).hide();
  new Effect.Appear(quoteActive);
  setTimeout('quoteChange()',8000);
}

/********** client slideshow (footer) *********/ 
function clients_slideshow(n,m) {
	if ($('set_'+n+'_first').iamactive) {
		newclient = 'set_'+n+'_sec';
		oldclient = 'set_'+n+'_first';
		
	} else {
		newclient = 'set_'+n+'_first';
		oldclient = 'set_'+n+'_sec';
	}
	
	$(newclient).style.zIndex = 101;
	$(oldclient).style.zIndex = 100;
	
	$(newclient).iamactive = true;
	$(oldclient).iamactive = false;
	
	for (i = 0; i < clients_number+1; i++) if ($(newclient).hasClassName('client_'+i)) $(newclient).removeClassName('client_'+i);
	$(newclient).addClassName('client_'+m);
	
	$(newclient).hide();
	new Effect.Appear(newclient);
	new Effect.Fade(oldclient);
	
	timeouts[n] = [];
	m =Math.floor( Math.random() * (clients_number + 1));
	while (timeouts[0]['v'] == m || timeouts[1]['v'] == m || timeouts[2]['v'] == m ) m =Math.floor( Math.random() * (clients_number + 1));
	//alert(n+','+m+','+clients_number);
	timeouts[n]['v'] = m;
	if (n == 0) {
		timeouts[n]['t'] = setTimeout("clients_slideshow(0,timeouts[0]['v'])",6000+Math.floor( Math.random() * 3000));
	}	else if (n == 1) {
		timeouts[n]['t'] = setTimeout("clients_slideshow(1,timeouts[1]['v'])",6000+Math.floor( Math.random() * 3000));
	}	else if (n == 2) {
		timeouts[n]['t'] = setTimeout("clients_slideshow(2,timeouts[2]['v'])",6000+Math.floor( Math.random() * 3000));
	}
			
}

/**************** banner menus ****************/

function banner_show( name ) {
	banner_current = name;
	$('u_'+name).className = '';
}
function banner_hide( name ) {
	banner_current = '';
	window.setTimeout(function () { 
			//alert(name);
			if (banner_current != name) $('u_'+name).className='hidden';
		}
		,100);
}


startList = function() {
    if (document.all&&document.getElementById) {
        navRoot = document.getElementById("banner_menu");
        for (i=0; i<navRoot.childNodes.length; i++) {
            node = navRoot.childNodes[i];
            if (node.nodeName=="LI") {
                node.onmouseover=function() {
                    this.className+=" over";
                }
                node.onmouseout=function() {
                    this.className=this.className.replace(" over", "");
                }
            }
        }
    }
}

window.onload=startList;

/**************** END BANNER MENUS ************/
function hide_all_submenus() {
    // hide all submenus which will not in "active" class    
}
var arrTemp=self.location.href.split("?");
var picUrl = (arrTemp.length>0)?arrTemp[1]:"";
var NS = (navigator.appName=="Netscape")?true:false;
var NS = ((!document.all)||window.opera)?true:false;

function AutoSize() {
	var iWidth = (NS)?window.innerWidth:document.documentElement.clientWidth;
	var iHeight = (NS)?window.innerHeight:document.documentElement.clientHeight;
	iWidth = document.images[0].width - iWidth + 30;
	//iHeight = document.images[0].height - iHeight;
	iHeight = 700-iHeight;
	window.resizeBy(iWidth, iHeight);
	self.focus();
	window.focus();
};
/*
function popup ( url ) {
    window.open(url,'Product','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=760,height=500,top=30,left=20');
}
*/
function closewindow() {
    window.close();
}

function javascript_on() {
    $('nojavascript').hide();
}

function showhide( id ) {
    if ($(id).hidden) {
        $(id).show();
        $(id).hidden = false;
    } else {
        $(id).hide();
        $(id).hidden = true;
    }
}

function add_notifies_and_errors( notifies, errors) {
	
}
function clear_main_search() {
	if ($F('menu_search_query') == 'search') $('menu_search_query').value = '';


}