
function setFolder( folder_nbr, total ) {
	    for (i=0; i<total; i++) {
	      document.getElementById("op"+i).style.display="none";
		  document.getElementById("op"+i+"m").parentNode.className="tab";
	      document.getElementById("op"+i+"td").style.borderBottom = "1px solid #424245";
	    }
	    
	    var el1 = document.getElementById("op"+folder_nbr);
	      el1.style.display = "block";
	    var el2 = document.getElementById("op"+folder_nbr+"m");
	      if (el2.parentNode.className == "tab") {
	      	el2.parentNode.className="tabA";
	       }
	    var el3 = document.getElementById("op"+folder_nbr+"td");
	      el3.style.borderBottom = "0";
}

function CUIPopUp( cui_url, cui_parameters, popname )
	 {
		 if( popname != '' )
		 {
			 var usename = popname;
		 }
		 else
		 {
			 var random_windowname = Math.round( ( Math.random() * 100 ) );
			 var usename = 'CUIpop' + random_windowname;
		 }
		 newWindow = window.open( cui_url, usename, cui_parameters );
	 }
	 function CUIImageChange( cui_img_name, cui_img_src )
	 {
		 if( document.images[ cui_img_name ] )
		 {
			 document.images[ cui_img_name ].src = cui_img_src;
		 }
	 }

var fname = '';
function checkConForm( fname )
{
	var fe = document.forms[ fname ].elements;
	if( fe )
	{
		if( fe.length > 0 )
		{
			if( fe[ 'send_name' ].value == '' || fe[ 'send_title' ].value == '' || fe[ 'send_company' ].value == '' || fe[ 'send_country' ].options[ fe[ 'send_country' ].selectedIndex ].value < 1 || fe[ 'send_message' ].value == '' || fe[ 'send_email' ].value.indexOf( '.' ) == -1 || fe[ 'send_email' ].value.indexOf( '@' ) == -1 )
			{
				window.alert( 'Required information is missing! All fields are required.' );
				return false;
			}
			return true;
		}
	}
	return false;
}


google.load("jquery", "1.2");
		var currnews = 0;
		var newstimer = 0;
		var newsrotate = true;
		function fadeNews() {
			clearTimeout( newstimer );
			var len = $('#frontnews .newsticker').length;
			if( newsrotate && len > 0 ) {
				$('#frontnews .newsticker:eq('+currnews+')').animate({opacity: 0}, function() {
					$(this).css({display: 'none'});
					if( currnews < len - 1 ) currnews++;
					else currnews = 0;
					$('#frontnews .newsticker:eq('+currnews+')').css({display: 'inline'});
					$('#frontnews .newsticker:eq('+currnews+')').animate({opacity: .999});
				});
			}
			newstimer = setTimeout( "fadeNews()", 5000 );
		}
		
		function initFadeNews() {
			var len = $('#frontnews span.newsticker').length;
			$('#frontnews').mouseover( function() {
				newsrotate = false;
			});
			$('#frontnews').mouseout( function() {
				newsrotate = true;
			});
			currnews = 2;
			$('#frontnews span.newsticker').css({display: 'none', opacity: 0});
			if( len > 0 ) fadeNews();
		}
		
		function startList() {
			if ( document.all && document.getElementById ) {
				if ( navRoot = document.getElementById("navi") ) {
					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 = setTimeout( this.className.replace (" over", ""), 5000 );
						  		}
						 } 
					} 
				}
			}
		}
		
		function reDrawCarouselIndicators( total, current ) {
			var images = "";
			for ( var i = 1; i <= total; i++ ) {
				if ( i != current ) {
					images = images + "<img src=\"http://www.elektrobit.com/docs/templates/graf/carousel_inactive.gif\" width=\"7\" height=\"7\"> ";
				} else {
					images = images + "<img src=\"http://www.elektrobit.com/docs/templates/graf/carousel_active.gif\" width=\"7\" height=\"7\"> ";
				}
			}
			$('#bannercounter').html( images );
		}
		
	function browserCheck() {
		this.br = navigator.appName.toLowerCase();
		this.version = navigator.appVersion.toLowerCase();
		this.agent = navigator.userAgent.toLowerCase();
		this.platform = navigator.platform.toLowerCase();
		this.major = parseInt(navigator.appVersion);
		this.minor = parseFloat(navigator.appVersion);
		this.is_opera = (this.agent.indexOf('opera') != -1);
		this.is_ns = (this.br == 'netscape' && !this.is_opera);
		this.is_ie = (this.br == 'microsoft internet explorer' && !this.is_opera);
		this.is_ns4 = (this.is_ns && this.major == 4 && !this.is_opera);
		this.is_ns6 = (this.is_ns && this.major == 5 && !this.is_opera);
		this.is_ie4 = (this.version.indexOf('msie 4.0') != -1 && !this.is_opera);
		this.is_ie5 = (this.version.indexOf('msie 5.0') != -1 && !this.is_opera);
		this.is_ie6 = (this.version.indexOf('msie 6.0') != -1 && !this.is_opera);
		this.is_windows = (this.platform.indexOf('win') != -1);
		this.is_mac = (this.agent.indexOf('mac') != -1);
		this.is_linux = (this.platform.indexOf('linux') != -1 || this.platform.indexOf('x11') != -1) ? true:false;
		this.is_dom = (document.getElementById) ? true:false;
		this.is_firefox = (this.agent.indexOf('firefox') != -1 );
		this.is_mozilla = (this.agent.indexOf('gecko') != -1 && !this.is_firefox );
	}
		
		window.onload = function() {
			br = new browserCheck();
			initFadeNews();
			startList();
			var activeCarousel = 1;
			var totalCarousel = ($('#carouselcontainer').children().size());
			if ( totalCarousel == 1 ) {
				$('#carousel_next').css('display', 'none');
			} 
			reDrawCarouselIndicators( totalCarousel, activeCarousel );
			//randomImage();
			/*
			$('#navi li').hover( function() {
				sIFR.replace(amplitude_cond, { selector: '.subwrap',css: ['.sIFR-root { font-size:14px; font-weight:normal; color:#cdcdce; }','a { text-decoration:none; color:#cdcdce; }','a:hover { text-decoration:none; color:#cdcdce; }','a:visited { text-decoration:none; color:#cdcdce; }'],fitExactly: 'true', wmode: 'transparent' });
			});*/
			/*
			if ( navigator.appName.toLowerCase() != 'microsoft internet explorer' ) {
				$('#navi li').mouseover( function() {
					$('#navi li div').css('display', 'none');
					$(this).addClass("act");
					$(this).children("div").css('display', 'block');
				});
				$('#navi li').mouseout( function() {
					$(this).removeClass();
					//$(this).children("div").fadeOut("slow");
					var action = $(this).children("div").css('display', 'none');
					var timer = setTimeout( action, 1000 );
				});
				$('#navi li div').mouseover( function() {
					$(this).parent().addClass("act");
				});
				$('#navi li div').mouseout( function() {
					$(this).parent().removeClass();
					$(this).css('display', 'none');
				});
			}	*/
			// Etusivun Wireless ja Automation-nostot
			      $('#front_liftup_left').hover( function () {
			        $('#front_liftup_left div.liftup_readmore').slideDown(300);
			      }, 
			      function () {
			        $('#front_liftup_left div.liftup_readmore').slideUp(300);
			      });
			      
			       $('#front_liftup_right').hover( function () {
			        $('#front_liftup_right div.liftup_readmore').slideDown(300);
			      }, 
			      function () {
			        $('#front_liftup_right div.liftup_readmore').slideUp(300);
			      });
			// Etusivun alasvetovalikot
				$('.frontmenuheader_right').click().toggle( function() {
					$(this).css('backgroundImage','url(http://www.elektrobit.com/docs/templates/graf/front_menu_headerbg_active.jpg)');
					$('.frontmenucontent_right').slideDown("normal");
					}, 
			      function () {
			        $('.frontmenucontent_right').slideUp("normal");
			      	if ( br.is_ie6 ) {
			    		$(this).css('backgroundImage', 'url(http://www.elektrobit.com/docs/templates/graf/front_menu_headerbg_r.jpg)');
			    	} else {			
						$(this).css('backgroundImage', 'url(http://www.elektrobit.com/docs/templates/graf/front_menu_headerbg.png)');
					}
			      });
			      
			      $('.frontmenuheader_left').click().toggle( function() {
					$(this).css('backgroundImage','url(http://www.elektrobit.com/docs/templates/graf/front_menu_headerbg_active.jpg)');
					$('.frontmenucontent_left').slideDown("normal");
					}, 
			      function () {
			        $('.frontmenucontent_left').slideUp("normal");
			      	if ( br.is_ie6 ) {
			    		$(this).css('backgroundImage', 'url(http://www.elektrobit.com/docs/templates/graf/front_menu_headerbg_l.jpg)');
			    	} else {			
						$(this).css('backgroundImage', 'url(http://www.elektrobit.com/docs/templates/graf/front_menu_headerbg.png)');
					}
			      });
			      
			      // Alasvetovalikon hover-efekti
			    $('.frontmenuheader_left').hover( function() {		
			    	if ( br.is_ie6 ) {
			    	$(this).css('backgroundImage', 'url(http://www.elektrobit.com/docs/templates/graf/front_menu_headerbg_l_hover.jpg)');
			    	} else {			
					$(this).css('backgroundImage', 'url(http://www.elektrobit.com/docs/templates/graf/front_menu_headerbg_hover.png)');
					}
				    $(this).css('cursor', 'pointer');
				      }, 
			      function () {
					if ( br.is_ie6 ) {
						$(this).css('backgroundImage', 'url(http://www.elektrobit.com/docs/templates/graf/front_menu_headerbg_l.jpg)');
					} else {
						$(this).css('backgroundImage', 'url(http://www.elektrobit.com/docs/templates/graf/front_menu_headerbg.png)');
					}
					$(this).css('cursor', 'arrow');
			    });
			    $('.frontmenuheader_right').hover( function() {		
				    if ( br.is_ie6 ) {
			    	$(this).css('backgroundImage', 'url(http://www.elektrobit.com/docs/templates/graf/front_menu_headerbg_r_hover.jpg)');
			    	} else {			
					$(this).css('backgroundImage', 'url(http://www.elektrobit.com/docs/templates/graf/front_menu_headerbg_hover.png)');
					}
				    $(this).css('cursor', 'pointer');
				      }, 
			      function () {
					if ( br.is_ie6 ) {
						$(this).css('backgroundImage', 'url(http://www.elektrobit.com/docs/templates/graf/front_menu_headerbg_r.jpg)');
					} else {
						$(this).css('backgroundImage', 'url(http://www.elektrobit.com/docs/templates/graf/front_menu_headerbg.png)');
					}
					$(this).css('cursor', 'arrow');
			    });
			      
			// Tuotenostokaruselli
			 /* if ( $('carouselarea') ) {
			  	$('#carouselarea div:first').css('display', 'block');
				if ( br.is_ie6 ) {
					DD_belatedPNG.fix('.carousel');
				}
			  	reDrawCarouselIndicators( totalCarousel, activeCarousel );
			  }*/
			    var img_w = 360; // carousel image width
				var img_speed = 900; // carousel image speed
				
				jQuery.easing.easeOutQuart = function (x, t, b, c, d) { 
				    return -c * ((t=t/d-1)*t*t*t - 1) + b; 
				}; 
				var min_x_about = (totalCarousel-1) * img_w;
			  
			    $('#carousel_prev').click(function(){
			  	if ( activeCarousel > 1 ) {
			  		$('#carousel_prev').css('display', 'block');
			  		$('#carousel_next').css('display', 'block');
				  	var le = parseInt($("div#carouselcontainer").css('left'));
					if (le < 0)
						$("div#carouselcontainer").animate({"left": "+="+img_w+"px"}, img_speed, 'easeOutQuart');
			  		activeCarousel--;
			  		if ( activeCarousel == 1 ) {
				  		$('#carousel_prev').css('display', 'none');
				  		$('#carousel_next').css('display', 'block');
			  		}
			  		reDrawCarouselIndicators( totalCarousel, activeCarousel );
			  	} 
			  });
			  
			  $('#carousel_next').click(function(){
			  	if( activeCarousel < totalCarousel ) {
			  		$('#carousel_next').css('display', 'block');
			  		$('#carousel_prev').css('display', 'block');
			  		var le = parseInt($("div#carouselcontainer").css('left'));
					if (le > -min_x_about)
						$("div#carouselcontainer").animate({"left": "-="+img_w+"px"}, img_speed, 'easeOutQuart');
			  		activeCarousel++;
			  		if ( activeCarousel == totalCarousel ) {
				  		$("#carousel_next").css({display: 'none'});
			  			$("#carousel_prev").css({display: 'block'});
			  		}
			  		reDrawCarouselIndicators( totalCarousel, activeCarousel );
			  	}
			  });
			  
			  /*
			  
			  $('#carousel_prev').click(function(){
			  	if ( activeCarousel > 1 ) {
			  		$($('#carouselarea').children().eq((activeCarousel-1))).hide();
			  		activeCarousel--;
			  		//alert("Näytetään edellinen banneri ("+activeCarousel+")");
			  		$($('#carouselarea').children().eq((activeCarousel-1))).show();
					if ( br.is_ie6 ) {
						DD_belatedPNG.fix('.carousel');
					}
			  		reDrawCarouselIndicators( totalCarousel, activeCarousel );
			  	} else {
			  		//alert("Ei voida näyttää edellistä banneria ("+activeCarousel+")");
			  	}
			  });
			  
			  $('#carousel_next').click(function(){
			  	if( activeCarousel < totalCarousel ) {
			  		$($('#carouselarea').children().eq((activeCarousel-1))).hide();
			  		activeCarousel++;
			  		$($('#carouselarea').children().eq((activeCarousel-1))).show();
			  		//alert("Näytetään seuraava banneri ("+activeCarousel+")");
			  		reDrawCarouselIndicators( totalCarousel, activeCarousel );
			  	}else {
			  		//alert("Ei voida näyttää seuraavaa banneria ("+activeCarousel+")");
			  	}
			  });
			*/	    
		 	if ( $('#frontbanner_text').children().length == 1 && $('#frontbanner_image').children().length == 0 ) {
		 		$('#frontbanner').css('display', 'none');
		 	}
		 	if ( $('#frontbanner_text2').children().length == 1 && $('#frontbanner_image2').children().length == 0 ) {
		 		$('#frontbanner2').css('display', 'none');
		 	}
		}