﻿
/*
    On page load
*/
$(document).ready(function() {

    // Menu laterale sinistro
	$("#menu").find("span.menuitem").each(function() {
		$(this).bind("click", function() {
			var ul = $(this).parent().children("ul");
			if(ul.css("display") == "none") {
				ul.slideDown(200);
			} else {
				ul.slideUp(200);
			}
		});
	});
	// Menu sedi
	$("#menusedi").find("span.menuitem").each(function() {
		$(this).bind("click", function() {
			var ul = $(this).parent().children("ul");
			if(ul.css("display") == "none") {
				ul.slideDown(200);
			} else {
				ul.slideUp(200);
			}
		});
	});
//	$("#menu li").bind("mouseenter", function() {
//	    if($(this).find("ul").length > 0) return;
//	    //$(this).stop();
//	    $(this).animate({
//	        backgroundColor: "#DDDDDD"
//	    }, 150);
//	} );
//	$("#menu li").bind("mouseleave", function() {
//	    if($(this).find("ul").length > 0) return;
//	    //$(this).stop();
//	    $(this).animate({
//	        backgroundColor: "#FFFFFF"
//	    }, 150);
//	} );
//	
	// Menu servizi
	$("#menuserv").find("span.menuitem").each(function() {
		$(this).bind("click", function() {
			var ul = $(this).parent().children("ul");
			if(ul.css("display") == "none") {
				ul.slideDown(200);
			} else {
				ul.slideUp(200);
			}
		});
	});
//	$("#menuserv li").bind("mouseenter mouseleave", function() { $(this).toggleClass("hover"); } );
//	


    // menu auto aprente
    if(document.location.href.indexOf("/sale/") > 0) {
        $("#msale").click();
    } else if(document.location.href.indexOf("boezio") > 0) {
        $("#mboezio").click();
    } else if(document.location.href.indexOf("regolo") > 0) {
        $("#mregolo").click();
    } else if(document.location.href.indexOf("marconi") > 0) {
        $("#mmarconi").click();
    } else if(document.location.href.indexOf("sedi/index.aspx") > 0) {
        $("#mboezio").click();
        $("#mregolo").click();
        $("#mmarconi").click();
    }

	if($("#sliderhome")) {
		// vetrina homepage
		$("#sliderhome").load("vetrina.html", function() {
			$("#sliderhome").easySlider( {
				auto: true,
				continuous: true,
				controlsShow: false,
				speed: 900,
				pause: 2000,
				numeric: false,
				hoverPause: true
			});
		});
	}

	var baseUri = $("base").attr("href");

	$("#home3d").flash(
        { 
          src: "cu3er.swf",
          width: 360,
          height: 240,
          wmode: "transparent",
          flashvars: { xml: "cu3er.xml" }
        },
        { version: 9 }
    );
    
    $("#vtgen").flash(
        { 
          src: "cu3er.swf",
          width: 640,
          height: 280,
          bgcolor: "white",
          wmode: "transparent",
          flashvars: { xml: "virtual-tour/cu3er.xml.aspx" }
        },
        { version: 9 }
    );
    
//    $(".promoboxhome div").flash(
//        { 
//          src: "http://www.youtube.com/v/uh-gG-64W5c&amp;hl=it_IT&amp;fs=1&amp;rel=0&amp;color1=0xe1600f&amp;color2=0xfebd01",
//          width: 180,
//          height: 160,
//          wmode: "transparent"
//        },
//        { version: 9 }
//    );

	var cumulus = baseUri + "tagcloud.swf?r="+Math.random();
	var cumdata = encodeURI(
'<tags>'+
	'<a href="'+baseUri+'sale/day-office.aspx?tc=1" style="font-size: 15px" color="0xFF7F00">Day office</a>'+
	'<a href="'+baseUri+'sale/sale-riunioni.aspx?tc=1" style="font-size: 25px" color="0xFF7F00">Sale riunioni</a>'+
	'<a href="'+baseUri+'uffici/affitto-uffici.aspx?tc=1" style="font-size: 15px" color="0xFF7F00">Uffici</a>'+
	'<a href="'+baseUri+'sale/videoconferenza.aspx?tc=1" style="font-size: 12px" color="0xFF7F00">Videoconferenza</a>'+
	'<a href="'+baseUri+'uffici/coworking.aspx?tc=1" style="font-size: 15px" color="0xFF7F00">Coworking</a>'+
	'<a href="'+baseUri+'virtual-office/uffici-virtuali.aspx?tc=1" style="font-size: 18px" color="0xFF7F00">Virtual office</a>'+
	'<a href="'+baseUri+'uffici/office-sharing.aspx?tc=1" style="font-size: 30px" color="0xFF7F00">Office sharing</a>'+
'</tags>'
);
	var cumdataen = encodeURI(
'<tags>'+
	'<a href="'+baseUri+'en/sale/day-office.aspx?tc=1" style="font-size: 15px" color="0xFF7F00">Day office</a>'+
	'<a href="'+baseUri+'en/sale/sale-riunioni.aspx?tc=1" style="font-size: 25px" color="0xFF7F00">Meeting rooms</a>'+
	'<a href="'+baseUri+'en/uffici/affitto-uffici.aspx?tc=1" style="font-size: 15px" color="0xFF7F00">Offices</a>'+
	'<a href="'+baseUri+'en/sale/videoconferenza.aspx?tc=1" style="font-size: 12px" color="0xFF7F00">Videoconference</a>'+
	'<a href="'+baseUri+'en/uffici/coworking.aspx?tc=1" style="font-size: 15px" color="0xFF7F00">Coworking</a>'+
	'<a href="'+baseUri+'en/virtual-office/uffici-virtuali.aspx?tc=1" style="font-size: 18px" color="0xFF7F00">Virtual office</a>'+
	'<a href="'+baseUri+'uffici/office-sharing.aspx?tc=1" style="font-size: 30px" color="0xFF7F00">Office sharing</a>'+
'</tags>'
);

	$("#tagcloud").html('<object data="'+cumulus+'" width="201px" height="167px" type="application/x-shockwave-flash">'+
						'<param name="movie" value="'+cumulus+'"></param>'+
						'<param name="bgcolor" value="#FFFFFF"></param>'+
						'<param name="AllowScriptAccess" value="always"></param>'+
						'<param name="wmode" value="transparent"></param>'+
						'<param name="flashvars" value="tcolor=0x111111&tcolor2=0x336699&hicolor=0xFF9F22&tspeed=200&distr=true&mode=both&tagcloud='+cumdata+'">'+
						'</object>');

	$("#tagclouden").html('<object data="'+cumulus+'" width="201px" height="167px" type="application/x-shockwave-flash">'+
						  '<param name="movie" value="'+cumulus+'"></param>'+
						  '<param name="bgcolor" value="#FFFFFF"></param>'+
						  '<param name="AllowScriptAccess" value="always"></param>'+
						  '<param name="wmode" value="transparent"></param>'+
						  '<param name="flashvars" value="tcolor=0x111111&tcolor2=0x336699&hicolor=0xFF9F22&tspeed=200&distr=true&mode=both&tagcloud='+cumdataen+'">'+
						  '</object>');

	//$("#pbhome").click(animazionehome);
});

function impostaDatePicker(idControllo, onSelect) {
	try {
		$("#"+idControllo).datepicker( { 
			closeText: 'Chiudi',
			prevText: '&#x3c;Prec',
			nextText: 'Succ&#x3e;',
			currentText: 'Oggi',
			monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno', 'Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],
			monthNamesShort: ['Gen','Feb','Mar','Apr','Mag','Giu', 'Lug','Ago','Set','Ott','Nov','Dic'],
			dayNames: ['Domenica','Luned&#236','Marted&#236','Mercoled&#236','Gioved&#236','Venerd&#236','Sabato'],
			dayNamesShort: ['Dom','Lun','Mar','Mer','Gio','Ven','Sab'],
			dayNamesMin: ['Do','Lu','Ma','Me','Gio','Ve','Sa'],
			dateFormat: 'dd/mm/yy',
			firstDay: 1,
			isRTL: false,
			onSelect: onSelect
		} );
	} catch (exn) {
		alert(exn);
	}
}

function animazionehome() {
	$("#pbhome").unbind();
	var t = $(this);
	if(t.css("position") == "absolute") {
		t.css("position", "").css("width", "").css("height", "").css("border", "0").css("background", "url('img/homeboxq.jpg') no-repeat scroll center center transparent");
		$("#pbhome").click(animazionehome);
		return;
	}
	t.css("left", t.position().left).css("top", t.position().top)
	 .css("position", "absolute").css("opacity", "0.1")
	 .css("background","#DEDEDE").css("border", "1px solid black");
	t.animate(
		{
			width: t.parent().width(),
			left: t.parent().position().left,
			opacity: 0.4
		},
		1500,
		"swing",
		function() {
			var t = $(this);
			t.animate(
				{
					height: 420,
					top: 16,
					opacity: 0.8
				},
				1500,
				"swing",
				function() {
					$("#pbhome").click(animazionehome);
				}
			);
		}
	);
}

Array.prototype.shuffle = function() {
	var i = this.length;
	if ( i == 0 ) return false;
	while ( --i ) {
		var j = Math.floor( Math.random() * ( i + 1 ) );
		var tempi = this[i];
		var tempj = this[j];
		this[i] = tempj;
		this[j] = tempi;
	}
};


function showVetrina(id) {
	window.open('vetrina.aspx?id='+id, '', 'width=399, height=450, toolbar=no, location=no,status=no,menubar=no,resizable=yes,scrollbars=yes');
}

/*
    Center
*/

jQuery.fn.center = function(params) {

    var options = {
        vertical: true,
        horizontal: true
    }

    op = jQuery.extend(options, params);

    return this.each(function(){
        var $self = jQuery(this);
        var width = $self.width();
        var height = $self.height();
        var paddingTop = parseInt($self.css("padding-top"));
        var paddingBottom = parseInt($self.css("padding-bottom"));
        var borderTop = parseInt($self.css("border-top-width"));
        var borderBottom = parseInt($self.css("border-bottom-width"));
        var mediaBorder = (borderTop+borderBottom)/2;
        var mediaPadding = (paddingTop+paddingBottom)/2;
        var halfWidth = (width/2)*(-1);
        var halfHeight = ((height/2)*(-1))-mediaPadding-mediaBorder;
        var cssProp = {
            position: 'absolute'
        };
        if(op.vertical) {
            var ty = ($(window).height() - height) / 2 + $(document).scrollTop();
            var diff = Math.abs(ty - parseInt($self.css("top")));
            if(diff > 2) {
                if(ty - parseInt($self.css("top")) > 0) {
                    cssProp.top = parseInt($self.css("top")) + diff / 6;
                } else if(ty - parseInt($self.css("top")) < 0) {
                    cssProp.top = parseInt($self.css("top")) - diff / 6;
                } else {
                    cssProp.top = parseInt($self.css("top"));
                }
            }
        }
        if(op.horizontal) {
            cssProp.left = ($(document).width() - width) / 2;
        }
        $self.css(cssProp);
    });
};

eval(function(p, a, c, k, e, r) { e = function(c) { return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function(e) { return r[e] } ]; e = function() { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p } ('(7($){$.u.v=7(b){5 c,8,w,r,x,A;5 d=$.W({},$.u.v.H,b);5 e=d.I*J;5 f=d.K.X();5 g=d.L;5 h=d.M;5 j=d.9;5 k=d.N;5 l=d.O;5 m=(f=="Y")?" ":".";5 n=P Q();5 o=0;y(i=0;i<q.p;i++){4(j){$(q[i]).9(j)}4(f=="s")n.R({3:$(q[i]),6:$(q[i]).9()});t n.R({3:$(q[i]),6:$(q[i]).9().Z(m)});4(!g)o=n[i].6.p>o?n[i].6.p:o;t o+=n[i].6.p;$(q[i]).9("")}B();7 B(){c=e/o;8=0;w=r=0;x=(!g)?C(S,c):C(T,c)};7 S(){8++;y(i=0;i<n.p;i++){5 a=n[i];4(a.6.p>=8){4(f=="s"){a.3.9(a.6.U(0,8))}t{a.3.z(a.6[8-1]);4(8<o){a.3.z(m)}}}}4(8>=o){D()}};7 T(){$3=n[w];4(f=="s"){$3.3.9($3.6.U(0,++r))}t{$3.3.z($3.6[r++]);4(r<$3.6.p)$3.3.z(m)}4(r>=$3.6.p){w++;r=0}8++;4(8>=o){D()}};7 D(){E(x);4(f!="s"){}4(k){4(l)A=C(V,l*J);t F()}h()};7 F(){y(i=0;i<n.p;i++){n[i].3.9("")}B()};7 V(){F();E(A)};7 G(){E(x);y(i=0;i<n.p;i++){n[i].3.9(n[i].6)}};q.G=G;10 q};$.u.v.H={I:2,K:"s",L:11,M:7(){},9:"",N:12,O:0};$.u.v.13={14:P Q()}})(15);', 62, 68, '|||obj|if|var|initialText|function|nIntervalCounter|text||||||||||||||||length|this|nSequentialCounterInternal|letter|else|fn|jTypeWriter|nSequentialCounter|nInterval|for|append|nLoopInterval|init|setInterval|circleEnd|clearInterval|newLoop|endEffect|defaults|duration|1000|type|sequential|onComplete|loop|loopDelay|new|Array|push|typerSimultaneous|typerSequential|substr|loopInterval|extend|toLowerCase|word|split|return|true|false|variables|aObjects|jQuery'.split('|'), 0, {}))



