var ccModal_hgt;
var ccModal_wdt;
var ccModal_rev;
var ccModal_flag = 0;
var ccModal_finLoc;
function initCCModal(inP, src,nat) {
 
 var params = inP.split(";");
 
 var work, outStr;
 
 ccModal_rev = "<iframe id='ccModalFrame' frameborder='0' src='" + src + "' marginheight='0' marginwidth='0'";
 
 for(var i=0; i< params.length; i++) {
  
  work = params[i].split(":");
  
  // get height and width
  if( work[0] == "height" ) {
   ccModal_hgt = work[1].replace("px", "");
   ccModal_hgt = ccModal_hgt.replace("em", "");
   ccModal_hgt = ccModal_hgt.replace("pt", "");
   ccModal_hgt = ccModal_hgt.replace(" ", "");
  }
  
  if( work[0] == "width" ) {
   ccModal_wdt = work[1].replace("px", "");
   ccModal_wdt = ccModal_wdt.replace("em", "");
   ccModal_wdt = ccModal_wdt.replace("pt", "");
   ccModal_wdt = ccModal_wdt.replace(" ", "");
  }
  
  // set up iframe
  ccModal_rev += " " + work[0] + "='" + work[1] + "'";
  
 }
 
 ccModal_rev += "></iframe>";
 ccModal_rev = "<div id=\"ccModalFrame\" style=\"width:456px; background-color:#ffffff; color:#000000; font-family:arial;\"><div id=\"container\" style=\"margin-top:20px;\"><div id=\"Message1\"><div style=\"font-size:15px; font-weight:bold; margin-left:20px;\">"
 
 if(nat=='USR')
     ccModal_rev += "This link is intended for US residents only. By selecting 'yes,' you are confirming that you are a US resident.";
  else
  if(nat=='EU')
  ccModal_rev += "This link is intended for EU residents only. By selecting 'yes,' you are confirming that you are a EU resident.";
 else
 ccModal_rev += "This link is intended for Canada residents only. By selecting 'yes,' you are confirming that you are a Canada resident."; 

 ccModal_rev += "<span style=\"font-weight:bolder; font-size:16px;\"></span></div><div style=\"font-size:15px; font-weight:bold; margin-left:20px;\">Would you like to proceed?</div></div><div id=\"Message2\" style=\"display:none; padding-top:25px;\"><div style=\"font-size:15px; font-weight:bold; margin-left:20px;\">YOU ARE NOW LEAVING WWW.RANKLIGAND.COM</div><div style=\"font-size:12px; margin-left:20px; margin-right:20px; font-family:Arial;\"></div><div style=\"font-size:10px; margin-left:20px; padding: 10px 0px 0px 0px;\">&copy; 2010 Amgen, Inc. All rights reserved.</div></div><div id=\"radio\" style=\"margin-left:20px; margin-top:15px;width:270px; font-size:14px\"><div style=\"margin-left=15px;\"><input id=\"radNo\" name=\"group1\" type=\"radio\" value=\"no\" checked /><b>No</b>, Return to www.rankligand.com<br /><input id=\"radYes\" name=\"group1\" type=\"radio\" value=\"yes\" /><b>Yes</b>, Leave www.rankligand.com <div id=\"submit\" align=\"center\" style=\"margin-top:15px\"><button onClick=\"Submit()\">Submit</button></div></div><div style=\"font-size:14px; margin-top:15px;\">You will be redirected shortly.</div></div></div></div>";
 ccModal_finLoc = src;
    
 $("#ccModal").prepend(ccModal_rev);
 
}
function setCCModal() {
    var canvasX = $(window).width();
    var canvasY = $(window).height();
 
 
    var boxX = ((canvasX / 2) - (ccModal_wdt / 2)) + $(window).scrollLeft();
    var boxY = ((canvasY / 2) - (ccModal_hgt / 2)) + $(window).scrollTop();
 
 if ( ccModal_wdt > canvasX ) boxX = 0;
 if ( $("#ccModal").height() > canvasY ) boxY = 0;
    $("#ccModal").css({
       
        'height': 'auto',
        'width': ccModal_wdt + 'px',
        'position': 'absolute',
        'background-color': '#ffffff',
        'border': '1px solid #aaaaaa',
        'top': boxY + 'px',
        'left': boxX + 'px',
  'z-index': '10000'
  
    });
}
function Submit() {
    if (document.getElementById("radNo").checked == true) {
        closeCCModal();
    }
    else if (document.getElementById("radYes").checked == true) {
        document.getElementById('Message1').style.display = 'none';
        document.getElementById('radio').style.display = 'none';
        document.getElementById('Message2').style.display = 'block';
        setTimeout("RedirectPage()", 3000)
    }
}
function RedirectPage() {
    closeCCModal();
    window.location = ccModal_finLoc;
}
function openCCModal(inP, src) {
 
 initCCModal(inP, src);
 setCCModal();
 ccModal_flag = 1;
 
 $("#ccModal").fadeIn("slow"); 
 
}
function removeCCModalFrame() {
 $("#ccModalFrame").remove();
}
function closeCCModal(inP) {
 
 $("#ccModalFrame").fadeOut("slow",removeCCModalFrame);
 if( inP == "" ) {
  $("#ccModal").fadeOut("slow");
 }
 else
 {
  $("#ccModal").fadeOut("slow", eval(inP));
 }
 ccModal_flag = 0;
 
}
function getAtts( perm )
{
    return perm;
}
$(document).ready(function() {
    $("#ccModal").hide();
    $(window).resize(function() {
         
        if(ccModal_flag == 1) {
   setCCModal();
  }
  
    });
    $(window).scroll(function() {
        if(ccModal_flag == 1) {
   setCCModal();
  }
    });
    
    $("a[rel=ccModal]").click(function() {
        initCCModal( $(this).attr("rev"), $(this).attr("href"),$(this).attr("nat") );
  //alert("href: " + $(this).attr("href") + "\nrev: " + $(this).attr("rev"));
  
  
  
  setCCModal();
  ccModal_flag = 1;
  
  $("#ccModal").fadeIn("slow");
  
        return false;
    });
    $("a[rel=ccModalClose]").click(function() {
  ccModal_flag = 0; 
  
  closeCCModal($(this).attr("rev"))
  
        return false;
    }); 
});
