﻿
function nav_main()
{
	// make transparent
	$("#selector").animate({opacity:0.0}, 1);
	
	// bind mouseenter, mouseleave events
	$("#link1").bind("mouseenter",function(){
        $("#selector").stop().animate({left:"10px", width:"426px", opacity:1.0}, 400);
    }).bind("mouseleave",function(){
    	$("#selector").stop().animate({left:"450px", width:"0px", opacity:1.0}, 300);
    });
	$("#link2").bind("mouseenter",function(){
        $("#selector").stop().animate({left:"464px", width:"426px", opacity:1.0}, 400);
    }).bind("mouseleave",function(){
    	$("#selector").stop().animate({left:"450px", width:"0px", opacity:1.0}, 300);
    });
}

var timer = 0;
var sol_not_equip = true;
var divider = true;
var ranNum = 0;
var prev_s = 0;
var prev_e = 0;
function change_background()
{
	var img_dir = "http://www.dec-it.ro/_img/bkgs/";

	if (sol_not_equip)
	{
	    // SOLUTII
		// make sure the new bkg is not the same as the previous one (or the same index as the other category's bkg)
		while ((ranNum == prev_s) || (ranNum == prev_e))
			ranNum= Math.floor(Math.random() * 10);		// 0 to 9
		
		// change bkg
		$("#s1").animate({opacity:0.0},"200",function()
			{
				setTimeout(function()
				{
					$("#s1").css("background", "url(" + img_dir + "solutii_" + ranNum + ".jpg)");
				},200)
			});
		setTimeout(function(){$("#s1").animate({opacity:1.0},"200");},600);
		// change text
		$("#overtext1").animate({opacity:1.0},"200",function()
			{
				setTimeout(function()
				{
					//$("#txt1").text(txt_s[ranNum]);
					$("#txt1").text($("#uls li").eq(ranNum).text());
				},200)
			});
		setTimeout(function(){$("#overtext1").animate({opacity:0.0},"200");},600);

		// prepare for next function call
		sol_not_equip = false;
		prev_s = ranNum;

	}
	else
	{
	    // ECHIPAMENTE
		// make sure the new bkg is not the same as the previous one (or the same index as the other category's bkg)
		while ((ranNum == prev_s) || (ranNum == prev_e))
			ranNum= Math.floor(Math.random() * 11);		// 0 to 10
		
		// change bkg
		$("#s2").animate({opacity:0.0},"200",function()
			{
				setTimeout(function()
				{
					$("#s2").css("background", "url(" + img_dir + "echipamente_" + ranNum + ".jpg)");
				},200)
			});
		setTimeout(function(){$("#s2").animate({opacity:1.0},"200");},600);
		// change text
		$("#overtext2").animate({opacity:1.0},"200",function()
			{
				setTimeout(function()
				{
					//$("#txt2").text(txt_e[ranNum]);
					$("#txt2").text($("#ule li").eq(ranNum).text());
				},200)
			});
		setTimeout(function(){$("#overtext2").animate({opacity:0.0},"200");},600);

		// prepare for next function call
		sol_not_equip = true;
		prev_e = ranNum;

	}
    timer = setTimeout("change_background();",3000);	// 3000 miliseconds
}

function doStuff()
{

	$("#body").fadeIn("slow");
	$("body").css("background","#f3f3f3");

	//nav_main();	/* commented out 20090824 :-< */
	change_background();
}