﻿
function ShowVideoStream(videoUrl,parentElementId,videoPlayerUrl)
{
    $('#' + parentElementId ).empty();
    var strVideoObj = '<object data="data:application/x-silverlight-2," type="application/x-silverlight-2"  width="390" height="290">';
    strVideoObj+='<param value="' + videoPlayerUrl +'" name="source" />'
    strVideoObj+='<param name="initParams" value="VideoSource=' + videoUrl + ',EnableScrubbing=true,InitialVolume=1"  />';
    strVideoObj+='<param name="background" value="black" />';
    strVideoObj+='<param name="minruntimeversion" value="2.0.31005.0" />';
    strVideoObj+='<param name="autoUpgrade" value="true" />';
    strVideoObj+='<a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration:none">';
    strVideoObj+='<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/> ';
    strVideoObj+='</a>';  
    strVideoObj+='</object>';
    $(strVideoObj).appendTo($('#' + parentElementId ));
}

function ShowVideoEmbedded(embeddedObject,parentElementId)
{
    $('#' + parentElementId ).empty();
    var strVideoObj = '<iframe frameborder="0" width="400" height="100%" scrolling="no"  src=' + embeddedObject + '></iframe>';
    $(strVideoObj).appendTo($('#' + parentElementId ));
}

function ShowImage(imgUrl,parentElementId)
{
    
    $('#' + parentElementId ).empty();
    $('<div style="width:400px;height:400px;overflow:hidden;scrolling:no;"><img src=' + imgUrl + '  /></div>').appendTo($('#' + parentElementId));
}
  
function doClick(buttonName,e)
{
    //the purpose of this function is to allow the enter key to 
    //point to the correct button to click.
    var key;
    
     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox
    if (key == 13)
    {
        //Get the button the user wants to have clicked
        var btn = $get(buttonName);
        if (btn != null)
        { //If we find the button click it
            btn.focus();
            btn.click();
            event.keyCode = 0
            return true;
        }
    }
    return false;
}

// JScript File
function SetPosition(elementId)
{
    var element = $get(elementId);
    
    if (element!=null)
    {        
        x = document.documentElement.scrollLeft;
        y = document.documentElement.scrollTop;
        
        var clientBounds = $common.getClientBounds();
        var width = clientBounds.width;
        var height = clientBounds.height;
        
         x = Math.max(0, Math.floor(x + width / 2.0 - element.offsetWidth / 2.0 ));
         y = Math.max(0, Math.floor(y + height / 2.0 - element.offsetHeight / 2.0 ));
         
         element.style.left = x + 'px';
         element.style.top = y + 'px';
     }
  }
  
  function ShowElement(elementId) {
    var el = document.getElementById(elementId);
    if (el) {   
        el.style.display = '';
    }            
  }
  
  function HideElement(elementId) {
    var el = document.getElementById(elementId);
    if (el) {   
        el.style.display = 'none';
    }
}

function onTextSearch(source, e, buttonName) {
    var txtStartUpFocus = $get(source.id);
    if (txtStartUpFocus != null && buttonName != '') {
        if (doClick(buttonName, e)) {
            txtStartUpFocus.click();
        }
    }
}


function test() {
    alert('ciao');
}

function showDialog(selector, title) {
    
    $(selector).dialog({ modal: true, resizable: false, draggable: false, title: title, width: 900, height: 650 }).parent().appendTo('first:form');
}




  




