﻿function resourceDownload(ResourceLink) {
    window.open("http://" + location.host + ResourceLink);
    __doPostBack('SendMail', ResourceLink);
}

var interval = null;
var startPosition = 0;
var endPosition = 96;
var topPosition = 310;
var speed = 150;
var scrollLength = 0;
var pause = false;

function settings() {
    if (document.getElementById('display')) {
        scrollLength = document.getElementById('display').clientHeight / 2;
        if (!interval) scrollit();
    }
    var H = rH() - 100;
    var xW = rW() - 50;
    var W = H * 4 / 3;
    if (xW<W) W=xW;
    if (H < 620) H = 620;
    if (W < 800) W = 800;
    
    //height
    document.getElementById("container").style.height = (H) + "px";  //668 
    document.getElementById("main").style.height = (H - 120) + "px"; //548

    if (document.getElementById("iframe")) document.getElementById("iframe").style.height = (H - 120) + "px";   //548
    if (document.getElementById("detail_table")) document.getElementById("detail_table").style.height = (H - 100) + "px";   //548
    if (document.getElementById("detail_content")) document.getElementById("detail_content").style.height = (H - 305) + "px";   //548
    if (document.getElementById("detail_description")) document.getElementById("detail_description").style.height = (H - 305) + "px";   //548
    if (document.getElementById("ctl00_pagina_pnlAccessori")) document.getElementById("ctl00_pagina_pnlAccessori").style.height = (H - 240) + "px";   //548
	if (document.getElementById("ctl00_pagina_Pnl_Models")) document.getElementById("ctl00_pagina_Pnl_Models").style.height = (H - 140) + "px";  
   
	//width
    document.getElementById("container").style.width = (W) + "px"; //1024
    document.getElementById("footer").style.width = (W) + "px";    //1024
    document.getElementById("content").style.width = (W - 190) + "px";   //790
    document.getElementById("lastHeaderItem").style.width = (W / 5 - 1) + "px";
    if (document.getElementById("detail_table")) document.getElementById("detail_table").style.width = (W - 170) + "px";
    document.getElementById("nav").style.width = 180 + "px";   //224
    if (document.getElementById("ctl00_pagina_models_table")) document.getElementById("ctl00_pagina_models_table").style.width = (W - 210) + "px";  
    document.getElementById("container").style.display = "block";
    document.getElementById("footer").style.display = "block";
}

function rW() {
    return (window.innerWidth) ? window.innerWidth :
		(document.documentElement.clientWidth) ? document.documentElement.clientWidth :
		(document.body.clientWidth) ? document.body.clientWidth : 0;
}
function rH() {
    return (window.innerHeight) ? window.innerHeight :
		(document.documentElement.clientHeight) ? document.documentElement.clientHeight :
		(document.body.clientHeight) ? document.body.clientHeight : 0;
}

function scrollit() {
    if (!pause) {
        if (startPosition != scrollLength) {
            startPosition = startPosition + 1;
            topPosition = topPosition - 1;
            document.getElementById('display').style.clip = "rect(" + (startPosition + 1) + "px 160px " + (startPosition + endPosition) + "px 0px)";
            document.getElementById('display').style.top = topPosition + "px";
            interval = setTimeout("scrollit()", speed);
        }
        else {
            startPosition = 0;
            topPosition = 314;
            interval = setTimeout("scrollit()", speed);
        }
    }
}

function stopinterval() {
    if (interval) clearTimeout(interval);
}

function pausetimeout(p) {
    pause = p;
    if (!pause) scrollit();
}
function Init() {
    NewsInit();
    CorsiInit();
}
function NewsInit() {
    if ($(".news").length > 0) {
        $(".news").jCarouselLite({
            auto: 6000,
            speed: 0,
            visible: 1
        });
    }
}
function CorsiInit() {
    if ($(".corsi").length > 0) {
        $(".corsi").jCarouselLite({
            auto: 6000,
            speed: 0,
            visible: 1
        });
    }
}
