﻿
var mid;
var cid;
var token;
var publishUrl;
var authenticated;

function GetApp(_mid,_cid,_token,_publishUrl,_authenticated) {

 //alert(_authenticated);
 if (_authenticated=="True") {
 
  mid=_mid;
  cid=_cid;
  token=_token;
  publishUrl=_publishUrl;
  authenticated=_authenticated;
 
      if (CheckDotNetVer())
      {
       if (_token!=null && _cid!=null && _publishUrl!=null)
        {
         
            var _link=_publishUrl+'?MerchantID='+_mid+'&CouponID='+_cid+'&Token='+_token;
            
            document.getElementById('hiddenFrame').src=_link;
           
        }
      }
  }
  else
  {
    alert(loginStr);
  }
  return false;
}



function isExplorer()
{
 var browser=navigator.appName

 if (browser=="Microsoft Internet Explorer")
  return true;
 else 
  return false;
}
 

var requiredVersion = "3.5";

function CheckDotNetVer() {


 if (isExplorer())
 {
 
  var userAgentString = navigator.userAgent.match(/\.NET CLR[ .][0-9.]+/g);
      if (userAgentString != null)
      {
        var i;
        for (i = 0; i < userAgentString.length; ++i)
        {
          var ver = userAgentString[i].slice(9);
          if ( CheckVersion(requiredVersion, ver))
            return true;
          
        }
      }

      var win = window.open("FrameworkUpdate/FrameworkUpdate35.htm", "FrameworkUpdate", "resizable=1,scrollbars=1,width=700,height=800");
      
      if (!win) 
      {
         alert("A popup blocker was detected. Please disable the popup blocker and try again.");
      } 
     
      return false;
      
 }
 else 
 {
     // For any other browser
     return true;
 }
    
}



function CheckVersion(requiredVersion, ver)
    {
      requiredVersion = requiredVersion.split(".");
      ver = ver.split(".");
      
      // Major versions must match exactly.
      if (requiredVersion[0] != ver[0])
        return false;
      
      // Minor/build numbers must be at least the required version.
      var i;
      for (i = 1; i < requiredVersion.length && i < ver.length; i++)
      {
        if (new Number(ver[i]) < new Number(requiredVersion[i]))
          return false;
      }
      return true;
    }


function OpenClientApp(_cid,_clientUrl,_local,_status,_clientUrl2)
{
  if (_status=='1')
  {    
    if (_clientUrl!=null && _cid!=null && _local!=null)
    {
        var _link=_clientUrl+''+_cid;
        if(_local==0){
            var winObjClient = window.open(_link, _cid, 'width=1024,height=768,scrollbars=yes');
            winObjClient.focus();
        }else{
            parent.CloseListPanel(_link);
        }
     }
  }
  else //if (_status=='6')
  {
    var _link2=_clientUrl2+''+_cid;
    var winObjClient2=window.open(_link2,_cid);
    winObjClient2.focus();
  }
  //else return false;
  
}

function OppenLinkWithFocus(_cid,_Url)
{
 if (_Url!=null && _cid!=null)
 {
  var winObjClient=window.open(_Url,_cid);
  winObjClient.focus();
 }
 return false;
}

function getStyle(oElm, strCssRule)
{
    var strValue = "";
    if(document.defaultView && document.defaultView.getComputedStyle){
        strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
    }
    else if(oElm.currentStyle){
        strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
            return p1.toUpperCase();
        });
        strValue = oElm.currentStyle[strCssRule];
    }
    return strValue;
}
