﻿/******************************/
//Video plyer common functions

function PlayYouTube(param,setWidth,setHeight) {
   
    var browser=navigator.appName;
    var b_version=navigator.appVersion;
    //check to see if this is non google
    //http://embed.break.com
    if(param.indexOf("http://embed.break.com") == -1) param += "&iv_load_policy=3&hl=en&fs=1&rel=0&egm=0";
    if(browser == "Microsoft Internet Explorer" && parseFloat(b_version) == "4")
        var sFlash = '<embed src="' + param + '" type="application/x-shockwave-flash" enablejsurl="false" enablehref="false" wmode="transparent" allownetworking="internal" allowscriptaccess="never" allowscriptaccess="always" allowfullscreen="true" width="' + setWidth + '" height="' + setHeight + '"></embed>';
    else
        var sFlash = '<object width="' + setWidth + '" height="' + setHeight + '"><param name="movie" value="' + param + '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="' + param + '" type="application/x-shockwave-flash" enablejsurl="false" enablehref="false" wmode="transparent" allownetworking="internal" allowscriptaccess="never" allowscriptaccess="always" allowfullscreen="true" width="' + setWidth + '" height="' + setHeight + '"></embed></object>';
    return sFlash;
}

function PlayVideo(sFilePath, iPollMediaId, iUserId, iPollId, ServerUrl,setWidth,setHeight) {
    var sFlash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + setWidth + '" height="' + setHeight + '" id="jmFLVPLayer" align="middle"> \n';
    sFlash += '<param name="allowScriptAccess" value="always" /> \n';
    sFlash += '<param name="allowFullScreen" value="true" />';
    sFlash += '<param name="wmode" value="opaque" />';
    sFlash += '<param name="movie" value="' + ServerUrl;
    sFlash += '/Themes/flash/jmFLVPLayer_small.swf" /> \n';
    sFlash += '<param name="quality" value="high" /> \n';
    sFlash += '<param name="FlashVars" value="c1=0xF2F2F2&c2=0xBBBBBB&ServerUrl=' + ServerUrl +'&FileName=' + sFilePath + '&PollMediaId=' + iPollMediaId + '&UserId=' + iUserId + '&PollId=' + iPollId ;
    sFlash += '" /> \n'
    sFlash += '<param name="bgcolor" value="#000000" /> \n';
    sFlash += '<embed src="' + ServerUrl + '/Themes/flash/jmFLVPLayer_small.swf" allowFullScreen="true" FlashVars="c1=0xF2F2F2&c2=0xBBBBBB&FileName=' + sFilePath + '&PollMediaId=' + iPollMediaId + '&UserId=' + iUserId + '&PollId=' + iPollId ;
    sFlash += '" quality="high" bgcolor="#000000" width="' + setWidth + '" height="' + setHeight + '" id="jmFLVPLayer" name="jmFLVPLayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer" /> \n';
    sFlash += '</object> \n';
    return sFlash;
}


function PlayIntroVideo(sFilePath, iPollMediaId, iUserId, iPollId, ServerUrl,setWidth,setHeight) {
    var sFlash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + setWidth + '" height="' + setHeight + '" id="jmFLVPLayer" align="middle"> \n';
    sFlash += '<param name="allowScriptAccess" value="always" /> \n';
    sFlash += '<param name="allowFullScreen" value="true" />';
    sFlash += '<param name="wmode" value="opaque" />';
    sFlash += '<param name="movie" value="' + ServerUrl;
    sFlash += '/Themes/flash/jmFLVPLayerl_Intro.swf" /> \n';
    sFlash += '<param name="quality" value="high" /> \n';
    sFlash += '<param name="FlashVars" value="c1=0xF2F2F2&c2=0xBBBBBB&ServerUrl=' + ServerUrl +'&FileName=' + sFilePath + '&PollMediaId=' + iPollMediaId + '&UserId=' + iUserId + '&PollId=' + iPollId ;
    sFlash += '" /> \n'
    sFlash += '<param name="bgcolor" value="#000000" /> \n';
    sFlash += '<embed src="' + ServerUrl + '/Themes/flash/jmFLVPLayerl_Intro.swf" allowFullScreen="true" FlashVars="c1=0xF2F2F2&c2=0xBBBBBB&FileName=' + sFilePath + '&PollMediaId=' + iPollMediaId + '&UserId=' + iUserId + '&PollId=' + iPollId ;
    sFlash += '" quality="high" bgcolor="#000000" width="' + setWidth + '" height="' + setHeight + '" id="jmFLVPLayer" name="jmFLVPLayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer" /> \n';
    sFlash += '</object> \n';
    return sFlash;
}


function getEmbedTag(sThumbnailPath, sVideoPath, sServerUrl, sPlayer){
    var sFlash = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='640' height='385' id='jmFLVPLayer' align='middle'>";
    sFlash += "<param name='allowScriptAccess' value='always' />";
    sFlash += "<param name='allowFullScreen' value='true' />";
    sFlash += "<param name='movie' value='" + sServerUrl + "/Themes/flash/"+sPlayer+"' />";
    sFlash += "<param name='quality' value='high' />";
    sFlash += "<param name='wmode' value='opaque' />";
    sFlash += "<param name='FlashVars' value='c1=0xF2F2F2&c2=0xBBBBBB&su=" + sServerUrl + "&FileName=" + sVideoPath + "&ImagePath=" + sThumbnailPath + "' />";
    sFlash += "<param name='bgcolor' value='#000000' /> \n";
    sFlash += "<embed src='" + sServerUrl + "/Themes/flash/"+sPlayer+"' allowFullScreen='true' FlashVars='c1=0xF2F2F2&c2=0xBBBBBB&su=" + sServerUrl + "&FileName=" + sVideoPath + "&ImagePath=" + sThumbnailPath + "' quality='high' bgcolor='#0000000' wmode='opaque' width='640' height='385' id='jmFLVPLayer' name='jmFLVPLayer' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
    sFlash += "</object>";
    b = document.getElementById("txtEmbed");
    b.value = sFlash;
    a = document.getElementById("divShare");
    a.style.display = "block";
}

function getLocalFlashMovie(movieName) {
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? window[movieName] : document[movieName];
}
function closeLocalVideo(div,flashId) {

    try {
        document.getElementById(div).style.display = 'none';
        var text = "0";
        getLocalFlashMovie('jmFLVPLayer').sendMessageToFlash(text);
    }
    catch (ex) {
        try { document.getElementById(flashId).sendMessageToFlash(text); }
        catch (exx)
        { }        
    }
}

function CheckValidUploadImageType(ext){
      var validExtensions = new Array();
      validExtensions[0] = 'jpg';
      validExtensions[1] = 'png';
      validExtensions[2] = 'jpeg';
      validExtensions[3] = 'gif';
      validExtensions[4] = 'bmp';
      
      var isvalid = false;
      for (var iCount = 0; iCount < validExtensions.length; iCount++) {
          if (ext.toUpperCase() == validExtensions[iCount].toUpperCase()) {
              isvalid = true
              break;
          }
      }
      return isvalid;
}

function CheckValidUploadVideoType(ext){
      var validExtensions = new Array();
      validExtensions[0] = 'flv';
      validExtensions[1] = 'wmv';
      validExtensions[2] = 'mp4';
      validExtensions[3] = 'avi';
      validExtensions[4] = '3gp';
      validExtensions[5] = 'mpeg';
      validExtensions[6] = 'mpg';
      validExtensions[7] = 'avi';
      validExtensions[8] = 'mov';
      
      var isvalid = false;
      for (var iCount = 0; iCount < validExtensions.length; iCount++) {
          if (ext.toUpperCase() == validExtensions[iCount].toUpperCase()) {
              isvalid = true
              break;
          }
      }
      return isvalid;
}


// for give the x  position for  iframe
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent)
        while (1) {
        curleft += obj.offsetLeft;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}
// for give the y  position for  iframe

function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent)
        while (1) {
        curtop += obj.offsetTop;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

/////asyncronous ajax call 
    function makeAjaxRequest(url, onLoadCompleteFunName) {
        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;
        }
        //
        switch (onLoadCompleteFunName) {
            case 'RAV':
                http_request.onreadystatechange = CompleteReportAbuseVideos;
                break;
        }
        http_request.open('GET', url, true);
        http_request.send(null);
    }
    
    //Friend list and Chat Request complete 
    function CompleteReportAbuseVideos() {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                if(http_request.responseText != 1)
                {
                    window.navigate(http_request.responseText);
                }
            }
        }
    }
     function replaceCharacters(origString, inChar, outChar) {
            var newString = origString.split(inChar);
            newString = newString.join(outChar);
            return newString;
        }
//////////////////////////////////////////
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->



 function OpenContactUs() {
            //var pathPrefix = '<%=ServerUrl%>';
            var scrWidth = window.screen.width;
            //window.open(pathPrefix + "/Popup/ContactUs.aspx", "contactUs", "menubar=0,resizable=0,status=0,toolbar=0,height=645,scrollbars=1, width=1019px,left=" + (scrWidth - 1019) / 2 + ",top=50");
            window.parent.tb_show("", pathPrefix + "/Popup/ContactUs.aspx?TB_iframe=true&height=345&width=950");            
        }

   
        function OpenAboutUs() {
          
            var scrWidth = window.screen.width;
            //window.open(pathPrefix + "/Popup/AboutUs.aspx", "contactUs", "menubar=0,resizable=0,status=0,toolbar=0,height=420,scrollbars=1, width=1019px,left=" + (scrWidth - 1019) / 2 + ",top=50");
            window.parent.tb_show("", pathPrefix + "/Popup/AboutUs.aspx?TB_iframe=true&height=374&width=950");            
        }
         function OpenAbout() {
          
            var scrWidth = window.screen.width;
            //window.open(pathPrefix + "/Popup/AboutUs.aspx", "contactUs", "menubar=0,resizable=0,status=0,toolbar=0,height=420,scrollbars=1, width=1019px,left=" + (scrWidth - 1019) / 2 + ",top=50");
            window.parent.tb_show("", pathPrefix + "/Popup/About.aspx?TB_iframe=true&height=345&width=980");            
        }

        function OpenPrivacyPolicy() {

            var scrWidth = window.screen.width;
            var newWin = "PPolicy";
            //window.open(pathPrefix + "/Popup/PrivacyPolicy.aspx", newWin + 1, "menubar=0,resizable=0,status=0,toolbar=0,height=645,scrollbars=1, width=1019px,left=" + (scrWidth - 1019) / 2 + ",top=50");
            window.parent.tb_show("", pathPrefix + "/Popup/PrivacyPolicy.aspx?TB_iframe=true&height=345&width=950");            
        }

        function OpenTermCondition() {
            var scrWidth = window.screen.width;
            //window.open(pathPrefix + "/Popup/TermsOfService.aspx", "TermService", "menubar=0,resizable=0,status=0,toolbar=0,height=645,scrollbars=1, width=1019px,left=" + (scrWidth - 1019) / 2 + ",top=50");
            window.parent.tb_show("", pathPrefix + "/Popup/TermsOfService.aspx?TB_iframe=true&height=345&width=950");            
        }
        
        function OpenSiteMap() {
            var scrWidth = window.screen.width;
            window.open(pathPrefix + "/sitemap.aspx", "sitemap", "menubar=0,resizable=0,status=0,toolbar=0,height=645,scrollbars=1, width=1019px,left=" + (scrWidth - 1019) / 2 + ",top=50");
            //window.parent.tb_show("", pathPrefix + "/sitemap.aspx?TB_iframe=true&height=345&width=950");            
        }
        


