/* PPLib1.js

 Common javascript functions for PressParade
 
*/

var bo_ns_id = 0;

// Test function
function DoAlert(aMessage)
{
//    debugger;
    alert(aMessage);
}

function startIeFix(){
if(isIE()){
document.write('<noscript id="bo_ns_id_' + bo_ns_id + '">');
}
}

function endIeFix(){
if(isIE()){
var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
var theNoScript = theObject.innerHTML;
document.write(theNoScript);
}
}

function isIE(){
var strBrowser = navigator.userAgent.toLowerCase();
if(strBrowser.indexOf("msie") > -1 && strBrowser.indexOf("mac") < 0){
return true;
}else{
return false;
}
}

// create an activex control externally to avoid in-place activation
function CreateControl(DivID, CLSID, ObjectID,
                       WIDTH, HEIGHT, URL, AUTOSTART)
{
  var d = document.getElementById(DivID);
  d.innerHTML = 
    '<object classid=' + CLSID + ' id=' + ObjectID + 
    ' width=' + WIDTH + ' height=' + HEIGHT +
    '><param name="URL" value=' + URL + 
    '><param name="autoStart" value=' + AUTOSTART + '/>';
}

// create a MediaPlayer control externally to avoid in-place activation
function CreateMediaPlayer(DivID, CLSID, ObjectID,
                       WIDTH, HEIGHT, URL, AUTOSTART)
{
  debugger;
  var d = document.getElementById(DivID);
  d.innerHTML = 
    '<object classid=' + CLSID + ' id=' + ObjectID + 
    ' width=' + WIDTH + ' height=' + HEIGHT 
    +'><param name="URL" value=' + URL 
    + '><param name="autoStart" value=' + AUTOSTART + '>' 
	+'<embed type="application/x-mplayer2" '
	+'pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" '
	+' showcontrols="true" width="' + WIDTH + '" height="' + HEIGHT +'" '
	+' src="'+ URL +'" autostart="' + AUTOSTART + '" loop="false">'
	+'</embed>'    
    +'</object>';

}

function GetLocalTimeOffset()
{
    // e.g., -5 means the zone is UTC+5
    // e.g., 5 means the zone is UTC-5
    // The offset value is the value that is applied in hours to the current 
    // datetime in order to get the current UTC value
    var dt = new Date();
    locOffset = dt.getTimezoneOffset();
    CreateOffsetDateCookie("TimezoneOffset",locOffset,0);
}

function CreateOffsetDateCookie(name,value,days)
{
    //debugger
    if(days && days > 0)
    {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires=" + date.toUTCString(); 
        
    }
    else
    {
        var expires = "";
    }
    
    document.cookie = name + "=" + value + expires + "; path=/";
}

