
function _rpc(args) {
    var rpc_options = {
        url: "http://www.levoip.com/rpc.php",
        type: "post",
        cache: false,
        dataType: "html",
        data: {lang: "en", section: "home", subsection: ""},
        success: function(res) { alert(res); }

    };
    if(args) {
        if(args.data) jQuery.extend(rpc_options.data, args.data);
        if(args.success) rpc_options.success = args.success;
    }
    jQuery.ajax(rpc_options);
}

function _rpc_main(args) {
    var rpc_options = {
        url: "rpc.php",
        type: "post",
        cache: false,
        dataType: "html",
        data: {lang: "en", section: "home", subsection: ""},
        success: function(res) { 
            $j("#content_body").fadeOut();
            $j("#content_aux").html(res);
            $j("#content").css({height: $j("#content_aux").height()});
            $j("#ajax-load").css({top: 250, left: $j(window).width() / 2 - 110}).show();
            setTimeout("$j(\"#content_body\").html($j(\"#content_aux\").html()); $j(\"#content_body\").fadeIn(); $j(\"#ajax-load\").hide(); gallery_start(); $j(\"[tp=gallery]\").lightBox({fixedNavigation:false}); showMap();", 750);
        }

    };
    if(args) {
        if(args.data) jQuery.extend(rpc_options.data, args.data);
        if(args.success) rpc_options.success = args.success;
    }
    jQuery.ajax(rpc_options);
}

function _rpc_center(args) {
    var rpc_options = {
        url: "rpc.php",
        type: "post",
        cache: false,
        dataType: "html",
        data: {lang: "en", section: "home", subsection: ""},
        success: function(res) { 
            $j("#center").fadeOut();
            $j("#content_aux").html(res);
            setTimeout("$j(\"#center\").html($j(\"#content_aux\").html()); $j(\"#center\").fadeIn(); gallery_start(); $j(\"[tp=gallery]\").lightBox({fixedNavigation:false}); showMap();", 750);
        }

    };
    if(args) {
        if(args.data) jQuery.extend(rpc_options.data, args.data);
        if(args.success) rpc_options.success = args.success;
    }
    jQuery.ajax(rpc_options);
}


function _rpc_footer(args) {
    var rpc_options = {
        url: "rpc.php",
        type: "post",
        cache: false,
        dataType: "html",
        data: {lang: "en", section: "footer", subsection: ""},
        success: function(res) { 
            $j("#footer").fadeOut();
            $j("#footer").html(res);
            $j("#footer").fadeIn();
        }

    };
    if(args) {
        if(args.data) jQuery.extend(rpc_options.data, args.data);
        if(args.success) rpc_options.success = args.success;
    }
    jQuery.ajax(rpc_options);
}

function gallery_start() {
    var myGallery = new gallery($('splash'), {
        timed: true,
        showArrows: false,
        showInfopane: false,
        showCarousel: false,
        embedLinks: false,
        delay: 3500,
        fadeDuration: 500
        });
  var myGallery = new gallery($('splash2'), {
        timed: true,
        showArrows: false,
        showInfopane: false,
        showCarousel: false,
        embedLinks: false,
        delay: 3500,
        fadeDuration: 500
    });

}

function showMap() {
    if (document.getElementById('map') && GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById('map'));                
        map.addControl(new GSmallMapControl());	            
        map.setCenter(new GLatLng(45.145968,8.948536), 12);

        function createMarker(point, description) {
            var marker = new GMarker(point);
            GEvent.addListener(marker, '', function() {
                    marker.openInfoWindowHtml(description);
                    });
            return marker;
        }
        map.addOverlay(createMarker(new GLatLng(45.145968,8.948536),''));
    }
}

function goto_home() {
    $j("#head").show("slow");
    $j("#head2").hide("slow");
    $j("#head3").hide("slow");
    $j("#head4").hide("slow");
}
function goto_mobile() {
    $j("#head").hide("slow");
    $j("#head2").show("slow");
    $j("#head3").hide("slow");
    $j("#head4").hide("slow");
}
function goto_voip() {
    $j("#head").hide("slow");
    $j("#head2").hide("slow");
    $j("#head3").show("slow");
    $j("#head4").hide("slow");
}
function goto_resellers() {
    $j("#head").hide("slow");
    $j("#head2").hide("slow");
    $j("#head3").hide("slow");
    $j("#head4").show("slow");
}
function init() {
    $j("#logo1").animate({width: 349}, 1000); $j("#logo2").animate({width: 349}, 1000);
	//goto_home();
    //rpc_main(); 
    //rpc_footer(); 
}


function overlay_on() {
    $j("#overlay").css({"opacity": 0.5, "z-index": 1100, "width": $j(document).width(), "height": $j(document).height()}).show().animate({"opacity": 0.8}, 100);
}
function overlay_off() {
    $j("#overlay").css({"opacity": 1}).hide();
}


function mail_friends() {
    if(!($j("#mail_friends_target_email1").val() != "" || $j("#mail_friends_target_email2").val() != "" || $j("#mail_friends_target_email3").val() != "")) alert("Perfavore, inserisci almeno un indirizzo email valido di un tuo amico");
    else if(!($j("#mail_friends_source_name").val() != "")) alert("Perfavore inserisci il tuo nome");
    else {
        var rpc_opts_aux = rpc_opts;
        rpc_opts_aux.section = "friends_mail";
        jQuery.extend(rpc_opts_aux, {mail_source_name: $j("#mail_friends_source_name").val(), mail_source_email: $j("#mail_friends_source_email").val(),
                mail_source_nickname: $j("#mail_friends_source_nickname").val(), mail_target_email1: $j("#mail_friends_target_email1").val(), 
                mail_target_email2: $j("#mail_friends_target_email2").val(), mail_target_email3: $j("#mail_friends_target_email3").val()});
        _rpc({data: rpc_opts_aux});
        $j("#box_invita").hide();
        overlay_off();
    }
}

/*aggiunte mie*/
function animate_logo(id,bool){
	if(bool){
		$j('#'+id).animate({width: 370}, 700);
	}
	else{
		$j('#'+id).animate({width: 349}, 700);
	}
}
function invita_amici(){
	overlay_on(); 
	$j("#box_invita").css({"position": "absolute", "left": $j(document).width() / 2 - 150, "top": $j(document).height() /2 - 100, "z-index": 1101}).show();
}
function scarica(){
	overlay_on(); $j("#box_download").css({"position": "absolute", "left": $j(document).width() / 2 - 150, "top": $j(document).height() /2 - 100, "z-index": 1101}).show();
}
