
//$.noConflict();
// 853  573

// 600x610 da grande
// 340x614 da piccolo

// la v in 250 x 560
var logindsp=false;
var bodyorange="e5653f";
var bodyblue="003758";
var aziende=null;
var tetratopl;
var stopmouse=false;
var imgdiv;

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)



$(function($){


//var preload = $('<div onload="alert();" id="preload"><img src="img/companyw10.jpg"><img src="img/personw.jpg"><img src="img/company.jpg"><img src="img/person.jpg"></div>');

//pic1.onload="alert('a');";


//pic1=new Image(); pic1.src="img/companyw10.jpg";
//pic2=new Image(); pic2.src="img/personw.jpg";

//$("#right").attr("onload","alert('a');");
//$("#right").css("background-image","url('img/company.jpg')");
//$("#left").css("background-image","url('img/person.jpg')");

/*<img src="img/companyw10.jpg">
<img src="img/personw.jpg">
<img src="img/company.jpg">
<img src="img/person.jpg">
*/

jQuery.preLoadImages("img/personw.jpg", "img/companyw10.jpg");



$("#logol").click ( function () { window.location.reload( false );});
$("#logor").click ( function () { window.location.reload( false );});
$("#clogo").css("top",32);
$("#clogo").css("left",$(window).width()/2-125);
$("#clogos").css("top",$("#clogo").position().top);
$("#clogos").css("left",$(window).width()/2-125);
$("#left").animate({"backgroundPosition":"-200 0"});
$("#right").animate({"backgroundPosition":"-360 0"});

//$("#footer").css("top",divh-$("#footer").height()-1);
//$("#footer").css("position","absolute");
//alert(($(document).width()-$("#footer").width())/2 + "px");
//$("#footer").css("left",($(document).width()-$("#footer").width())/2 + "px");


$("#navpiccolo").css("top",$("#clogos").position().top+10+"px");
$("#navpiccolo").css("left",$("#clogos").position().left+$("#clogos").width()+20+"px"	);


	
	
$("#navpiccolo").hover(function () {
$("#fumettonav").css("top",$("#navpiccolo").offset().top+80 + "px");
$("#fumettonav").css("left",$("#navpiccolo").offset().left-340 + "px");
	$("#fumettonav").fadeIn();
	},function () {
	$("#fumettonav").fadeOut();
	});





$("#cem").click(function () {
	$("#schermos").attr("src","img/noi.png");
	$("#schermos").attr("width",480);
		$("#schermos").attr("height",290);
});
$('#ccg').fadeOut();
$("#vr").fadeIn();
	$("#vl").fadeIn();
	
	$("#vrt").fadeIn();
		$("#vlt").fadeIn();
	
$("#vrt").width($("#vr").width());
$("#vlt").width($("#vl").width());

$("#vrt").height($("#vr").height());
$("#vlt").height($("#vl").height());

$("#vrt").css("top",$("#vr").position().top+"px");
$("#vrt").css("left",$("#vr").position().left+"px");

$("#vlt").css("top",$("#vl").position().top+"px");
$("#vlt").css("left",$("#vl").position().left+"px");

	
innerwidth=$("#inner").width();
tetrawidth=$("#tetrapack").width();
tetratopl=(innerwidth/2)-(tetrawidth/2);
$("#tetrapack").css("left",tetratopl);

$("#tetrapack").animate({"opacity":1},1000);



themecolor(bodyblue);
$("body").mousemove(mouseBackground);

$("#left").click(vai);
$("#right").click(vai);
$("#navpiccolo").click(vai);



	//add your code here

function vai () {

if (stopmouse) return;

stopmouse=true;
$("#footer").css("position","absolute");
$("#footer").fadeOut();
$("#fumettonav").fadeOut();
$("*").stop(true,true);
vais();
//window.setTimeout(vais, 250);
}
function vais() {
$("#navpiccolo").fadeOut(250);
$("#logor").fadeOut(0);
$("#logol").fadeOut(0);
$("#vr").fadeOut(0);
$("#vl").fadeOut(0);
$("#vrt").fadeOut(0);
$("#vlt").fadeOut(0);

$("#clogos").fadeOut();
$("#clogo").fadeOut();
if (aziende) {
  div=$("#right");
  otherdiv=$("#left");
div.css("backgroundPosition","-370px 0px");
      div.css("background-image","url('img/companyw10.jpg')");
	
      imgdiv=$("#logor");

  }
  else {
  div=$("#left");
        imgdiv=$("#logol");
    otherdiv=$("#right");
      div.css("background-image","url('img/personw.jpg')");
      }
      imgdiv.detach();
  div.removeClass("clickable");
    otherdiv.removeClass("clickable");
  bw=$(document).width();
  bh=$(document).height();
  oldt=div.offset().top;
    oldl=div.offset().left;
    try {
    themecolor("FFFFFF");
    $("#tetrapack").animate({"backgroundColor":"#ffffff"});
  } catch (e) {alert("CHECK2: " + e);}
    otherdiv.animate({"opacity":0,"width":250},{complete: function () {
    $("#outer1").animate({"top":0,"left":0,"width":div.width(),"height":div.height(),"backgroundPosition":"0 0"},{duration:1000,easing: "easeOutBounce", complete: function () {
    bw=$(document).width();
    bh=$(document).height();
    oldt=div.offset().top;
      oldl=div.offset().left;
		
	    div.css("position","absolute");
	    div.css("top",oldt);
	    div.css("left",oldl);
        div.css("width","600px");
        div.css("height","600px");
        div.css("margin","0 0 0 0");
	    div.detach();
	    $("#outer3").remove();
	    div.appendTo("#zoomed");
	    
	   div.css("z-index","-1");
		
		//imgdiv.click(function () {window.location.reload()});
		
		
		backpos=-50;
		if (aziende) backpos=-50;
		divw=$(document).width();
		divh=$(document).height();
		
		divw=divw<1000?1000:divw;
divh=divh<650?650:(divh>713?713:divh);
		div.animate({"top":0,"left":0,"width":divw,"height":divh,"backgroundPosition": backpos + " 0"},{duration:1000,easing: "easeOutExpo",complete: function (){

		imgdiv.appendTo("body");

//	imgdiv.attr("id", "logo");
		if (aziende) {
		imgdiv.css("left",$('#pannellobiancoc').offset().left);
		imgdiv.fadeIn();
		doAziende();
		
		
		}
		else
		doPersone();
		
		} });
}});
	}});
}

function daccidentro(){

if (aziende) {
doAziende();

}
else
doPersone();

}


function themecolor(thiscolor) {
if (stopmouse) return;
$("#outer1").animate({"backgroundColor": "#DDDDDD"});
$("body").animate({"backgroundColor":"#"+thiscolor},{ complete:function () {
	$("body").animate({"backgroundColor": "#"+thiscolor});
	$("#outer3").animate({"backgroundColor": "#"+thiscolor});
	$("#outer2").animate({"backgroundColor": "#"+thiscolor});
	//$("#outer1").animate({"backgroundColor": "#"+thiscolor});
	//$("#inner").animate({"backgroundColor": "#"+thiscolor});
	
	$("#inner").animate({"backgroundColor": "#ffffff"});
	$("#outer3").animate({"backgroundColor": "#"+colorscale(thiscolor,1)});
	$("#outer2").animate({"backgroundColor": "#"+colorscale(thiscolor,1)});
	//$("#outer1").animate({"backgroundColor": "#"+colorscale(thiscolor,1)});

}});}

function innerMove(isAziende) {
if (stopmouse) return;
innertop=$("#inner").position().top;
innerleft=$("#inner").position().left;
if (isAziende) {
	themecolor(bodyorange);
	//$("#navpiccolo").fadeIn();
	$("#tetrapack").animate({"left":(tetratopl-123)},{duration:1000, easing: "easeOutExpo", complete: function() {
		
		}});
	$("#left").animate({"backgroundPosition":"-200 0"});
	$("#right").animate({"backgroundPosition":"-200 0"});
	//$("#vr").css("left",750+innerleft);
	//$("#vr").css("top",360+innertop);
	$("#vr").animate({"left":"730"});
	$("#vl").animate({"left":"130"});
	$("#vrt").animate({"left":"730"});
	$("#vlt").animate({"left":"130"});
	//$("#logor").fadeIn(2000);
	}
	else {
	themecolor(bodyblue);
	$("#navpiccolo").fadeOut(250);
		$("#tetrapack").animate({"left":(tetratopl+130)},{duration:1000,easing: "easeOutExpo", complete: function() {
			
			}});
		$("#left").animate({"backgroundPosition":"-350 0"});
		$("#right").animate({"backgroundPosition":"-450 0"});		
		
		$("#vr").animate({"left":"670"});
			$("#vl").animate({"left":"70"});
			$("#vrt").animate({"left":"670"});
				$("#vlt").animate({"left":"70"});
		//$("#vl").css("left",250+innerleft);
		//$("#vl").css("top",360+innertop);
		
		//$("#logol").fadeIn(2000);
	}
		

}


function mouseBackground(event) {
if (stopmouse) return 0;
innerleft=$("#right").offset().left;
//document.title = innerleft;
width=$(document).width();
height=$(document).height();
oldaziende=aziende;
if (event.pageX > innerleft) 
	aziende=true;
	else
	aziende=false;

if (oldaziende != aziende) {
	stopAllBacks();
	//$("#vr").fadeOut();
	//$("#vl").fadeOut();
	$("#logol").fadeOut(500);
	$("#logor").fadeOut(500);
	innerMove(aziende);
}
  
}

function stopAllBacks() {
try {
$("#inner").stop();
$("#outer1").stop();
$("#outer2").stop();
$("#outer3").stop();
$("body").stop();
$("#left").stop();
$("#right").stop();
$("#tetrapack").stop();
$("#tetrapack").css("opacity","1");
$("#logor").stop(true,true);
$("#logol").stop(true,true);
$("#vl").stop(true,true);
$("#vr").stop(true,true);
$("#vlt").stop(true,true);
$("#vrt").stop(true,true);
//$("*").stop(true,true);
}
catch (e) {alert("CHECK3: " + e);}
}

function mettifreccia(div) {
	divleft=div.offset().left;
	divtop=div.offset().top;
	/*
	$("#frecciadx").css("top",divtop);
	$("#frecciadx").css("left",divleft-150 +"px");
	$("#frecciadx").css("opacity",1);*/
}

function entrafreccia(func) {

$("#frecciadx").animate({"left":"+=150"},{complete: func});

}

function frecciainsu(div,func) {

div.css("top",70);
div.css("opacity",1);
div.animate({"top":0},{complete: func});
}

function doAziende() {
try {
divw=$(document).width();
divh=$(document).height();
divw=divw<1000?1000:divw;
divh=divh<650?650:(divh>713?713:divh);
afinestra=$('<div id="afinestra"></div>');
afinestra.css("width",divw);
afinestra.css("height",divh);
$("#zoomed").append(afinestra);
$("#loginfrm").attr("action","/index_az.php?p=1");

$("#mydoreg").attr("href","/ana_mod.php");

//$("#username").attr("name","username");
//$("#password").attr("name","pwd");
$("#username").remove();
$("#password").remove();
//$("#password_dimenticata").remove();
$("#usertxt").after('<br /><input id="username" name="username" type="text">');
$("#pwdtxt").after('<br /><input id="password" name="pwd" type="password">');
$("#password_dimenticata").after('<a href="/recpwdaz.php" style="font-size: 13px; color:#00A; font-decoration: underline;">Password dimenticata?</a>');


$("#percorso").animate({"opacity":1},{ complete: function () {
	$("#vantaggi").animate({"opacity":1}, {	 complete:function () {
			$("#costi").animate({"opacity":1});
if (!msie) {
				$("#percorso").css("backgroundImage","url(img/box.png) ");
} else $("#percorso").css("backgroundImage","url('../img/box.gif') ");
		
			}});
		}});



$("#right").animate({"backgroundPosition":"-50 0"});
$("#usertxt").text("Username");
$("#rapidodiv").css("top",imgdiv.position().top+70);
$("#rapidodiv").css("left",imgdiv.position().left+50);
$("#rapidodiv").slideUp();

$("#rapidodiv").slideDown();
$("#hiddenrapidodiv").css("display","none");
$("#hiddenrapidodiv").fadeOut();
} catch (e) {alert("CHECK4: " + e);}
$("#username").click(function () {
logindsp=true;
$("#hidden2rapidodiv").slideDown();

});

$("#rapido").click( function () {
$('#ccg').fadeOut(function () {
	$('#ccg').remove();
	});

	$("#rapido").fadeOut(250,function () {
	logindsp=true;
		$("#hiddenrapidodiv").slideUp();
		$("#hiddenrapidodiv").slideDown();
		//$("#hidden2rapidodiv").css("display","none");

	});
});

//imgdiv.click(showLogin);
$("#pannellobiancoc").animate({"height":"100%"}, {complete: function () {

	$("#sloganav").css("top",imgdiv.position().top+"px");
		$("#sloganav").css("left",imgdiv.position().left+imgdiv.width()+120+"px");
			$("#sloganav").fadeIn(function() {
			imgdivleft=$(window).width()>1280?1280:$(window).width();
			$("#sloganarancio").css("left",imgdivleft-$("#sloganarancio").width()+"px");
//			$("#sloganav").css("top","px");
			$("#help").fadeIn();
			$("#sloganarancio").fadeIn();
			$('#ccg').css("top","184px");
			$('#ccg').css("left","147px");
			$('#ccg').fadeIn();
$("#footer").css("top",$("#sloganarancio").offset().top+$("#sloganarancio").height());
$("#footer").css("left",363); //$("#pannellobiancoc").offset().left+$("#pannellobiancoc").width());
//$("#footer").css("width",644);
$(".testo1").css("color","#"+bodyblue);
$(".testo1 a:hover").css("color","#0f0");
$("#footer").fadeIn();			
			});
			
	}});
$("#flussocompany").fadeIn()
	$("#percorso").animate({"opacity":1},{complete: function () {$("#frecciofila").fadeIn();}});
	
	
	

		//$("#percorso > IMG").animate({"opacity":1});
	mettifreccia($("#percorso"));
	$("#percorso").addClass("clickable");	

	

	
	/*$("div.sliding").click(function () {

 //div=$("#contenuti > DIV  > DIV");
//div.animate({"width":0,"margin-left":0});
$(this).animate({"width":0,"margin-left":0,"opacity":0},{easing: "easeInExpo", complete: advanzare});

 //	div.remove();
	/*$("#contenuti > DIV  > DIV").animate({"width":0,"margin-left":0},{complete: function() {
	//alert($(this).attr('id'));
	//$(this).remove();}});
	*/
	//});
	
	
	$("#percorso").click(function () {
	/*$("#navhere").fadeOut(function () {
	//$("#navigatore").css("display","block");
		$("#schermos").attr("src","img/bianco.png");
	$("#navhere").fadeIn();
	$("#schermo").fadeIn(function () {entrafreccia(spiegaPercorso);}); */
	spiegaPercorso(); 
	/*
});*/

	});


}

function spiegaPercorso() {

/*div=$('#contenutipercorso');
div.detach();
div.appendTo("#contenuti");*/

mettischeda("percorso");
window.setTimeout(setupVantaggi,2000);

$('#contenutimask').fadeIn();
	$("#percorso").removeClass("clickable");
	$("#percorso").unbind('click');
			$("#percorso").click(function () {$("#sheet1").css("z-index",zinde++);});
}

function setupVantaggi () {
if (!msie) {
		$("#vantaggi").css("backgroundImage","url(img/box.png)");
		} else $("#percorso").css("backgroundImage","url(img/box.gif) ");
	mettifreccia($("#vantaggi"));
	$("#vantaggi").addClass("clickable");	
	$("#vantaggi").click(function () {

	entrafreccia(spiegaVantaggi);

	});
}
function spiegaVantaggi() {
//$("#schermos").attr("src","img/bianco.png");
	/*div=$('#contenutivantaggi');
	div.detach();
	div.appendTo("#contenuti");*/
		mettischeda("vantaggi");
		$("#vantaggi").removeClass("clickable");
		$("#vantaggi").unbind('click');
		
		$("#vantaggi").click(function () {$("#sheet2").css("z-index",zinde++);});
	//	frecciainsu($("#frecciasucosti"), setupCosti);
	window.setTimeout(setupCosti,2000);
	}


function setupCosti() {
//	$("#costi").animate({"opacity":1});
if (!msie) {
			$("#costi").css("backgroundImage","url(img/box.png)");
			} else $("#percorso").css("backgroundImage","url(img/box.gif) ");
	mettifreccia($("#costi"));
	$("#costi").addClass("clickable");	
	$("#costi").click(function () {
	entrafreccia(spiegaCosti);
	});
	}
function spiegaCosti() {
//$("#navhere").fadeOut();
//$("#schermo").fadeOut();
//$("#navs").attr("src","img/icosti.png");
	mettischeda("costi");
	
	$("#sheet3").css("width","565px");
	$("#contenuticosti").css("width","565px");
//$("#navhere").fadeIn();

		$("#costi").removeClass("clickable");
		$("#costi").unbind('click');
		$("#costi").click(function () {$("#sheet3").css("z-index",zinde++);});
		
/*window.setTimeout(function() {
if (!logindsp) {
	$("#rapido").fadeOut(function () {
	
		$("#hiddenrapidodiv").slideUp();
		$("#hiddenrapidodiv").slideDown();
		$("#hidden2rapidodiv").css("display","none");
		$("#hidden2rapidodiv").slideDown();

	});}},5000);
	*/	
		//frecciainsu($("#frecciasulogo"), setupReg);
	}

function setupReg () {
imgdiv.css("left",$('#pannellobiancoc').offset().left);
$('#pannellobiancoc').animate({"left":$('#flussocompany').position().left,"width":$('#flussocompany').width()});
	/*$("#vantaggi").animate({"opacity":1});
	mettifreccia($("#vantaggi"));
	$("#vantaggi").addClass("clickable");	
	$("#vantaggi").click(function () {
	entrafreccia(spiegaVantaggi);

	});*/
}

function showLogin () {
$("div.sliding").unbind('click');
imgdiv.unbind('click');
	/*$("#navhere").fadeOut(function () {
//$("#navigatore").css("display","block");
		$("#navs").attr("src","img/navigatore.png");
		$("#schermos").attr("src","img/bianco.png");
	$("#navhere").fadeIn();
	$("#schermo").fadeIn(setupLogin);
	});*/
}

function setupLogin () {
/*imgdiv.css("left",$('#pannellobiancoc').offset().left);
$('#pannellobiancoc').animate({"left":$('#flussocompany').position().left,"width":$('#flussocompany').width()});*/
	/*$("#vantaggi").animate({"opacity":1});
	mettifreccia($("#vantaggi"));
	$("#vantaggi").addClass("clickable");	
	$("#vantaggi").click(function () {
	entrafreccia(spiegaVantaggi);

	});*/
$('#contenuti > DIV').remove();
	div=$('#contlogin');
	div.detach();
	div.appendTo("#contenuti");
	$("#wreg").click( function () {
	$("#noreg").fadeOut(); 
		$("#noreg").fadeIn();
	});
}

function advanzare () {
$(this).remove();

if ($(this).attr("id")=="contenutipercorso4") {
	$("#schermos").attr("src","img/noi.png");
	$("#schermos").attr("width",480);
		$("#schermos").attr("height",290);
		
	frecciainsu($("#frecciasuvantaggi"), setupVantaggi);
	}
if ($(this).attr("id")=="contenutipercorso3") {
	$("#schermos").attr("src","img/gente.jpg");
	$("#schermos").attr("width",480);
		$("#schermos").attr("height",290);
	}
	
if ($(this).attr("id")=="contenutivantaggi2") {
	$("#schermos").attr("src","img/noi.png");
	$("#schermos").attr("width",480);
		$("#schermos").attr("height",290);
	frecciainsu($("#frecciasucosti"), setupCosti);
	}


}


});



var spunta=0;
var afinestra;

var zinde=1;

function doPersone() {
try {

$("#oppure").css("color","#e5653f");
//document.getElementById("localita").value=geoip_city();
} catch (e) {alert("CHECK1: " + e);}

imgdivleft=$(window).width()>1280?1280:$(window).width();


imgdiv.css("left",imgdivleft-imgdiv.width()-80+"px");
imgdiv.fadeIn();

imgdiv.css("z-index",10000);

$('#foglio').fadeIn();


$('#foglio').animate({"height":250},{easing: "swing", complete: clickstep});

	

//$('#foglio').css("-ms-filter","progid:DXImageTransform.Microsoft.Matrix(M11=0.99619470, M12=-0.08715574, M21=0.08715574, M22=0.99619470,sizingMethod='auto expand')");

$('#foglio').css("z-index",10000);
afinestra=$('<div id="afinestra"></div>');
divw=$(document).width();
divh=$(document).height();

divw=divw<1000?1000:divw;
divh=divh<650?650:(divh>713?713:divh);
afinestra.css("width",divw);
afinestra.css("height",divh);

$("#footer").css("top",divh-$("#footer").height()-1);
$("#footer").css("left",363); //$("#pannellobiancoc").offset().left+$("#pannellobiancoc").width());
//$("#footer").css("width",644);
$(".testo1").css("color","#"+bodyorange);
$(".testo1 a:hover").css("color","#0f0");
$("#footer").fadeIn();

$('#ccg').css("top",divh-$("#ccg").height()-1);
$('#ccg').fadeIn();


$("#zoomed").append(afinestra);


$("#cercare").css("top",-100);
$("#cercare").css("left",304);
$("#cercare").fadeIn();
$("#cercare").animate({"top":-1});	
$("#localitadiv").fadeOut();
$("#categoriadiv").fadeOut();

$("#rapidodiv").css("top","75px");
$("#rapidodiv").css("left",imgdiv.position().left+40+"px");
$("#rapidodiv").slideUp();

$("#rapidodiv").slideDown();
$("#hiddenrapidodiv").css("display","none");
$("#hiddenrapidodiv").fadeOut();
$("#password").remove();
$("#usertxt").after('<br/>');
$("#password_dimenticata").after('<a href="/recpwd.php" style="font-size: 13px; color:#00A; font-decoration: underline;">Password dimenticata?</a>');
$("#pwdtxt").after('<br /><input type="password" name="password" id="password">')
$("#username").click(function () {
logindsp=true;
$("#hidden2rapidodiv").slideDown();

});

$("#rapido").click( function () {

	$("#rapido").fadeOut(250,function () {

	logindsp=true;
		$("#hiddenrapidodiv").slideUp();
		$("#hiddenrapidodiv").slideDown();
		//$("#hidden2rapidodiv").css("display","none");

	});
});


$("#submitte").hover( function () {
$("#categoriadiv").fadeIn();
$


$("#submitte").click(function () {
document.getElementById("form1").submit();
});
});

$("#categoriadiv").click(function () {
$("#localitadiv").slideDown();
});

}

function clickstep() {
if (msie) {
//$("#foglio").css("top",-30);
//$("#foglio").css("left",30);
fnSetRotation(document.getElementById("foglio"),-5);	

}
$('#foglio').click( function () {
mettispunta();	
});
}


function mettispunta() {
afinestra=$("#afinestra");
spunta++;

switch(spunta) { 
  
  case 1: 
   x=54-14;
   y=18-30;
  break; 

  case 2: 
x=61-14;
y=86-30;
  break; 
 
  case 3: 
   x=67-14;
   y=176-30;
  break; 

  default: 
    //istruzioni 
}
if (spunta<=3) {
	spuntadiv=$('<div class="spunta" id="spunta'+spunta+'"></div>');
	spuntadiv.css("top",y);
	spuntadiv.css("left",x);
	spuntadiv.css("z-index",10000);
	$("body").append(spuntadiv);
	
	sheetdiv=$('<div class="mysheet" id="sheet'+spunta+'"></div>');
	sheetdiv.append($("#sheetcont"+spunta).detach());
	sheetdiv.css("top",$(window).height()+1);
	sheetdiv.css("left",-100+ (spunta*200));
	afinestra.append(sheetdiv);
	sheetdiv.css("z-index",zinde++);
	sheetdiv.fadeIn(); //$(window).height()-sheetdiv.height()
	sheetdiv.draggable();
	//.addTouch();
//	sheetdiv.dialog().addTouch();
	sheetdiv.animate({"top":267},{easing: "easeOutExpo", complete: function () {
	if (spunta==1) {
		hintdiv=$("#draghint");
		hintdiv.css("top",160);
		hintdiv.css("left",420);
		hintdiv.fadeIn();
		hintdiv.click(function() {$(this).fadeOut();});
	
		}
		
		}});
	
	
	sheetdiv.mousedown(function () {
	$(this).css("z-index",zinde++);
	
	
	});


	}
	

	if (spunta==3) {
	/*
		window.setTimeout(function() {
			$("#rapido").fadeOut(function () {
				if (!logindsp) {
				$("#hiddenrapidodiv").slideUp();
				$("#hiddenrapidodiv").slideDown();
				$("#hidden2rapidodiv").css("display","none");
				$("#hidden2rapidodiv").slideDown();
		}
			});},5000);
		*/	
		}

}

function testlogin() {
	user = $("#username").value;
	if (user.length<3) {
		$("#username").css("backgroundColor","#FFEEEE");
		return false;
	}
	pass = $("#password").value;
	if (pass.length<3) {
		$("#password").css("backgroundColor","#FFEEEE");
		return false;
	}

	}



function mettischeda(cosa) {

afinestra=$("#afinestra");
spunta++;
	/*spuntadiv=$('<div class="spunta" id="spunta'+spunta+'"></div>');
	spuntadiv.css("top",y);
	spuntadiv.css("left",x);
	spuntadiv.css("z-index",10000);
	$("body").append(spuntadiv);*/
	
	sheetdiv=$('<div class="mysheet" id="sheet'+spunta+'"></div>');
	sheetdiv.append($("#cont"+cosa).detach());
	sheetdiv.css("top",$(window).height()+1);
	sheetdiv.css("left",420);
	afinestra.append(sheetdiv);
		sheetdiv.css("z-index",zinde++);
		/*
	sheetdiv.css("-webkit-transform","rotate(-2.5deg)");	
		sheetdiv.css("-moz-transform:","rotate(-2.5deg)");	
		*/
		
	sheetdiv.fadeIn();
	sheetdiv.animate(
			{"top":80+((spunta-1)*100)},
			{easing: "easeOutExpo",complete: function()
				{
				if (spunta==1) 
					{
					hintdiv=$("#draghint");
					hintdiv.css("top",20);
					hintdiv.css("left",800);
					hintdiv.fadeIn();
					hintdiv.click(function() {$(this).fadeOut();});
					}
				}
			}
			);
			
			
		
	sheetdiv.draggable();


//	$('Element').dialog().addTouch();

	sheetdiv.mousedown(function () {
	$(this).css("z-index",zinde++);
	});


	
	

	
	if (spunta==3) {
		window.setTimeout(function() {
					$("#ccg").fadeOut();
			$("#rapido").fadeOut(function () {

				//$("#hiddenrapidodiv").slideUp();
				$("#hiddenrapidodiv").slideDown();
				//$("#hidden2rapidodiv").css("display","none");
				$("#hidden2rapidodiv").slideDown();
		
			});
		},5000);
	}
}
var deg2radians = Math.PI * 2 / 360;
var that;

function fnSetRotation(oObj, deg)
{
return 0;
    rad = deg * deg2radians ;
    costheta = Math.cos(rad);
    sintheta = Math.sin(rad);
 
    a = parseFloat(costheta).toFixed(8);
    c = parseFloat(-sintheta).toFixed(8);
    b = parseFloat(sintheta).toFixed(8);
    d = parseFloat(costheta).toFixed(8);
 
   /* document.getElementById("fM11").value = a;
    document.getElementById("fM12").value = c;
    document.getElementById("fM21").value = b;
    document.getElementById("fM22").value = d;*/
 
    if (oObj.filters) {
	oObj.filters.item(0).M11 = costheta;
	oObj.filters.item(0).M12 = -sintheta;
	oObj.filters.item(0).M21 = sintheta;
	oObj.filters.item(0).M22 = costheta;

    } else {
  	
	    oObj.setAttribute("style", "position:absolute; -moz-transform:  matrix(" + a + ", " + b + ", " + c + ", " + d + ", 0, 0); -webkit-transform:  matrix(" + a + ", " + b + ", " + c + ", " + d + ", 0, 0); -o-transform:  matrix(" + a + ", " + b + ", " + c + ", " + d + ", 0, 0);");
    }
 
}

function log(msg) {
if (true)
alert(msg);
}



