﻿if (!window.Silverlight)
{
    window.Silverlight = { };
}

// Silverlight control instance counter for memory mgt
Silverlight._silverlightCount = 0;
Silverlight.fwlinkRoot = 'http://go2.microsoft.com/fwlink/?LinkID=143433';  
Silverlight.onGetSilverlight = null;
Silverlight.onSilverlightInstalled = function() { window.location.reload(false); };


//////////////////////////////////////////////////////////////////
// isInstalled, checks to see if the correct version is installed
//////////////////////////////////////////////////////////////////
Silverlight.isInstalled = function(version) {
    var isVersionSupported = false;
    var container = null;
    try {
        var control = null;

        try {
            control = new ActiveXObject('AgControl.AgControl');
            if (version == null) {
                isVersionSupported = true;
            }
            else if (control.IsVersionSupported(version)) {
                isVersionSupported = true;
            }
            control = null;
        }
        catch (e) {
            var plugin = navigator.plugins["Silverlight Plug-In"];
            if (plugin) {
                if (version === null) {
                    isVersionSupported = true;
                }
                else {
                    var actualVer = plugin.description;
                    if (actualVer === "1.0.30226.2")
                        actualVer = "2.0.30226.2";


                    var actualVerArray = actualVer.split(".");
                    while (actualVerArray.length > 3) {
                        actualVerArray.pop();
                    }
                    while (actualVerArray.length < 4) {
                        actualVerArray.push(0);
                    }
                    var reqVerArray = version.split(".");
                    while (reqVerArray.length > 4) {
                        reqVerArray.pop();
                    }

                    var requiredVersionPart;
                    var actualVersionPart;
                    var index = 0;


                    do {
                        requiredVersionPart = parseInt(reqVerArray[index]);
                        actualVersionPart = parseInt(actualVerArray[index]);
                        index++;
                    }
                    while (index < reqVerArray.length && requiredVersionPart === actualVersionPart);

                    if (requiredVersionPart <= actualVersionPart && !isNaN(requiredVersionPart)) {
                        isVersionSupported = true;
                    }
                }
            }
        }
    }
    catch (e) {
        isVersionSupported = false;
    }
    if (container) {
        document.body.removeChild(container);
    }

    return isVersionSupported;
}
Silverlight.WaitForInstallCompletion = function()
{
    if ( ! Silverlight.isBrowserRestartRequired && Silverlight.onSilverlightInstalled )
    {
        try
        {
            navigator.plugins.refresh();
        }
        catch(e)
        {
        }
        if ( Silverlight.isInstalled(null) )
        {
            Silverlight.onSilverlightInstalled();
        }
        else
        {
              setTimeout(Silverlight.WaitForInstallCompletion, 3000);
        }    
    }
}
Silverlight.__startup = function()
{
    Silverlight.isBrowserRestartRequired = Silverlight.isInstalled(null);//(!window.ActiveXObject || Silverlight.isInstalled(null));
    if ( !Silverlight.isBrowserRestartRequired)
    {
        Silverlight.WaitForInstallCompletion();
    }
    if (window.removeEventListener) { 
       window.removeEventListener('load', Silverlight.__startup , false);
    }
    else { 
        window.detachEvent('onload', Silverlight.__startup );
    }
}

if (window.addEventListener) 
{
    window.addEventListener('load', Silverlight.__startup , false);
}
else 
{
    window.attachEvent('onload', Silverlight.__startup );
}

///////////////////////////////////////////////////////////////////////////////
// createObject();  Params:
// parentElement of type Element, the parent element of the Silverlight Control
// source of type String
// id of type string
// properties of type String, object literal notation { name:value, name:value, name:value},
//     current properties are: width, height, background, framerate, isWindowless, enableHtmlAccess, inplaceInstallPrompt:  all are of type string
// events of type String, object literal notation { name:value, name:value, name:value},
//     current events are onLoad onError, both are type string
// initParams of type Object or object literal notation { name:value, name:value, name:value}
// userContext of type Object
/////////////////////////////////////////////////////////////////////////////////

Silverlight.createObject = function(source, parentElement, id, properties, events, initParams, userContext) {
    var slPluginHelper = new Object();
    var slProperties = properties;
    var slEvents = events;

    slPluginHelper.version = slProperties.version;
    slProperties.source = source;
    slPluginHelper.alt = slProperties.alt;

    //rename properties to their tag property names
    if (initParams)
        slProperties.initParams = initParams;
    if (slProperties.isWindowless && !slProperties.windowless)
        slProperties.windowless = slProperties.isWindowless;
    if (slProperties.framerate && !slProperties.maxFramerate)
        slProperties.maxFramerate = slProperties.framerate;
    if (id && !slProperties.id)
        slProperties.id = id;

    // remove elements which are not to be added to the instantiation tag
    delete slProperties.ignoreBrowserVer;
    delete slProperties.inplaceInstallPrompt;
    delete slProperties.version;
    delete slProperties.isWindowless;
    delete slProperties.framerate;
    delete slProperties.data;
    delete slProperties.src;
    delete slProperties.alt;


    // detect that the correct version of Silverlight is installed, else display install
    if (Silverlight.isInstalled(slPluginHelper.version)) {
        //move unknown events to the slProperties array
        for (var name in slEvents) {
            if (slEvents[name]) {
                if (name == "onLoad" && typeof slEvents[name] == "function" && slEvents[name].length != 1) {
                    var onLoadHandler = slEvents[name];
                    slEvents[name] = function(sender) { return onLoadHandler(document.getElementById(id), userContext, sender) };
                }
                var handlerName = Silverlight.__getHandlerName(slEvents[name]);
                if (handlerName != null) {
                    slProperties[name] = handlerName;
                    slEvents[name] = null;
                }
                else {
                    throw "typeof events." + name + " must be 'function' or 'string'";
                }
            }
        }
        slPluginHTML = Silverlight.buildHTML(slProperties);
    }
    //The control could not be instantiated. Show the installation prompt
    else {
        slPluginHTML = Silverlight.buildPromptHTML(slPluginHelper);

    }

    // insert or return the HTML
    if (parentElement) {
        parentElement.innerHTML = slPluginHTML;
    }
    else {
        return slPluginHTML;
    }

}

///////////////////////////////////////////////////////////////////////////////
//
//  create HTML that instantiates the control
//
///////////////////////////////////////////////////////////////////////////////
Silverlight.buildHTML = function( slProperties)
{
    var htmlBuilder = [];

    htmlBuilder.push('<object type=\"application/x-silverlight\" data="data:application/x-silverlight,"');
    if ( slProperties.id != null )
    {
        htmlBuilder.push(' id="' + slProperties.id + '"');
    }
    if ( slProperties.width != null )
    {
        htmlBuilder.push(' width="' + slProperties.width+ '"');
    }
    if ( slProperties.height != null )
    {
        htmlBuilder.push(' height="' + slProperties.height + '"');
    }
    htmlBuilder.push(' >');
    
    delete slProperties.id;
    delete slProperties.width;
    delete slProperties.height;
    
    for (var name in slProperties)
    {
        if (slProperties[name])
        {
            htmlBuilder.push('<param name="'+Silverlight.HtmlAttributeEncode(name)+'" value="'+Silverlight.HtmlAttributeEncode(slProperties[name])+'" />');
        }
    }
    htmlBuilder.push('<\/object>');
    return htmlBuilder.join('');
}




// createObjectEx, takes a single parameter of all createObject parameters enclosed in {}
Silverlight.createObjectEx = function(params)
{
    var parameters = params;
    var html = Silverlight.createObject(parameters.source, parameters.parentElement, parameters.id, parameters.properties, parameters.events, parameters.initParams, parameters.context);
    if (parameters.parentElement == null)
    {
        return html;
    }
}

///////////////////////////////////////////////////////////////////////////////////////////////
// Builds the HTML to prompt the user to download and install Silverlight
///////////////////////////////////////////////////////////////////////////////////////////////
Silverlight.buildPromptHTML = function(slPluginHelper) {
     
    var slPluginHTML = "";
    var urlRoot = Silverlight.fwlinkRoot;
    var shortVer = slPluginHelper.version;
    if (slPluginHelper.alt) {
        slPluginHTML = slPluginHelper.alt;
    }
    else {
        if (!shortVer) {
            shortVer = "";
        }
        slPluginHTML = "<a href='javascript:Silverlight.getSilverlight(\"{1}\");' style='text-decoration: none;'><img src='{2}' alt='Get Microsoft Silverlight' style='border-style: none'/></a>";
        slPluginHTML = slPluginHTML.replace('{1}', shortVer);
        slPluginHTML = slPluginHTML.replace('{2}', urlRoot + '108181');
    }

    return slPluginHTML;
}


Silverlight.getSilverlight = function(version) {
    if (Silverlight.onGetSilverlight) {
        Silverlight.onGetSilverlight();
    }

    var shortVer = "";
    var reqVerArray = String(version).split(".");
    if (reqVerArray.length > 1) {
        var majorNum = parseInt(reqVerArray[0]);
        if (isNaN(majorNum) || majorNum < 2) {
            shortVer = "1.0";
        }
        else {
            shortVer = reqVerArray[0] + '.' + reqVerArray[1];
        }
    }

    var verArg = "";

    if (shortVer.match(/^\d+\056\d+$/)) {
        verArg = "&v=" + shortVer;
    }
    Silverlight.followFWLink("114576" + verArg);
}


///////////////////////////////////////////////////////////////////////////////////////////////
/// Navigates to a url based on fwlinkid
///////////////////////////////////////////////////////////////////////////////////////////////
Silverlight.followFWLink = function(linkid) {
    top.location = Silverlight.fwlinkRoot; //+ String(linkid);
}

///////////////////////////////////////////////////////////////////////////////////////////////
/// Encodes special characters in input strings as charcodes
///////////////////////////////////////////////////////////////////////////////////////////////
Silverlight.HtmlAttributeEncode = function( strInput )
{
      var c;
      var retVal = '';

    if(strInput == null)
      {
          return null;
    }
      
      for(var cnt = 0; cnt < strInput.length; cnt++)
      {
            c = strInput.charCodeAt(cnt);

            if (( ( c > 96 ) && ( c < 123 ) ) ||
                  ( ( c > 64 ) && ( c < 91 ) ) ||
                  ( ( c > 43 ) && ( c < 58 ) && (c!=47)) ||
                  ( c == 95 ))
            {
                  retVal = retVal + String.fromCharCode(c);
            }
            else
            {
                  retVal = retVal + '&#' + c + ';';
            }
      }
      
      return retVal;
}
///////////////////////////////////////////////////////////////////////////////
//
//  Default error handling function to be used when a custom error handler is
//  not present
//
///////////////////////////////////////////////////////////////////////////////

Silverlight.default_error_handler = function (sender, args)
{
    var iErrorCode;
    var errorType = args.ErrorType;

    iErrorCode = args.ErrorCode;

    var errMsg = "\nSilverlight error message     \n" ;

    errMsg += "ErrorCode: "+ iErrorCode + "\n";


    errMsg += "ErrorType: " + errorType + "       \n";
    errMsg += "Message: " + args.ErrorMessage + "     \n";

    if (errorType == "ParserError")
    {
        errMsg += "XamlFile: " + args.xamlFile + "     \n";
        errMsg += "Line: " + args.lineNumber + "     \n";
        errMsg += "Position: " + args.charPosition + "     \n";
    }
    else if (errorType == "RuntimeError")
    {
        if (args.lineNumber != 0)
        {
            errMsg += "Line: " + args.lineNumber + "     \n";
            errMsg += "Position: " +  args.charPosition + "     \n";
        }
        errMsg += "MethodName: " + args.methodName + "     \n";
    }
    alert (errMsg);
}

///////////////////////////////////////////////////////////////////////////////////////////////
/// Releases event handler resources when the page is unloaded
///////////////////////////////////////////////////////////////////////////////////////////////
Silverlight.__cleanup = function ()
{
    for (var i = Silverlight._silverlightCount - 1; i >= 0; i--) {
        window['__slEvent' + i] = null;
    }
    Silverlight._silverlightCount = 0;
    if (window.removeEventListener) { 
       window.removeEventListener('unload', Silverlight.__cleanup , false);
    }
    else { 
        window.detachEvent('onunload', Silverlight.__cleanup );
    }
}
///////////////////////////////////////////////////////////////////////////////////////////////
/// Releases event handler resources when the page is unloaded
///////////////////////////////////////////////////////////////////////////////////////////////
Silverlight.__getHandlerName = function (handler)
{
    var handlerName = "";
    if ( typeof handler == "string")
    {
        handlerName = handler;
    }
    else if ( typeof handler == "function" )
    {
        if (Silverlight._silverlightCount == 0)
        {
            if (window.addEventListener) 
            {
                window.addEventListener('onunload', Silverlight.__cleanup , false);
            }
            else 
            {
                window.attachEvent('onunload', Silverlight.__cleanup );
            }
        }
        var count = Silverlight._silverlightCount++;
        handlerName = "__slEvent"+count;
        
        window[handlerName]=handler;
    }
    else
    {
        handlerName = null;
    }
    return handlerName;
}


// Silverlight Error..
function onSilverlightError(sender, args) {
    var appSource = "";
    if (sender != null && sender != 0) {
        appSource = sender.getHost().Source;
    }
    var errorType = args.ErrorType;
    var iErrorCode = args.ErrorCode;
    var errMsg = "Unhandled Error in Silverlight 2 Application " + appSource + "\n";
    errMsg += "Code: " + iErrorCode + "    \n";
    errMsg += "Category: " + errorType + "       \n";
    errMsg += "Message: " + args.ErrorMessage + "     \n";
    if (errorType == "ParserError") {
        errMsg += "File: " + args.xamlFile + "     \n";
        errMsg += "Line: " + args.lineNumber + "     \n";
        errMsg += "Position: " + args.charPosition + "     \n";
    }
    else if (errorType == "RuntimeError") {
        if (args.lineNumber != 0) {
            errMsg += "Line: " + args.lineNumber + "     \n";
            errMsg += "Position: " + args.charPosition + "     \n";
        }
        errMsg += "MethodName: " + args.methodName + "     \n";
    }
    //throw new Error(errMsg);
    //Error code 4001 : Image not avaiable.
    //Error code 8001 : Correct version not installed.
    if (args.ErrorCode == 8001) {
        document.getElementById('errorLocation').innerHTML = getErrorMsg();
        document.getElementById('silverlightControlHost').style.display = 'none';
    }
}
//

/* Share Video.*/
function addShareVideoDiv() {    
   
    //For Div Close        
   /* var ie = parseFloat(navigator.appVersion.split('MSIE')[1]);    
    if (ie < 8){
        var IEBaseFixId = window.setInterval(function(){
            if (document.body) {
                div1.appendChild(contents);
                
                window.clearInterval(IEBaseFixId);
            }
        }, 50);
    }
    else
    {
    div1.appendChild(contents);
    document.forms[0].appendChild(div1);    
    }
      
        document.getElementById('<%=FooterChatDivPos.ClientID%>').innerHTML = parseInt(contents.style.width) + parseInt(document.getElementById('<%=FooterChatDivPos.ClientID%>').innerHTML);
        //--Logic for reposition of div
        if(document.getElementById('<%=hReposition.ClientID%>').innerHTML=="")
        {
         document.getElementById('<%=hReposition.ClientID%>').innerHTML=Id;
        }
        else 
        {
         document.getElementById('<%=hReposition.ClientID%>').innerHTML=document.getElementById('<%=hReposition.ClientID%>').innerHTML + "," + Id;
        }   
    }*/ 
}

/* Share Video.*/


/* JM Control */
var isVideoOpen = false;
function openVideo(sFilePath, iPollMediaId, iUserId, iPollId, ServerUrl, ViewType) {
    var clientwidth = document.body.clientWidth;
    var iLeft = 270;  //For resolution more than 800
     
    if (clientwidth <= 800) {
        iLeft = 100; //For resolution  <= 800
    }
    iLeft = clientwidth / 2 - 640 / 2;
    clientwidth = clientwidth / 2;
    clientwidth = (clientwidth - iLeft) + 4;
    isVideoOpen = true;

    var sFlash = GetEmbedForPreview(sFilePath, ServerUrl, 640, 385); //EmbeddedTagOperations.js
    /*//Flash
    var pos = sFilePath.indexOf(ServerUrl);
    if (pos >= 0 && sFilePath.indexOf("<object") != 0) {
        sFlash = PlayVideo(sFilePath, iPollMediaId, iUserId, iPollId, ServerUrl); //This function is declare in global.js file.
        // Code for share video. (Embed)
        b = document.getElementById("txtEmbed");
        b.value = sFlash;
        // End of the code.PlayVideo
    }
    else if ((sFilePath.indexOf(ServerUrl.toLowerCase()) > 0)) {//JM video as embed.        
        sFlash = sFilePath;
    }
 
    else if ((sFilePath.indexOf("<object") >= 0) && (sFilePath.toLowerCase().indexOf("video.google.com") > 0)) {//embed google
        sFilePath = sFilePath.replace("http://www.video.google.com/watch?v=", "http://www.video.google.com/v/");
        sFilePath = sFilePath.replace(/,/g, "%2C");
        sFilePath = sFilePath.replace(/&/g, "%26");
        sFlash = sFilePath;
    }
//    else if ((sFilePath.toLowerCase().indexOf("video.google.com") > 0)) {//embed google
//        sFilePath = sFilePath.replace("http://www.video.google.com/watch?v=", "http://www.video.google.com/v/");
//        sFilePath = sFilePath.replace(/,/g, "%2C");
//        sFilePath = sFilePath.replace(/&/g, "%26");
//        sFlash = PlayYouTube(sFilePath);
//    }
    else if ((sFilePath.indexOf("<object") >= 0) && (sFilePath.toLowerCase().indexOf("youtube.com") > 0)) {//embed youtube
        sFilePath = sFilePath.replace("http://www.youtube.com/watch?v=", "http://www.youtube.com/v/");
        indexW = sFilePath.indexOf("width=");
        indexW = parseInt(indexW) + 6;
        sWdith = sFilePath.substring(indexW, indexW + 3);
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");

        indexH = sFilePath.indexOf("height=");
        indexH = parseInt(indexH) + 7;
        sHeight = sFilePath.substring(indexH, indexH + 3);
        sFilePath = sFilePath.replace(sHeight, "385");
        sFilePath = sFilePath.replace(sHeight, "385");
        sFilePath = sFilePath.replace(sHeight, "385");
        sFilePath = sFilePath.replace(sHeight, "385");
        sFlash = sFilePath;
        sFlash = sFilePath;
    }
    else if (sFilePath.indexOf("<object") >= 0 && sFilePath.indexOf("msnbc.msn.com") >= 0) {//MSNBC
        indexW = sFilePath.indexOf("width=");
        indexW = parseInt(indexW) + 6;
        sWdith = sFilePath.substring(indexW, indexW+3);
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");

        indexH = sFilePath.indexOf("height=");
        indexH = parseInt(indexH) + 7;
        sHeight = sFilePath.substring(indexH, indexH+3);
        sFilePath = sFilePath.replace(sHeight, "385");
        sFilePath = sFilePath.replace(sHeight, "385");
        sFilePath = sFilePath.replace(sHeight, "385");
        sFilePath = sFilePath.replace(sHeight, "385");
        sFlash = sFilePath;

    }
    else if (sFilePath.indexOf("<object") >= 0 && (sFilePath.indexOf("theonion.com") >= 0 || sFilePath.indexOf("vimeo.com") >= 0)) {//The Onion
        indexW = sFilePath.indexOf("width=");
        indexW = parseInt(indexW) + 6;
        sWdith = sFilePath.substring(indexW, indexW+3);
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");

        indexH = sFilePath.indexOf("height=");
        indexH = parseInt(indexH) + 7;
        sHeight = sFilePath.substring(indexH, indexH+3);
        sFilePath = sFilePath.replace(sHeight, "385 ");
        sFilePath = sFilePath.replace(sHeight, "385 ");
        sFilePath = sFilePath.replace(sHeight, "385 ");
        sFilePath = sFilePath.replace(sHeight, "385 ");
        sFilePath = sFilePath.replace(".swftype=", ".swf type=");
        sFlash = sFilePath;
    }
    else if (sFilePath.indexOf("<object") >= 0 && sFilePath.indexOf("player.ordienetworks.com") >= 0) {//Funnyordie
        indexW = sFilePath.indexOf("width=");
        indexW = parseInt(indexW) + 6;
        sWdith = sFilePath.substring(indexW, indexW+3);
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");

        indexH = sFilePath.indexOf("height=");
        indexH = parseInt(indexH) + 7;
        sHeight = sFilePath.substring(indexH, indexH+3);
        sFilePath = sFilePath.replace(sHeight, "385");
        sFilePath = sFilePath.replace(sHeight, "385");
        sFilePath = sFilePath.replace(sHeight, "385");
        sFilePath = sFilePath.replace(sHeight, "385");
        sFlash = sFilePath;
    }
    else if (sFilePath.indexOf("<object") >= 0 && sFilePath.indexOf("www.hulu.com") >= 0 ) {//Hulu
        indexW = sFilePath.indexOf("width=");
        indexW = parseInt(indexW) + 6;
        sWdith = sFilePath.substring(indexW, indexW + 3);
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");
        sFilePath = sFilePath.replace(sWdith, "640");

        indexH = sFilePath.indexOf("height=");
        indexH = parseInt(indexH) + 7;
        sHeight = sFilePath.substring(indexH, indexH + 3);
        sFilePath = sFilePath.replace(sHeight, "385");
        sFilePath = sFilePath.replace(sHeight, "385");
        sFilePath = sFilePath.replace(sHeight, "385");
        sFilePath = sFilePath.replace(sHeight, "385");
        sFlash = sFilePath;
    }
    else if (sFilePath.indexOf("<object") >= 0 && sFilePath.indexOf("cdn.turner.com") >= 0){//cnn
        indexW = sFilePath.indexOf("width=");
        indexW = parseInt(indexW) + 6;
        sWdith = sFilePath.substring(indexW, indexW + 3);
        sFilePath = sFilePath.replace(sWdith, "640");
//        sFilePath = sFilePath.replace(sWdith, "640");
//        sFilePath = sFilePath.replace(sWdith, "640");
//        sFilePath = sFilePath.replace(sWdith, "640");

//        indexH = sFilePath.indexOf("height=");
//        indexH = parseInt(indexH) + 7;
//        sHeight = sFilePath.substring(indexH, indexH + 3);
//        sFilePath = sFilePath.replace(sHeight, "385");
//        sFilePath = sFilePath.replace(sHeight, "385");
//        sFilePath = sFilePath.replace(sHeight, "385");
//        sFilePath = sFilePath.replace(sHeight, "385");
        sFlash = sFilePath;
      }
    else if (sFilePath.indexOf("<embed") == 0 && sFilePath.indexOf("video.google.com") >= 0) {//embed video.google
    indexW = sFilePath.indexOf("width:");
        indexW = parseInt(indexW) + 6;
        sWdith = sFilePath.substring(indexW, indexW + 3);
        sFilePath = sFilePath.replace(sWdith, "640");
        indexH = sFilePath.indexOf("height:");
        indexH = parseInt(indexH) + 7;
        sHeight = sFilePath.substring(indexH, indexH + 3);
        sFilePath = sFilePath.replace(sHeight, "385");
        sFlash = sFilePath;
    }
    else if (sFilePath.indexOf("<embed") == 0) {//embed other than video.google
    sFlash = sFilePath;
    }
    //For Web Url.
    else if (sFilePath.indexOf("video.google.com") >= 0) // for Google Videos
    {
        sFilePath = sFilePath.replace(/,/g, "%2C");
        sFilePath = sFilePath.replace(/&/g, "%26");
        //param = param.replace(/?/g, "%3F");
        //param = param.replace(/=/g, "%3D");
        sFlash = PlayYouTube(sFilePath);
    }    
    else //Other video player like youtube, google video player.
    {
        sFilePath = sFilePath.replace('autoplay=1', 'autoplay=0');
        sFlash = PlayYouTube(sFilePath); //This function is declare in global.js file.
    }
    */
    
    if (ViewType == "ListView")
        document.getElementById(dvFlashId).innerHTML = "<div class='bg_gray_box' id='dvOpenImage'><table><tr><td>" + sFlash + "</td><td valign='top'><img src='" + ServerUrl + "Themes/default/images/close.gif' onclick='javascript:closeVideo(12);' class='left'   border='0' /></td></tr></table><div class='clear_both'></div> </div> ";
    else
        document.getElementById(dvFlashId).innerHTML = '<div id="VideoBorder">' + sFlash + '</div>';

    document.getElementById(dvFlashId).style.display = 'block';
    //alert(iLeft);
    document.getElementById(dvFlashId).style.left = iLeft + "px";  //(clientwidth - 3) + "px";
        document.getElementById(dvFlashId).style.top = 131 + "px";
         
}

function getFlashMovie(movieName) {
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? window[movieName] : document[movieName];
}

function closeVideo(param) {

    try {
        a = document.getElementById("divShare");
        a.style.display = "none";
        document.getElementById(dvFlashId).innerHTML = "";
        document.getElementById(dvFlashId).className = "";
        document.getElementById(dvFlashId).style.display = 'none';
        document.getElementById("SilverLightControl").style.height = 370 + "px";
        document.getElementById("SilverLightControl").style.width = 1000 + "px";
        var text = "0";
        getFlashMovie("jmFLVPLayer").sendMessageToFlash(text);       
    }
    catch (ex) {
        try { document.getElementById('jmFLVPLayer').sendMessageToFlash(text); }
        catch (exx)
        { }
    }
}

function CloseVideo_Completed() {

    if (document.getElementById(dvFlashId) != null)
        document.getElementById(dvFlashId).innerHTML = "";
}

function getTextFromFlash(str) {
    document.htmlForm.receivedField.value = "From Flash: " + str;
    return str + " received";
}
function GetSearchText() {

    var objSearchText = document.getElementById("dvSearchQuestionJM");
    if (objSearchText != null) {
        objSearchText.innerHTML = "";
    }
        
   
}
function OpenSearchText(url)
 {
    var objSearchText = document.getElementById("dvSearchQuestionJM");
    if (objSearchText != null)
    {
        objSearchText.innerHTML = "<input type='text' id='txtSearchDiv' style='height:15px;width:100%;border:2px' visible='true'/>";
        objSearchText.style.display = 'block';
        //objSearchText.style.left = 2 + "px";
        objSearchText.style.top = 135 + "px";
    }
}
var resonID = 0;

/*This function will hide Bad Raves*/
function jsHideBadRaves() {
    
    document.getElementById("dvBadRaves").style.display = 'none';
}


/*This function will Open Bad Raves div on click of report link on silverlight control*/
function jsShowBadRaves(Pollid, UID, ShowHide, ServerUrl) {
     
    
     var URLT = Pollid +"-" + ServerUrl + "-"+ UID;
     var clientwidth = document.body.clientWidth;
     var iLeft = 200;
     if (clientwidth < 800) 
     {
         iLeft = 140;
     }
     clientwidth = clientwidth / 2;
     clientwidth = (clientwidth - iLeft);
     var objddlBadRaves = document.getElementById("dvBadRaves");

     var strInnerHTML = "<div class='bg_gray_box' style='width:350px;height:140px; padding:5px; background-image:url('" + ServerUrl + "ClientBin/Images/bggra.png'); background-repeat:no-repeat;border-width:1px;border-color:Red;border-style:solid'>";
     strInnerHTML += "<div style='width:100%; height:20px; color:#FF0000'><strong>Please select the type of abuse you would like to report.</strong><a href='#'><img src='" + ServerUrl + "ClientBin/Images/closebut.gif' width='14' height='13' border='0' onclick='javascript:closeReport();'/></a></div>";
     strInnerHTML += "<label for='user'>Reason <span style='color:#FF0000;padding-right:30px'>*</span></label><select name='select' onchange='cChange(this)'><option style='width:150px' value='0'>Select Reason</option>";
     strInnerHTML += "<option style='width:150px' value='1'>Not Suitible for minors</option>";
     strInnerHTML += "<option style='width:150px' value='2'>Pornography/Obscenity</option>";
     strInnerHTML += "<option style='width:150px' value='3'>Racist/Hateful</option>";
     strInnerHTML += "<option style='width:150px' value='4'>Harrassment/Cyberbullying</option>";
     strInnerHTML += "<option style='width:150px' value='5'>Other</option>";
     strInnerHTML += "</select><br/><label for='comments' style='vertical-align:top;padding-right:12px'>Description</label><textarea id='comments' style='width: 220px;height: 50px;' ></textarea>";
     strInnerHTML += "<br/><a href='#'><img src='" + ServerUrl + "Themes/default/images/btn_Submit.png' border='0' onclick='javascript:CallReportFunc(" + Pollid + ");'/></a></form></div>";

//     strInnerHTML += "<br/><a href='#'><img src='" + ServerUrl + "Themes/default/images/btn_Submit.png' width='100' height='40' border='0' onclick='javascript:CallReportFunc(" + Pollid + ");'/></a></form></div>";
     
     //strInnerHTML += "<br/><input type='button' style='width:80px;background-image:url('" + ServerUrl + "/btn_submit.png');' name='submitbutton' id='submitbutton' value='Submit' onclick='javascript:CallReportFunc(" + Pollid + ");' /></form></div>";
     strInnerHTML += " <input type='hidden' name='hdnUID' value='" + UID + "'/>";
     strInnerHTML += " <input type='hidden' name='hdnServerUrl' value='" + ServerUrl + "'/>";     
     
     document.getElementById("dvBadRaves").innerHTML = strInnerHTML;
     document.getElementById("dvBadRaves").style.display = 'block';
     document.getElementById("dvBadRaves").style.left = clientwidth + "px";
     document.getElementById("dvBadRaves").style.top = 240 + "px";
 }
/*This function will navigate to result page on click of share button*/
 function ShowShare(serverURL, pollid, ViewType) {
        var URL = serverURL + "/Poll/PollResultDetails.aspx?pollid=" + pollid ;
        var clientwidth = document.body.clientWidth;
        var iTop = 380;
        //var iTop = 202;
        var iLeft = 635;
        /*
        if (clientwidth < 800)
            iLeft = 614;
        else if (clientwidth < 1024)
            iLeft = 616;
        else if (clientwidth < 1152)
            iLeft = 680;
        else if (clientwidth < 1280)
            iLeft = 743;
        else if (clientwidth < 1400)
            iLeft = 803; 
        */
        clientwidth = clientwidth / 2;
        clientwidth = (clientwidth - iLeft);
        var varShareThis = document.getElementById("dvShareQuestion");
        if (varShareThis != null)
        {
            //document.getElementById('dvAddThis').style.display = 'block';
            //var ShowShareinnerHTML = "<table style='height:165px;width:160px;padding-bottom:10' class='bg_Share' >";
            var ShowShareinnerHTML = "<table style='padding-bottom:10'>";
           /*
            ShowShareinnerHTML += "<tr><td><a href='http://www.facebook.com/share.php?u=" + URL + "' onclick=\"return fbs_click('" + URL + "')\" target='_blank' class='fb_FaceBook_link'>Facebook</a></td></tr>";
            ShowShareinnerHTML += "<tr><td>";
            ShowShareinnerHTML += "<a href='http://www.google.com/bookmarks/mark?op=edit&bkmk=" + URL + "' onclick=\"return google_click('" + URL + "')\" target='_blank' class='fb_Google_link'>Google</a></td></tr>";
            ShowShareinnerHTML += "</td></tr><tr><td><a href='http://twitter.com/home?status=" + URL + "' onclick=\"return twit_click('" + URL + "')\" target='_blank' class='fb_Twitter_link'>Twitter</a></td></tr>";
            ShowShareinnerHTML += "</td></tr><tr><td><a href='http://digg.com/submit?url=" + URL + "' onclick=\"return digg_click('" + URL + "')\" target='_blank' class='Digg_link' type='Crawl'>Digg</a></td></tr>";
            ShowShareinnerHTML += "</td></tr><tr><td><a href='http://www.stumbleupon.com/submit?url=" + URL + "' target='_blank' class='Stumble_link'>Stumbleupon</a></td></tr>";
            ShowShareinnerHTML += "</td></tr><tr style='height:10px'></tr>"
            ShowShareinnerHTML += "<tr><td>";
           */
           
           /*
            ShowShareinnerHTML += "<div class='addthis_toolbox addthis_default_style' style='float: right; text-align: right'>";
            ShowShareinnerHTML += "<a class='addthis_button_facebook'></a><a class='addthis_button_email'></a><a class='addthis_button_favorites'>";
            ShowShareinnerHTML += "</a><a class='addthis_button_print'></a><span class='addthis_separator'>|</span>";
            ShowShareinnerHTML += "<a href='http://www.addthis.com/bookmark.php?v=250&amp;pub=xa-4a8f93e278e25b46' class='addthis_button_expanded'> More</a>";
            ShowShareinnerHTML += "</div>"
            ShowShareinnerHTML += document.getElementById('dvAddThis').innerHTML;
           */
            ShowShareinnerHTML += "<tr valign='top'><td>"
            ShowShareinnerHTML += "<a class=\"st-taf\" href=\"http://tellafriend.socialtwist.com:80\" onclick=\"return false;\" style=\"border:0;padding:0;margin:0;\">";
            ShowShareinnerHTML += "<div id='imgTellandShare' onmouseout=\"STTAFFUNC.hideHoverMap(this)\" onmouseover=\"STTAFFUNC.showHoverMap(this, '2009111930017', '" + URL + "', document.title)\" onclick=\"STTAFFUNC.showHoverMap(this, '2009111930017', '" + URL + "', document.title)\"></div></a>";
            ShowShareinnerHTML += "</td></tr></table>";
            
            if (ViewType == "ListView") {
                document.getElementById("dvShareQuestion").innerHTML = "<div class='bg_gray_box centerdiv' id='dvOpenImage'><table><tr><td>" + ShowShareinnerHTML + "</td><td valign='top'><img src='" + ServerUrl + "/Themes/default/images/close.gif' onclick='javascript:closeSharePopUp();' class='left'   border='0' /></td></tr></table><div class='clear_both'></div> </div> ";
                document.getElementById("dvShareQuestion").style.display = 'block';
                document.getElementById("dvShareQuestion").className = "ShowSharecenter";
            }
            else {
                document.getElementById("dvShareQuestion").innerHTML = ShowShareinnerHTML;
                document.getElementById("dvShareQuestion").style.display = 'block';
                document.getElementById("dvShareQuestion").style.left = iLeft + "px";
                document.getElementById("dvShareQuestion").style.top = iTop + "px";
            }
            //document.getElementById('imgTellandShare').click();
            //this function defined in tellafrined js file.
            STTAFFUNC.showHoverMap(document.getElementById('imgTellandShare'), '2009111930017', URL, document.title);
        }
    }

    function ShareQuestionHide() {
        //document.getElementById("dvShareQuestion").innerHTML = "";
        //document.getElementById("dvShareQuestion").style.display = 'none';
    }
    
    function digg_click(URL) {
        u = location.href; ;
        t = "JMPage";
        window.open('http://digg.com/submit?url=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
        return false;
    }
    function google_click(URL) {
        u = location.href; ;
        t = "JMPage";
        window.open('http://www.google.com/bookmarks/mark?op=edit&bkmk' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
        return false;
    }
    function twit_click(URL) {
        u = location.href; ;
        t = "JMPage";
        window.open('http://twitter.com/home?status=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
        return false;
    }
 function fbs_click(URL) 
{     
    u = location.href; ;
    t="JMPage";
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
    return false;
}
 /*This function will fire on change event of Reson DropDown List*/
 function cChange(opt) 
 {     
    resonID = opt.value;
 }
 /*This function will close the Badraves pop-up window */
 function closeSharePopUp() {
     document.getElementById("dvShareQuestion").innerHTML = "";
    
 }
 function closeReport() {
       if(document.getElementById("dvBadRaves")!=null)
      document.getElementById("dvBadRaves").innerHTML = "";     
 }
 /*This Function will call Report page to update the comments reported by the user in DB*/
 function CallReportFunc(Pollid, UID) {
      
     var serverUrl = '';
     if(  document.getElementById("hdnServerUrl"))
        serverUrl= document.getElementById("hdnServerUrl").value;
     var mylist = document.getElementById("select");
     var abuseRson = resonID;
     var response = 0;
     var reasonText = '';
     if(document.getElementById("comments"))
         reasonText = document.getElementById("comments").value;

     var HiddenUid = '';
     if (document.getElementById("hdnUID"))
          HiddenUid = document.getElementById("hdnUID").value;

      var url = serverUrl + "ReportPage.aspx?_POLLID=" + Pollid + "&serverURL=" + serverUrl + "&_UserId=" + UID + "&Comments=" + reasonText + "&ABR=" + abuseRson + "";
       
     if (abuseRson == null || abuseRson == "0")
       {
           return false;
      }
      else {
          http_request = false;
         
          if (window.XMLHttpRequest) 
          { // Mozilla, Safari,...
              http_request = new XMLHttpRequest();
              if (http_request.overrideMimeType)
               {
                  http_request.overrideMimeType('text/xml');
              }
          } else if (window.ActiveXObject) 
          { // IE
              try 
              {
                  http_request = new ActiveXObject("Msxml2.XMLHTTP");
              } catch (e) 
              {
                  try 
                  {
                      http_request = new ActiveXObject("Microsoft.XMLHTTP");
                  } catch (e) { }
              }
          }
          if (!http_request) {
              //alert('Cannot create XMLHTTP instance');
              return false;
          }
          
          http_request.open('GET', url, true);
          http_request.send(null);
          closeReport();
      }
  }

  var pImagePath_SL; // = "themes/default/images/CustomPopUp/";
  var pWidthPopMaster_SL = 690;
  var pHeightPopMaster_SL = 400;
  var pTitlePopMaster_SL = "Log In or Become a Member";
   
  var XCord_SL = 0;
  var YCord_SL = 0;


  function RenderPopUpPopMasterHeader(type, ServerURL) {
       
      pImagePath_SL =ServerURL + "themes/default/images/CustomPopUp/";
      str = '<div style="width:' + pWidthPopMaster_SL + 'px;height:' + pHeightPopMaster_SL + 'px; position:absolute;z-index:1023; top:' + YCord_SL + '; left:' + XCord_SL + ';">';
      str += '<div style="position:absolute; left:22px; top:13px; z-index:1;"><span style="color:#FFFFFF; font-family:Trebuchet MS;font-weight:bold;font-size:12px">' + pTitlePopMaster_SL + '</span></div>';
      str += '<div id="CloseMe" onmousemove="document.getElementById(\'CloseMe\').style.backgroundColor = \'white\';" onmouseout="document.getElementById(\'CloseMe\').style.backgroundColor = \'transparent\';" onclick="document.getElementById(\'divFLoginWindow\').style.display=\'none\';"  style="position:absolute;cursor:hand;cursor:pointer;height:20px;width:20px; right:24px; top:12px; z-index:1;"><img  style="margin-top:5px;margin-left:5px;"  src="' + pImagePath_SL + 'closePop.png" height="11" width="11"/></div>';
      str += '<div id="TopImageContainer">';
      str += '<div id="TopLeftImage" style="float:left; width:15px;"><img style=\'vertical-align:bottom;\' src="' + pImagePath_SL + 'LeftTop.png" height="39" width="15" /></div>';
      str += '<div id="TopCenterImage" style="float:left; width:' + (pWidthPopMaster_SL - 40) + 'px;"><img  style=\'vertical-align:bottom\'  src="' + pImagePath_SL + 'MidTop.png" height="39" width="' + (pWidthPopMaster_SL - 40) + '" /></div>';
      str += '<div id="TopRightImage" style="float:left; width:19px;"><img style=\'vertical-align:bottom\' src="' + pImagePath + 'RightTop.png" height="39" width="19" /></div>';
      str += '</div><div id="Middle_Div">';
      str += '<div id="LeftMiddleDiv" style="float:left; width:15px; height:' + (pHeightPopMaster_SL - 30) + 'px;"><img src="' + pImagePath_SL + 'LeftMiddle.png" height="' + (pHeightPopMaster_SL - 30) + '" width="15" /></div>';
      if (type == 'JmHeaderLogin') {
          str += '<div id="CenterMiddleDiv"  style="float:left;overflow:hidden; background-color:#ffffff; height:' + (pHeightPopMaster_SL - 30) + 'px; width:' + (pWidthPopMaster_SL - 40) + 'px;"><div style="padding-top:14px; padding-left:3px; padding-right:3px; z-index:1;width:100%;overflow:hidden">' + '<iframe frameborder="0" width=\'98%\' height=\'380\'  src=\'jmLoginPopup.aspx?formPollResult=JmHeaderLogin' + ' \'style=\'height:380px;overflow:hidden\'></iframe>' + '</div></div>';
      }
      else if (type == 'JmHeaderAskQ') {
      str += '<div id="CenterMiddleDiv"  style="float:left;overflow:hidden; background-color:#ffffff; height:' + (pHeightPopMaster_SL - 30) + 'px; width:' + (pWidthPopMaster_SL - 40) + 'px;"><div style="padding-top:14px; padding-left:3px; padding-right:3px; z-index:1;width:100%;overflow:hidden">' + '<iframe frameborder="0" width=\'98%\' height=\'380\'  src=\'jmLoginPopup.aspx?formPollResult=JmHeaderAskQ' + ' \'style=\'height:380px;overflow:hidden\'></iframe>' + '</div></div>';
      }
      else if (type == 'JmHeaderContest') {
      str += '<div id="CenterMiddleDiv"  style="float:left;overflow:hidden; background-color:#ffffff; height:' + (pHeightPopMaster_SL - 30) + 'px; width:' + (pWidthPopMaster_SL - 40) + 'px;"><div style="padding-top:14px; padding-left:3px; padding-right:3px; z-index:1;width:100%;overflow:hidden">' + '<iframe frameborder="0" width=\'98%\' height=\'380\'  src=\'jmLoginPopup.aspx?formPollResult=JmHeaderContest' + ' \'style=\'height:380px;overflow:hidden\'></iframe>' + '</div></div>';
      }
      else if (type == 'SharedQ') {
      str += '<div id="CenterMiddleDiv"  style="float:left;overflow:hidden; background-color:#ffffff; height:' + (pHeightPopMaster_SL - 30) + 'px; width:' + (pWidthPopMaster_SL - 40) + 'px;"><div style="padding-top:14px; padding-left:3px; padding-right:3px; z-index:1;width:100%;overflow:hidden">' + '<iframe frameborder="0" width=\'98%\' height=\'380\'  src=' +   ServerURL + 'jmLoginPopup.aspx?formPollResult=SharedQ' + ' \'style=\'height:380px;overflow:hidden\'></iframe>' + '</div></div>';
  }

  else if (type == 'RatingFromSL') {
  str += '<div id="CenterMiddleDiv"  style="float:left;overflow:hidden; background-color:#ffffff; height:' + (pHeightPopMaster_SL - 30) + 'px; width:' + (pWidthPopMaster_SL - 40) + 'px;"><div style="padding-top:14px; padding-left:3px; padding-right:3px; z-index:1;width:100%;overflow:hidden">' + '<iframe frameborder="0" width=\'98%\' height=\'380\'  src=' + ServerURL + 'jmLoginPopup.aspx?formPollResult=RatingFromSL' + ' \'style=\'height:380px;overflow:hidden\'></iframe>' + '</div></div>';
  }

  else if (type == 'ReportAbuseFromSL') {
  str += '<div id="CenterMiddleDiv"  style="float:left;overflow:hidden; background-color:#ffffff; height:' + (pHeightPopMaster_SL - 30) + 'px; width:' + (pWidthPopMaster_SL - 40) + 'px;"><div style="padding-top:14px; padding-left:3px; padding-right:3px; z-index:1;width:100%;overflow:hidden">' + '<iframe frameborder="0" width=\'98%\' height=\'380\'  src=' + ServerURL + 'jmLoginPopup.aspx?formPollResult=ReportAbuseFromSL' + ' \'style=\'height:380px;overflow:hidden\'></iframe>' + '</div></div>';
}

else if (type.indexOf('ViewProfile') != -1) {
var SplitUserId = type.split("_");
str += '<div id="CenterMiddleDiv"  style="float:left;overflow:hidden; background-color:#ffffff; height:' + (pHeightPopMaster_SL - 30) + 'px; width:' + (pWidthPopMaster_SL - 40) + 'px;"><div style="padding-top:14px; padding-left:3px; padding-right:3px; z-index:1;width:100%;overflow:hidden">' + '<iframe frameborder="0" width=\'98%\' height=\'380\'  src=' + ServerURL + 'jmLoginPopup.aspx?formPollResult=ViewProfile&UserId=' + SplitUserId[1] + ' \'style=\'height:380px;overflow:hidden\'></iframe>' + '</div></div>';
}

else if (type.indexOf('SeeQuestions') != -1) {
    var SplitUserId = type.split("_");
    str += '<div id="CenterMiddleDiv"  style="float:left;overflow:hidden; background-color:#ffffff; height:' + (pHeightPopMaster_SL - 30) + 'px; width:' + (pWidthPopMaster_SL - 40) + 'px;"><div style="padding-top:14px; padding-left:3px; padding-right:3px; z-index:1;width:100%;overflow:hidden">' + '<iframe frameborder="0" width=\'98%\' height=\'380\'  src=' + ServerURL + 'jmLoginPopup.aspx?formPollResult=SeeQuestions&UserId=' + SplitUserId[1] + ' \'style=\'height:380px;overflow:hidden\'></iframe>' + '</div></div>';
}

else if (type.indexOf('SeeAnswers') != -1) {
    var SplitUserId = type.split("_");
    str += '<div id="CenterMiddleDiv"  style="float:left;overflow:hidden; background-color:#ffffff; height:' + (pHeightPopMaster_SL - 30) + 'px; width:' + (pWidthPopMaster_SL - 40) + 'px;"><div style="padding-top:14px; padding-left:3px; padding-right:3px; z-index:1;width:100%;overflow:hidden">' + '<iframe frameborder="0" width=\'98%\' height=\'380\'  src=' + ServerURL + 'jmLoginPopup.aspx?formPollResult=SeeAnswers&UserId=' + SplitUserId[1] + ' \'style=\'height:380px;overflow:hidden\'></iframe>' + '</div></div>';
}

else if (type.indexOf('FriendReq') != -1) {
    var SplitUserId = type.split("_");
    str += '<div id="CenterMiddleDiv"  style="float:left;overflow:hidden; background-color:#ffffff; height:' + (pHeightPopMaster_SL - 30) + 'px; width:' + (pWidthPopMaster_SL - 40) + 'px;"><div style="padding-top:14px; padding-left:3px; padding-right:3px; z-index:1;width:100%;overflow:hidden">' + '<iframe frameborder="0" width=\'98%\' height=\'380\'  src=' + ServerURL + 'jmLoginPopup.aspx?formPollResult=FriendReq&UserId=' + SplitUserId[1] + ' \'style=\'height:380px;overflow:hidden\'></iframe>' + '</div></div>';
}


  
  

      str += '<div id="RightMiddleDiv" style="float:left; width:19px; height:' + (pHeightPopMaster_SL - 30) + 'px;"><img src="' + pImagePath_SL + 'RightMiddle.png" height="' + (pHeightPopMaster_SL - 30) + '" width="19" /></div>';
      str += '</div><div id="BottomImages">';
      str += '<div style=" width:15px;float:left;"><img src="' + pImagePath_SL + 'LeftBottom.png" height="32" width="15" /></div>';
      str += '<div style=" width:' + (pWidthPopMaster_SL - 40) + 'px;float:left;"><img src="' + pImagePath_SL + 'MidBottom.png" height="32" width="' + (pWidthPopMaster_SL - 40) + '" /></div>';
      str += '<div style=" width:19px;float:left;"><img src="' + pImagePath_SL + 'RightBottom.png"  width="19" height="32" /></div></div></div>';

      return str;
  }


 
        
  function ShowLoginScreenOnWindow_SL(type,ServerURL) {
       
      if (document.getElementById('divFLoginWindow') != null) {
          document.getElementById('divFLoginWindow').style.display = 'block';
          document.getElementById('divFLoginWindow').innerHTML = RenderPopUpPopMasterHeader(type, ServerURL);
           
          document.getElementById('divFLoginWindow').style.zIndex = 99999;
          document.getElementById('divFLoginWindow').style.position = 'absolute';
      }
  }
 
/*This function will navigate to login page*/
 function OpenLoginPage(serverURL) {
     window.location.href = serverURL + "jmlogin.aspx";
     //window.navigate(serverURL + "jmlogin.aspx"); 
 }
/* JM Control end */
function getErrorMsg() {
    var msg = "This sample application was built with Silverlight 3 Beta.\n";
    msg += "You currently have Silverlight installed, but not the version required to view this sample.\n\n";
    msg += "<a href=\"http://go.microsoft.com/fwlink/?LinkID=143433\">Click here to download Silverlight 3</a>.<br><br>";
    msg += "<a  href=\"http://go.microsoft.com/fwlink/?LinkID=143433\" style=\"text-decoration: none; align:center\">\n";
    msg += "<img src=\"http://go.microsoft.com/fwlink/?LinkId=108181\" alt=\"Get Microsoft Silverlight\" style=\"border-style: none\" />";
     msg += "<br><br>"                            
    return msg; 

}

function pluginError(sender, args) {
    if (args.ErrorCode == 8001) {
        document.getElementById('errorLocation').innerHTML = getErrorMsg();
        document.getElementById('silverlightControlHost').style.display = 'none';
    }
}


function openImage(imageurl, ServerUrl) {
    var clientwidth = document.body.clientWidth;
    var iLeft = 300;
    if (clientwidth < 800) {
        iLeft = 200;
    }
    clientwidth = clientwidth / 2;
    clientwidth = (clientwidth - iLeft) + 4;
    document.getElementById(dvFlashId).innerHTML = " <div class='bg_gray_box' id='dvOpenImage'><table><tr><td><img width='500px'  src='" + imageurl + "' border='0' /></td><td valign='top'><img src='" + ServerUrl + "Themes/default/images/close.gif' onclick='javascript:CloseVideo_Completed();' class='left'   border='0' /></td></tr></table><div class='clear_both'></div> </div>";
    document.getElementById(dvFlashId).style.display = 'block';
    // document.getElementById("dvFlash").className = "centerdiv";    
    document.getElementById(dvFlashId).style.left = clientwidth + "px";
    document.getElementById(dvFlashId).style.top = 165 + "px";
}

function openArticleURL(articleurl, ServerUrl) {
    
    window.open(articleurl, "mywindow", "location=0,menubar=1,resizable=1,status=1,scrollbars=1,  width=500,height=600");
}

function openListViewMedia(PollMediaType, ServerUrl, PollImagePath, PollMediaId, UserID, PollID) {
    ServerUrl = ServerUrl + "/";
    switch (PollMediaType) {
        case "V":
            openVideo(PollImagePath, PollMediaId, UserID, PollID, ServerUrl,'ListView');
            break;
        case "I":
            openImage(PollImagePath, ServerUrl);
            break;
        case "A":
            openArticleURL(PollImagePath, ServerUrl);
            break;
        
    }
}
String.prototype.startsWith = function(str)
{ return (this.match("^" + str) == str) }


function ShowPollResultDiv()
 { 
     if ((document.getElementById('ResultContent1') != null) && (document.getElementById('ResultContent2') != null)) {
         if (document.getElementById('ResultContent1').getElementsByTagName('input'))
         {
            var inputs = document.getElementById('ResultContent1').getElementsByTagName('input');
            for (var a = 0; a < inputs.length; a++) {
            if(inputs[a]!='undefined')
                inputs[a].disabled = false;
             }
         }
         if (document.getElementById('ResultContent2').getElementsByTagName('input')) {
             var inputs = document.getElementById('ResultContent2').getElementsByTagName('input');
             for (var b = 0; b < inputs.length; b++) {
                 if (inputs[b] != 'undefined')
                     inputs[b].disabled = false;
             }
         }

         if (document.getElementById('ResultContent1').getElementsByTagName('a')) {
             var inputs = document.getElementById('ResultContent1').getElementsByTagName('a');
             for (var c = 0; c < inputs.length; c++) {
                 if (inputs[c] != 'undefined')
                     inputs[c].disabled = false;
             }
         }
         if (document.getElementById('ResultContent2').getElementsByTagName('a')) {
             var inputs = document.getElementById('ResultContent2').getElementsByTagName('a');
             for (var d = 0; d < inputs.length; d++) {
                 if (inputs[d] != 'undefined')
                     inputs[d].disabled = false;
             }
         }

         if (document.getElementById('ResultContent1').getElementsByTagName('textarea')) {
             var inputs = document.getElementById('ResultContent1').getElementsByTagName('textarea');
             for (var e = 0; e < inputs.length; e++) {
                 if (inputs[e] != 'undefined')
                     inputs[e].disabled = false;
             }
         }

         if (document.getElementById('ResultContent2').getElementsByTagName('textarea')) {
             var inputs = document.getElementById('ResultContent2').getElementsByTagName('textarea');
             for (var f = 0; f < inputs.length; f++) {
                 if (inputs[f] != 'undefined')
                     inputs[f].disabled = false;
             }
         }
         if (document.getElementById('ResultContent1').getElementsByTagName('div')) {
             var inputs = document.getElementById('ResultContent1').getElementsByTagName('div');
             for (var g = 0; g < inputs.length; g++) {
                 if (inputs[g] != 'undefined')
                     inputs[g].disabled = false;
             }
         }
         if (document.getElementById('ResultContent2').getElementsByTagName('div')) {
             var inputs = document.getElementById('ResultContent2').getElementsByTagName('div');
             for (var h = 0; h < inputs.length; h++) {
                 if (inputs[h] != 'undefined')
                     inputs[h].disabled = false;
             }
         }

         if (document.getElementById('ResultContent1').getElementsByTagName('span')) {
             var inputs = document.getElementById('ResultContent1').getElementsByTagName('span');
             for (var k = 0; k < inputs.length; k++) {
                 if (inputs[k] != 'undefined')
                     inputs[k].disabled = false;
             }
         }
         if (document.getElementById('ResultContent2').getElementsByTagName('span')) {
             var inputs = document.getElementById('ResultContent2').getElementsByTagName('span');
             for (var l = 0; l < inputs.length; l++) {
                 if (inputs[l] != 'undefined')
                     inputs[l].disabled = false;
             }
         }
         
       }
}
    function HidePollResultDiv()
     {

         if ((document.getElementById('ResultContent1') != null) && (document.getElementById('ResultContent2') != null)) {
             if (document.getElementById('ResultContent1').getElementsByTagName('input')) {
                 var inputs = document.getElementById('ResultContent1').getElementsByTagName('input');
                 for (var i = 0; i < inputs.length; i++) {
                     if (inputs[i] != null)
                         inputs[i].disabled = true;
                 }
             }
             if (document.getElementById('ResultContent2').getElementsByTagName('input')) {
                 var inputs = document.getElementById('ResultContent2').getElementsByTagName('input');
                 for (var j = 0; j < inputs.length; j++) {
                     if (inputs[j] != null)
                         inputs[j].disabled = true;
                 }
             }
             if (document.getElementById('ResultContent1').getElementsByTagName('a')) {
                 var inputs = document.getElementById('ResultContent1').getElementsByTagName('a');
                 for (var i = 0; i < inputs.length; i++) {
                     if (inputs[i] != null)
                         inputs[i].disabled = true;
                 }
             }
             if (document.getElementById('ResultContent2').getElementsByTagName('a')) {
                 var inputs = document.getElementById('ResultContent2').getElementsByTagName('a');
                 for (var j = 0; j < inputs.length; j++) {
                     if (inputs[j] != null)
                         inputs[j].disabled = true;
                 }
             }
             if (document.getElementById('ResultContent1').getElementsByTagName('textarea')) {
                 var inputs = document.getElementById('ResultContent1').getElementsByTagName('textarea');
                 for (var i = 0; i < inputs.length; i++) {
                     if (inputs[i] != null)
                         inputs[i].disabled = true;
                 }
             }
             if (document.getElementById('ResultContent2').getElementsByTagName('textarea')) {
                 var inputs = document.getElementById('ResultContent2').getElementsByTagName('textarea');
                 for (var j = 0; j < inputs.length; j++) {
                     if (inputs[j] != null)
                         inputs[j].disabled = true;
                 }
             }
             if (document.getElementById('ResultContent1').getElementsByTagName('div')) {
                 var inputs = document.getElementById('ResultContent1').getElementsByTagName('div');
                 for (var i = 0; i < inputs.length; i++) {
                     if (inputs[i] != null)
                         inputs[i].disabled = true;
                 }
             }
             if (document.getElementById('ResultContent2').getElementsByTagName('div')) {
                 var inputs = document.getElementById('ResultContent2').getElementsByTagName('div');
                 for (var j = 0; j < inputs.length; j++) {
                     if (inputs[j] != null)
                         inputs[j].disabled = true;
                 }
             }

             if (document.getElementById('ResultContent1').getElementsByTagName('span')) {
                 var inputs = document.getElementById('ResultContent1').getElementsByTagName('span');
                 for (var i = 0; i < inputs.length; i++) {
                     if (inputs[i] != null)
                         inputs[i].disabled = true;
                 }
             }
             if (document.getElementById('ResultContent2').getElementsByTagName('span')) {
                 var inputs = document.getElementById('ResultContent2').getElementsByTagName('span');
                 for (var j = 0; j < inputs.length; j++) {
                     if (inputs[j] != null)
                         inputs[j].disabled = true;
                 } 
             }
 
          }
    }


    