﻿// Questo file fa riferimento a scripts presenti nel file css_editing.js


function ShowBody(url) {
    if (url.length > 1) {
        if (url.substr(0, 6) == 'mailto') {
            window.open(url);
        }
        else {
            var body = document.getElementById('pagecontainer');
            if (body != null) {
                body.src = url;
            }
        }
    }
}


function PageLoading() {
    //ScaleFont();
    //ScalePage();

    StartFishEye();
    //showAnimateHeader();
    //$('.ghost').fadeTo('slow', 0.5);
}

function ScaleFont() {

    var body = document.getElementsByTagName('body')[0];
    var dimSchermo = window.screen.width;
    var fontsize = Math.ceil(dimSchermo / 117);
    body.style.fontSize = fontsize + 'px';
    
}



function StartFishEye() {

    var lSchermo = window.screen.width;
    var maxw = 40;
    var itmw = 24;

    $('#bottomIcons').Fisheye(
				            {
				                maxWidth: maxw,
				                items: 'a',
				                itemsText: 'span',
				                container: '.dock-container2',
				                itemWidth: itmw,
				                proximity: 80,
				                alignment: 'left',
				                valign: 'bottom',
				                halign: 'center'
				            }
			            )
}



var defaultSearchText = 'Cerca:';
function TextFocus() {
    var txts = document.getElementById('txtSearch');
    if (txts != null) {
        var regex = new RegExp(defaultSearchText);
        txts.value = txts.value.replace(regex, '');
    }
}
function TextFocusOut() {
    var txts = document.getElementById('txtSearch');
    if (txts != null) {
        var v = txts.value.trim();
        if (v == '' || v == null)
            txts.value = defaultSearchText;
    }
}



function TxtSearch_KeyPress(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    var s = String.fromCharCode(charCode);

    if (charCode == 13) {
        Search();
    }

    // Necessario solo per FireFox
    if (charCode == 8 || charCode == 35 || charCode == 36 || charCode == 37 || charCode == 39 || charCode == 46)
    { return true; }

    // Modificare la regex includendo gli altri caratteri +-
    var regex = /[^\s\w\"]/g;

    return !regex.test(s);
}

function SearchBtn_Click() {
    Search();
}

function Search() {
    var txt = document.getElementById('txtSearch').value;
    if (txt && txt != defaultSearchText)
        document.getElementById('pagecontainer').src = 'SearchResults.aspx?QueryString=' + txt;
    else
        alert('Digitare un termine da ricercare prima di avviare la ricerca!');
}


function isMobileUserAgent() {
    if (!!(navigator.userAgent.match(/(iPhone|iPod|blackberry|android|wap|phone|htc|lg|midp|mmp|mobile|nokia|opera mini|palm|pocket|psp|sgh|smartphone|symbian|treo mini|Playstation Portable|SonyEricsson|Samsung|MobileExplorer|PalmSource|Benq|Windows Phone|Windows Mobile|IEMobile|Windows CE|Nintendo Wii|hiptop|avantgo|plucker|xiino|blazer|elaine)/i))) 
        return true; 
        return false; 
}

var isMobileUA = isMobileUserAgent();
var swfHeader = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="1920" height="180" id="header_background" align="middle"><param name="movie" value="images/common/header_bkg.swf"/><param name="wmode" value="opaque" /><!--[if !IE]>--><object type="application/x-shockwave-flash" data="images/common/header_bkg.swf" width="1920" height="180"><param name="movie" value="images/common/header_bkg.swf"/><param name="wmode" value="opaque" /></object><!--<![endif]--></object>';
function showAnimateHeader() {
    if (!isMobileUA) {
        document.getElementById('topBand').innerHTML = swfHeader;
    }
}
