// Initialize Flash
function initFlash() 
{
  if ($("home-intro")) {
    var FO = {movie: "./images/flash/home-intro.swf", width:"770", height:"300", majorversion:"7", build:"0", wmode: "opaque"};
    UFO.create(FO, "home-intro");
  }
  
  if ($("home-products")) {
    var FO = { movie: "./images/flash/home-products.swf", width:"426", height:"177", majorversion:"7", build:"0", wmode: "transparent"};
    UFO.create(FO, "home-products");
  }
}

/* Tracing function for jsTrace() - http://www.easy-designs.net/code/jsTrace/ */
function trace( msg ){
  if( typeof( jsTrace ) != 'undefined' ){
    jsTrace.send( msg );
  }
}

// Cancel default action
function stopEvent(e) {
  if (window.event) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  
  if (e && e.stopPropagation && e.preventDefault) {
    e.stopPropagation();
    e.preventDefault();
  }
}



function initNav() 
{
  if(!$('nav')) {
    return;
  }

  var toggles = $S('.toggle');
  var subs = $S('.sub');

  subs.each(function(el, i) {

if(currentOpen){
	if(currentOpen != i+1){
		
		el.addClass('hide');

	}

}else{

	el.addClass('hide');


}


	  
      toggles[i].addEvent('click', function(e) {
											
        if (el.hasClass('hide')) {
			var opened = false;
		} else {
			var opened = true;
		}
		
		subs.each(function(el) {
          el.addClass('hide');
        }) 											
		
		if (opened) {
	      el.addClass('hide');
		} else {
		  el.removeClass('hide');
		}
		
	    stopEvent(e);	  
      });
  });
}






function initHomeIcons() 
{
  if(!$('welcome')) {
    return;
  }
 
  var icontoggles = $S('.icontoggle');
  var iconcontents = $S('.iconcontent');
  
  iconcontents.each(function(el, i) {
      el.addClass('hide');
      icontoggles[i].addEvent('click', function(e, i) {
 
        if (this.hasClass('open')) {
			var opened = true;
		} else {
			var opened = false;
		}
		
        icontoggles.each(function(el) {
          el.removeClass('open');
        });

        iconcontents.each(function(el) {
          el.addClass('hide');
        });
		
		if (opened) {
		  this.removeClass('open');
		  $('welcome-content').removeClass('hide');
		  $('below').removeClass('belowhide');
		  el.addClass('hide');
		} else {
		  this.addClass('open');	
		  $('welcome-content').addClass('hide');
		  $('below').addClass('belowhide');
		  el.removeClass('hide');
		}
        
	    stopEvent(e);	  
      });
  });
}

function setHome(){


    
/*

for(i=1; i<=5; i++){
		document.getElementById("iconDiv"+ i).style.visibility="hidden";
		document.getElementById("iconDiv"+ i).style.height="0";
		document.getElementById("welcome-content").style.height="220";
	
	}
*/
}


function homeIcons(icon){
	
/*	document.getElementById("welcome-content").style.visibility="hidden";
	document.getElementById("welcome-content").style.height="0";

	for(i=1; i<=5; i++){
		document.getElementById("iconDiv"+ i).style.visibility="hidden";
		document.getElementById("iconDiv"+ i).style.height="0";
	}
		
		document.getElementById("iconDiv"+ icon).style.visibility="visible";
		document.getElementById("iconDiv"+ icon).style.height="220";
*/		

}


//window.addEvent('load', initNav);
window.addEvent('load', initHomeIcons);
window.addEvent('load', initFlash);


