﻿//Global
var currentImageIndex=0;

function SetUpEmbed(file)
        {
            var w,h;
            w = screen.width * 0.5;
            h = parseInt(w / 1.77049,10);
            /*w=540;
            h=305;*/
            //alert(navigator.userAgent);
            if(navigator.userAgent.indexOf('Firefox')>-1 || navigator.userAgent.indexOf('Opera')>-1 )
            {
                document.writeln('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" type="video/quicktime">');
                document.writeln('<embed pluginspage="http://www.apple.com/quicktime/download/" src="' + file + '" width="' + w + '" height="' + h + '" scale="tofit" controller="true" kioskmode="true"></embed>');
                document.writeln('</object>');
            }
            else
            {
                document.writeln('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" type="video/quicktime" width="' + w +'" height="' + h +'">');
                document.writeln('<param name="src" value="' + file + '" />');
                document.writeln('<param name="width" value="' + w + '" />');
                document.writeln('<param name="height" value="' + h + '" />');
                document.writeln('<param name="controller" value="true" />');
                document.writeln('<param name="kioskmode" value="true" />');
                document.writeln('<param name="scale" value="tofit" />');
                document.writeln('</object>');
            }
            var divP=document.getElementById('divPanorama');
            if(divP==null) return;
            divP.style.width=w + 'px';
        }
function popupMap(path)
    {
        wMap = window.open(path,"Map","location=no,toolbar=no,menubar=no,scrollbars=no,width=550,height=550");
    }
function MyNavigateTo(url)
    {
        //alert('MyNavigateTo');
        
        //Goes the chosen location
        window.opener.location=url;
        
        //Returns this page
        history.back();
        
        //Focus the chosen page
        window.opener.focus();
    }
function mapClose()
    {
        window.close();
    }
function popupLang(file)
    {
        window.open(file,"Language","location=no,toolbar=no,menubar=no,scrollbars=yes,width=500,height=400");
    }    
function popupInfo(path)
    {
        window.open(path,"","location=no,toolbar=no,menubar=no,scrollbars=yes,width=500,height=450");
    }
function popupPicture(img)
    {
        if(img==null) return;
        
        var s = img.src.substring(img.src.lastIndexOf("file=")+5);
        
        //alert(s);
        
        var w=window.open(s,"Immagine","location=no,toolbar=no,menubar=no,scrollbars=yes");
        w.focus();
    }
function showEnlarged(file,w,h)
    {
        img = document.getElementById('imgBig');
        img.src = 'Thumbnail.axd?w='+ w + '&h=' + h +' &file=' + file;
    }
function ShowViewStateSize()
    {
        var buf = document.forms[0]["__VIEWSTATE"].value;
        alert("View state is " + buf.length + " bytes");
    }
    function changeMainPicture()
    {
        var img = document.getElementById('mainPicture');
        if(img==null){ alert('No Image found!'); return};
        
        currentImageIndex++;
        if(currentImageIndex==8) currentImageIndex=1;
        img.src = "Front" + currentImageIndex + ".jpg";
    }