/**
 * Disclaimer - Popup Page Disclaimer
 *
 * @version   1.0
 *
 *
 * @author    Chris Taylor (chris.taylor@morningstar.com)
 */
 var $jq = jQuery.noConflict();


 String.prototype.startsWith = function(str)
 {return (this.match("^"+str)==str)}

 function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
 
var countrycodelist={
"Afghanistan":93 ,"Albania":355 ,"Algeria":213 ,"Andorra":376 ,"Angola":244 ,"Antigua & Deps":1268,"Argentina":54 ,"Armenia":374 ,"Australia":61 ,"Austria":43 ,"Azerbaijan":994 ,"Bahamas":1242 ,"Bahrain":973 ,"Bangladesh":880 ,"Barbados":1246 ,"Belarus":375 ,"Belgium":32 ,"Belize":501 ,"Benin":229 ,"Bhutan":975 ,"Bolivia":591 ,"Bosnia Herzegovina":387,"Botswana":267 ,"Brazil":55 ,"Brunei":673 ,"Bulgaria":359 ,"Burkina":226,"Burundi":257 ,"Cambodia":855 ,"Cameroon":237 ,"Canada":1 ,"Cape Verde":238,"Central African Rep":236,"Chad":235 ,"Chile":56 ,"China":86 ,"Colombia":57 ,"Comoros":269 ,"Congo":242,"Congo (Democratic Rep)":243,"Costa Rica":506 ,"Croatia":385 ,"Cuba":53 ,"Cyprus":357 ,"Czech Republic":420 ,"Denmark":45 ,"Djibouti":253 ,"Dominica":1767 ,"Dominican Republic":1809 ,"East Timor":670,"Ecuador":593 ,"Egypt":20 ,"El Salvador":503 ,"Equatorial Guinea":240 ,"Eritrea":291 ,"Estonia":372 ,"Ethiopia":251 ,"Fiji":679 ,"Finland":358 ,"France":33 ,"Gabon":241 ,"Gambia":220 ,"Georgia":995 ,"Germany":49 ,"Ghana":233 ,"Greece":30 ,"Grenada":1473 ,"Guatemala":502 ,"Guinea":224 ,"Guinea-Bissau":245 ,"Guyana":592 ,"Haiti":509 ,"Honduras":504 ,"Hungary":36 ,"Iceland":354 ,"India":91 ,"Indonesia":62 ,"Iran":98 ,"Iraq":964 ,"Ireland (Republic)":353,"Israel":972 ,"Italy":39 ,"Ivory Coast":225 ,"Jamaica":1876 ,"Japan":81 ,"Jordan":962 ,"Kazakhstan":7 ,"Kenya":254 ,"Kiribati":686 ,"Korea North":850,"Korea South":82,"Kuwait":965 ,"Kyrgyzstan":996 ,"Laos":856 ,"Latvia":371 ,"Lebanon":961 ,"Lesotho":266 ,"Liberia":231 ,"Libya":218 ,"Liechtenstein":423 ,"Lithuania":370 ,"Luxembourg":352 ,"Macedonia":389 ,"Madagascar":261 ,"Malawi":265 ,"Malaysia":60 ,"Maldives":960 ,"Mali":223 ,"Malta":356 ,"Marshall Islands":692 ,"Mauritania":222 ,"Mauritius":230 ,"Mexico":52 ,"Micronesia":691 ,"Moldova":373 ,"Monaco":377 ,"Mongolia":976 ,"Montenegro":382 ,"Morocco":212 ,"Mozambique":258 ,"Myanmar (Burma)":95,"Namibia":264 ,"Nauru":674 ,"Nepal":977 ,"Netherlands":31 ,"New Zealand":64 ,"Nicaragua":505 ,"Niger":227 ,"Nigeria":234 ,"Norway":47 ,"Oman":968 ,"Pakistan":92 ,"Palau":680 ,"Panama":507 ,"Papua New Guinea":675 ,"Paraguay":595 ,"Peru":51 ,"Philippines":63 ,"Poland":48 ,"Portugal":351 ,"Qatar":974 ,"Romania":40 ,"Russian Federation":7,"Rwanda":250 ,"St Kitts & Nevis":1869,"St Lucia":1758 ,"St Vincent & Gr/dines":1784,"Samoa":685 ,"San Marino":378 ,"Sao Tome & Principe":239,"Saudi Arabia":966 ,"Senegal":221 ,"Serbia":381 ,"Seychelles":248 ,"Sierra Leone":232 ,"Singapore":65 ,"Slovakia":421 ,"Slovenia":386 ,"Solomon Islands":677 ,"Somalia":252 ,"South Africa":27 ,"Spain":34 ,"Sri Lanka":94 ,"Sudan":249 ,"Suriname":597 ,"Swaziland":268 ,"Sweden":46 ,"Switzerland":41 ,"Syria":963 ,"Taiwan":886 ,"Tajikistan":992 ,"Tanzania":255 ,"Thailand":66 ,"Togo":228 ,"Tonga":676 ,"Trinidad & Tobago":1868,"Tunisia":216 ,"Turkey":90 ,"Turkmenistan":993 ,"Tuvalu":688 ,"Uganda":256 ,"Ukraine":380 ,"United Arab Emirates":971 ,"United Kingdom":44 ,"United States":1 ,"Uruguay":598 ,"Uzbekistan":998 ,"Vanuatu":678 ,"Vatican City":39,"Venezuela":58 ,"Vietnam":84 ,"Yemen":967 ,"Zambia":260 ,"Zimbabwe":263
}

function checkMaCountry() {
var Country=document.getElementById("disclaimerCountry").value;
var countrycode=document.getElementById('countrybuttonbox').value;
if(countrycodelist[Country]==countrycode){blockBoxes();}
else if(countrycodelist[Country]==undefined) { alert("Country Code not defined."); return false; 
}
else{alert("Country telephone code is incorrect."); return false; }

}

function blockBoxes() { 
document.getElementById('countrybutton2').style.display='block';
document.discform1.countrybutton2.disabled=false;
document.discform1.countrybuttonbox.disabled=true;
document.discform1.countrybutton.disabled=true;
document.discform1.disclaimerCountry.disabled=true;
document.discform1.countrybutton2.focus();
}



 function relContains(relString,relContains){ 
  var relArray;  
  var relLength;
  if (relString != undefined){
  relArray = relString.split(" ");
  relLength = relArray.length;
  }
  
  for (var i=0; i<relLength; i++){
   
   if (relArray[i].startsWith(relContains)){
    return relArray[i];
   }
  
  
  }
  return "";
}

 $jq.hsDisclaimer = function(options) {
  
  /* set the default options for hsDisclaimer */
  
  var defaults = {
      DisclaimerMessage:'Please set DisclaimerMessage', /* Message shown in disclaimer */
      DisclaimerMessage2:'Please set DisclaimerMessage', /* Message shown in second disclaimer (for two-step) */
      DisclaimerDiv:'', /* Div to use for disclaimer message */
      DisclaimerDiv1:'',/* Div to use for  united states disclaimer message */
	  DisclaimerDiv2:'', /* Div to use for second disclaimer message (for two-step) */
      DisclaimerTextClass:'', /* Additional Class to use for disclaimer text */
      DisagreeMessage:'Please set DisagreeMessage', /* Message shown if UsesDisagreeMessage = true and user declines */
      UsesDisagreeMessage: false, /* Show a message if the user declines, otherwise do default action (link->don't like, page->back 1 page)
      CookieName: 'hsDisclaim', /* Name appended onto "hsDsisclaimer" to use for Cookie */
      DisableCookies: false, /* Turns off cookies, users have to answer each time */
      AcceptButtonText: 'I accept', /* Button used for "accept", or the country submit in a countrydisclaimer */
      AcceptButtonText2: 'I accept', /* Button used for "accept", on step 2 of 2-step */
      DeclineButtonText: 'I decline', /* Button used for "decline", or the country submit in a countrydisclaimer */
      DeclineButtonText2: 'I decline', /* Button used for "decline", on step 2 of 2-step */
      UseOverlay : true, /* Block out the background content of the page with an overlay */
      UseOverlayFades : true, /* Should the overlay fade in/out? can cause a brief period when content underneath is visible */      
      EmbargoedCountries: [], /* if we're using rel="hscountrydisclaimer", which are the disallowed countries */
      CountryList: ["Afghanistan","Albania","Algeria","Andorra","Angola","Antigua &amp; Deps","Argentina","Armenia","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bhutan","Bolivia","Bosnia Herzegovina","Botswana","Brazil","Brunei","Bulgaria","Burkina","Burundi","Cambodia","Cameroon","Canada","Cape Verdi","Central African Rep","Chad","Chile","China","Colombia","Comoros","Congo","Congo (Democratic Rep)","Costa Rica","Croatia","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","East Timor","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Fiji","Finland","France","Gabon","Gambia","Georgia","Germany","Ghana","Greece","Grenada","Guatemala","Guinea","Guinea-Bissau","Guyana","Haiti","Honduras","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland (Republic)","Israel","Italy","Ivory Coast","Jamaica","Japan","Jordan","Kazakhstan","Kenya","Kiribati","Korea North","Korea South","Kuwait","Kyrgyzstan","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Mauritania","Mauritius","Mexico","Micronesia","Moldova","Monaco","Mongolia","Montenegro","Morocco","Mozambique","Myanmar (Burma)","Namibia","Nauru","Nepal","Netherlands","New Zealand","Nicaragua","Niger","Nigeria","Norway","Oman","Pakistan","Palau","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Qatar","Romania","Russian Federation","Rwanda","St Kitts &amp; Nevis","St Lucia","St Vincent &amp; Gr/dines","Samoa","San Marino","Sao Tome &amp; Principe","Saudi Arabia","Senegal","Serbia","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","Spain","Sri Lanka","Sudan","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Togo","Tonga","Trinidad &amp; Tobago","Tunisia","Turkey","Turkmenistan","Tuvalu","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States","Uruguay","Uzbekistan","Vanuatu","Vatican City","Venezuela","Vietnam","Yemen","Zambia","Zimbabwe"], /* list of all countries to show in the dropdown */
      AlignHorizontal: true,
      AlignVertical: true,
      AlwaysScroll: false,
      OpenInNewWindow: false
   };

  var options = $jq.extend({}, defaults, options); 
  var DiscCookieName = 'hsDisclaimerPage'+options.CookieName;
  
  /* sets a cookie */  
  setCookie = function(val){
   if (!options.DisableCookies){
    $jq.cookie(DiscCookieName,val);
   }
  }
  
  if (options.DisableCookies){
   /* Make sure no cookies are set already */
   setCookie(null);
  }
  
  /* Apply the disclaimers to links on the page, depending on their "rel" attribute */
  $jq(document).ready(function () {
  
   var disclaimerContent,disclaimerContent2;
   /* Set the content for the disclaimer - if a div is set, use the div's content, otherwise use the DisclaimerMessage */
   
   if (options.DisclaimerDiv != '') 
    { disclaimerContent = escape($jq('#'+options.DisclaimerDiv).html());}
    else 
    { disclaimerContent = escape(options.DisclaimerMessage); }
    
	if (options.DisclaimerDiv1 != '') 
    { disclaimerContent1 = escape($jq('#'+options.DisclaimerDiv1).html());}
    else 
    { disclaimerContent1 = escape(options.DisclaimerMessage1); }
	
   if (options.DisclaimerDiv2 != '') 
    { disclaimerContent2 = escape($jq('#'+options.DisclaimerDiv2).html());}
    else 
    { disclaimerContent2 = escape(options.DisclaimerMessage2); }

    
   $jq("a[rel^='hsdisclaimer']").bind("click",function(e){ 
    if ($jq.cookie(DiscCookieName) != 'allow'){  
     var relTag = $jq(this).attr('rel');
     if (relTag.indexOf("::") > -1){        
        popupSimpleDisclaimer(this,options.UseOverlay,disclaimerContent,relTag.substring(relTag.indexOf("::")+2,relTag.indexOf(" ")),true);
     } else {
        popupSimpleDisclaimer(this,options.UseOverlay,disclaimerContent,'',true);
     }
    return false;
    }
    });
    $jq("a[rel^='hscountrydisclaimer']").bind("click",function(e){
    
	
	var relTag = $jq(this).attr('rel');
    if (relTag.indexOf("::") > -1){        
      popupCountryDisclaimer(this,options.UseOverlay,disclaimerContent,relTag.substring(relTag.indexOf("::")+2,relTag.indexOf(" ")));      
     } else {
      popupCountryDisclaimer(this,options.UseOverlay,disclaimerContent,'');
     }   
   

   return false;
   
   
   
   });

   $jq("a[rel^='hstwostepcountrydisclaimer']").bind("click",function(e){
options.disclaimerTextClass="";
options.AcceptButtonText="Continue";
   if(readCookie("allowme")!="true")
{

   var relTag = $jq(this).attr('rel');

	if (relTag.indexOf("::") > -1){        
      popupTwoStepDualCountryDisclaimer(this,options.UseOverlay,disclaimerContent,disclaimerContent2,relTag.substring(relTag.indexOf("::")+2,relTag.indexOf(" ")),disclaimerContent1);
         $jq(window).scroll(function(){
            centerThis('.hsdisclaimer');
     });       
     } else {
      popupTwoStepDualCountryDisclaimer(this,options.UseOverlay,disclaimerContent,disclaimerContent2,'',disclaimerContent1);
         $jq(window).scroll(function(){
            centerThis('.hsdisclaimer');
     });       
     }   
}
else
{
 $jq(this).attr("target", "_blank");
return true;
}
	
	
	if(readCookie("blockme")=="true"){

doDisagreeAction("back");
} 
    return false;
   });   

   if (relContains($jq('body').attr('rel'),'hsdisclaimer')) {
   if ($jq.cookie(DiscCookieName) != 'allow'){
    popupSimpleDisclaimer(null,options.UseOverlay,disclaimerContent,true);
         $jq(window).scroll(function(){
            centerThis('.hsdisclaimer');
     });  
   }
   }
   if (relContains($jq('body').attr('rel'),'hscountrydisclaimer')) {
   if ($jq.cookie(DiscCookieName) != 'allow'){
     popupCountryDisclaimer(null,options.UseOverlay,disclaimerContent,'');
          $jq(window).scroll(function(){
             centerThis('.hsdisclaimer');
     });  
   }
   }
   if (relContains($jq('body').attr('rel'),'hstwostepcountrydisclaimer')) {
   if ($jq.cookie(DiscCookieName) != 'allow'){
     popupTwoStepDualCountryDisclaimer(null,options.UseOverlay,disclaimerContent,disclaimerContent2,'');
          $jq(window).scroll(function(){
             centerThis('.hsdisclaimer');
   
   });  
   }
   
   } 
   
       
  });
  
  
  
  
  
  
  /*Confirm Disclaimer */
  popupSimpleDisclaimerus = function(div,tag,overlay,message,message2,linkurl,showbottomlinks) {
   var interactions="";
   if (linkurl != '') {   
     var acceptLink = linkurl;
     } else {
     var acceptLink = $jq(tag).attr("href");
     }
   doShowOverlay(null);

   htmlStr = "<div class='hsdisclaimer'><div class='hsdisclaimertext "+ options.disclaimerTextClass +"'><form>"+unescape(message)+"<p>"+interactions+"</p>";
   htmlStr =htmlStr+"<input type=\"button\"  value=\"I Confirm\" onclick=\"checkConfirmationus(this.form,'"+div+"','"+tag+"','"+overlay+"','"+message2+"','"+linkurl+"',"+showbottomlinks+")\"/></form></div></div>";
  $jq(".hsdisclaimer").remove();
  
   $jq("body").append(htmlStr);   
   centerThis('.hsdisclaimer');
   $jq('.hsdisclaimer').fadeIn("slow", function(){centerThis('.hsdisclaimer');} )
   return false;
  };
  
  
  
  
  
  
  /* Standard Yes/No Disclaimer */
  popupSimpleDisclaimer = function(tag,overlay,message,linkurl,showbottomlinks) {
   var interactions="";
   if (linkurl != '') {   
     var acceptLink = linkurl;
     } else {
     var acceptLink = $jq(tag).attr("href");
     }
if(showbottomlinks)
{
	 if (tag!=null){     
   interactions ="<a href='"+acceptLink+"' rel='hsDisclaimerAccept'";
    if (options.OpenInNewWindow){
     interactions += 'target=\"_blank\"';
    }
    interactions += "onclick='createCookie(\"allowme\",\"true\",10);setCookie(\"allow\");";

	if (options.OpenInNewWindow == true){
  
         interactions += "clearDisclaimer();";
        }    
    
	interactions += "'>"+options.AcceptButtonText+"</a> | <a href='#' onclick='doDisagreeAction(\"clear\")' rel='hsDisclaimerDecline'>"+options.DeclineButtonText+"</a>";   
    } else {
    interactions ="<a href='#' onclick='setCookie(\"allow\");clearDisclaimer();successState();return false;' class='disclaimerButton accept'>"+options.AcceptButtonText+"</a> | <a href='#' onclick='doDisagreeAction(\"back\")' rel='hsDisclaimerDecline' class='disclaimerButton reject'>"+options.DeclineButtonText+"</a>";
   }
 }  
   doShowOverlay(null);

   htmlStr = "<div class='hsdisclaimer'><div class='hsdisclaimertext "+ options.disclaimerTextClass +"'>"+unescape(message)+"<p>"+interactions+"</p></div></div>";
  $jq(".hsdisclaimer").remove();
  
  
  $jq("body").append(htmlStr);   
   centerThis('.hsdisclaimer');
   $jq('.hsdisclaimer').fadeIn("slow", function(){centerThis('.hsdisclaimer');} )
   return false;
  };
  
  /* A "Select your country" Disclaimer */
  popupCountryDisclaimer = function(tag,overlay,message,linkurl) {
   if (linkurl != '') {   
     var acceptLink = linkurl;
     } else {
     var acceptLink = $jq(tag).attr("href");
     } 
     
   doShowOverlay(null);

   htmlStr = "<div class='hsdisclaimer'><div class='hsdisclaimertext "+ options.disclaimerTextClass +"'>"+unescape(message)+"</div><p>";
   htmlStr = htmlStr+ "<select id='disclaimerCountry'>";
   for (country in options.CountryList){
    htmlStr = htmlStr+ "<option value='"+options.CountryList[country]+"'>"+options.CountryList[country]+"</option>";
   }
   htmlStr = htmlStr+"<input type='button' id='countrybutton' value='"+options.AcceptButtonText+"' onclick='checkEmbargoedCountries(\""+tag+"\",\""+escape(acceptLink)+"\")'/>";
   htmlStr = htmlStr+"</select></p></div>";
   $jq("body").append(htmlStr);   
   centerThis('.hsdisclaimer');
   $jq('.hsdisclaimer').fadeIn("slow", function(){} )
   return false;
  }
  
  /* Function to check if selected country is allowed and do the required actions if it is */
  checkEmbargoedCountries = function(tag,linkurl){
   var selectedCountry = $jq('#disclaimerCountry').attr('value');
   var isAllowed = true;
   for (var i=0;i<options.EmbargoedCountries.length;++i){
    if (options.EmbargoedCountries[i] == selectedCountry){
      if (tag != "null") {
       doDisagreeAction("clear");
      }
      else {
       createCookie("blockme","true",10);
	   doDisagreeAction("back");
	   
      }
      isAllowed = false;
    }     
   }
   if (isAllowed == true){    
     if (tag == "null") {
          clearDisclaimer();
          setCookie("allow");
        }
        else {
        if(options.OpenInNewWindow == false){
          window.location = unescape(linkurl);
          }
          else {
          window.open(unescape(linkurl),'disclaimerTarget');
          clearDisclaimer();
          }
          setCookie("allow");
         }
    }
  }
    
 /* A Dual "Select your country"/"place of origin" Disclaimer */
  popupDualCountryDisclaimer = function(tag,overlay,message,linkurl) {
   if (linkurl != '') {   
     var acceptLink = linkurl;
     } else {
     var acceptLink = $jq(tag).attr("href");
     } 
     
   doShowOverlay(null);                                                                     

   htmlStr = "<div class='hsdisclaimer'><div class='hsdisclaimertext "+ options.disclaimerTextClass +"'>"+unescape(message)+"</div><p>";
   htmlStr = htmlStr+"<p>Due to restrictions under applicable securities laws, access to this website is not permitted in certain jurisdictions</p><p>Please select the country of your residence:</p>"
   htmlStr = htmlStr+ "<select id='disclaimerCountry'>";
   for (country in options.CountryList){
    htmlStr = htmlStr+ "<option value='"+options.CountryList[country]+"'>"+options.CountryList[country]+"</option>";
   }
   htmlStr = htmlStr+"</select>";
   htmlStr = htmlStr+"<p>Please confirm the country you are currently located in:</p>";
   htmlStr = htmlStr+ "<select id='disclaimerLocation'>";
   for (country in options.CountryList){
    htmlStr = htmlStr+ "<option value='"+options.CountryList[country]+"'>"+options.CountryList[country]+"</option>";
   }
   htmlStr = htmlStr+"</select>";   
   htmlStr = htmlStr+"<input type='button' id='countrybutton' value='"+options.AcceptButtonText+"' onclick='checkDualEmbargoedCountries(\""+tag+"\",\""+acceptLink+"\")'/>";
   htmlStr = htmlStr+"</p></div>";
   $jq("body").append(htmlStr);   
   centerThis('.hsdisclaimer');
   $jq('.hsdisclaimer').fadeIn("slow", function(){} )   
   return false;
  }  
  
  /* Function to check if dual selected countries are allowed and do the required actions if it is */
  checkDualEmbargoedCountries = function(tag,linkurl){
   var selectedCountry = $jq('#disclaimerCountry').attr('value');
   var selectedCountry2 = $jq('#disclaimerLocation').attr('value');
   var isAllowed = true;
   for (var i=0;i<options.EmbargoedCountries.length;++i){
    if (options.EmbargoedCountries[i] == selectedCountry || options.EmbargoedCountries[i] == selectedCountry2){
      if (tag != "null") {
       doDisagreeAction("clear");
      }
      else {
       doDisagreeAction("back");
      }
      isAllowed = false;
    }     
   }
   if (isAllowed == true){    
     if (tag == "null") {
          clearDisclaimer();
          setCookie("allow");
        }
        else {
          window.location = linkurl;
          setCookie("allow");
         }
    }
  }  
  

 /* Two Step (country->yes no) Disclaimer */
  popupTwoStepDualCountryDisclaimer = function(tag,overlay,message,message2,linkurl,message1) {
   
   if (linkurl != '') {   
     var acceptLink = linkurl;
     } else {
     var acceptLink = $jq(tag).attr("href");
     } 
     
   doShowOverlay(null);

   htmlStr = "<div class='hsdisclaimer'><div class='hsdisclaimertext "+ options.disclaimerTextClass +"'>"+unescape(message)+"</div><p>";
   htmlStr = htmlStr+"<p>Please confirm your country of residence:</p>"
    htmlStr = htmlStr+ "<form name='discform1' id='discform1' onsubmit='checkMaCountry();return false;'>";
   htmlStr = htmlStr+ "<select id='disclaimerCountry'>";
   for (country in options.CountryList){
    htmlStr = htmlStr+ "<option value='"+options.CountryList[country]+"'>"+options.CountryList[country]+"</option>";
   }
   htmlStr = htmlStr+"</select>";
   htmlStr = htmlStr+"<p style='padding:.5em 0'>Please enter the telephone country code of the selected country:</p>";
   /*
   htmlStr = htmlStr+ "<select id='disclaimerLocation'>";
   
   for (country in options.CountryList){
    htmlStr = htmlStr+ "<option value='"+options.CountryList[country]+"'>"+options.CountryList[country]+"</option>";
   }
   htmlStr = htmlStr+"</select><br/><br/>";   
   */
     htmlStr = htmlStr+ "<input type=\"text\" id='countrybuttonbox' />";
	 htmlStr = htmlStr+"<input type='button' onclick='checkMaCountry();' id='countrybutton' value='"+options.AcceptButtonText+"' />";
   htmlStr = htmlStr+"<br/><br/><input type='button' id='countrybutton2' value='Submit' onclick='checkDualTwoStepEmbargoedCountries(this.parentNode,\""+tag+"\",\""+overlay+"\",\""+message+"\",\""+message2+"\",\""+acceptLink+"\",\""+message1+"\")' disabled='disabled' style='display:none;'/>";
   htmlStr = htmlStr+"</p><br/><p>By clicking the \"Submit\" button you certify that you are an individual resident in the country stipulated by you above, and that you have read and understood this notice.</p><p>The information contained in this website does not constitute an offer to sell, or the solicitation of an offer to acquire or subscribe for, any securities of the Company in any jurisdiction in which, or to any person to whom, such offer or solicitation is unlawful.</p></div>";

   
    htmlStr = htmlStr+ "</form>";
   $jq("body").append(htmlStr);   
   centerThis('.hsdisclaimer');
   $jq('.hsdisclaimer').fadeIn("slow", function(){} )   
   return false;
  }  
 

  checkConfirmationus=function(form,div,tag,overlay,message,linkurl,showbottomlinks)
  { 
  
	
	
	

	if($jq(form).find(":checked").length==0)
  {
  alert("Please select atleast one checkbox");

  }
else if($jq(form).find('input[value="unable"]:checked').length==1)
		   {
			  createCookie("blockme","true",10);
			   doDisagreeAction("clear");
		   
		   }
   else
   {
   
    options.disclaimerTextClass = "hsdisclaimertext2";
          options.AcceptButtonText = options.AcceptButtonText2;
          options.DeclineButtonText = options.DeclineButtonText2;

     popupSimpleDisclaimer(tag,overlay,message,linkurl,true);     

     //clearDisclaimerBox(div);          

//		centerThis('.hsdisclaimer'); 
		 
   }
        



  }
  
  /* Function to check if dual selected countries are allowed and do the required actions if it is */
  checkDualTwoStepEmbargoedCountries = function(div,tag,overlay,message,message2,linkurl,message1){
   
   var selectedCountry = $jq('#disclaimerCountry').attr('value');
   var selectedCountry2 = $jq('#disclaimerLocation').attr('value');
   
   var isAllowed = true;
   
   for (var i=0;i<options.EmbargoedCountries.length;++i){
    if (options.EmbargoedCountries[i] == selectedCountry || options.EmbargoedCountries[i] == selectedCountry2){
      if (tag != "null") {
	  createCookie("blockme","true",10);
       doDisagreeAction("clear");
      }
      else {
	   createCookie("blockme","true",10);
       doDisagreeAction("back");
      }
      isAllowed = false;
    }     
   }

   if (isAllowed == true){    
     if (tag == "null") {
          options.disclaimerTextClass = "hsdisclaimertext2";
          options.AcceptButtonText = options.AcceptButtonText2;
          options.DeclineButtonText = options.DeclineButtonText2;
          popupSimpleDisclaimer(null,overlay,message2,linkurl,true);
       
          clearDisclaimerBox(div);          
          centerThis('.hsdisclaimer');          
        }
        else {
          
		 if(selectedCountry=="United States") 
		 {
		  options.disclaimerTextClass = "hsdisclaimertext2";
          options.AcceptButtonText = "";
          options.DeclineButtonText = "";
          
		  popupSimpleDisclaimerus(div,tag,overlay,message1,message2,linkurl,false);
          
          clearDisclaimerBox(div);          
          centerThis('.hsdisclaimer'); 
		 }
		 else
		 {
		  options.disclaimerTextClass = "hsdisclaimertext2";
          options.AcceptButtonText = options.AcceptButtonText2;
          options.DeclineButtonText = options.DeclineButtonText2;
          popupSimpleDisclaimer(tag,overlay,message2,linkurl,true);
          
          clearDisclaimerBox(div);          
          centerThis('.hsdisclaimer');          
         
		 }
		 
		 
		 }
    }
  }   
  /* Callback function */
  successState = function(){}
  
  /* Remove the disclaimer box/overlay from the page */
  clearDisclaimer = function(){  
  $jq('.hsdisclaimer').fadeOut("slow", function(){$jq('.hsdisclaimer').remove();} )
  if ($jq('.hsdisclaimeroverlay')){
      doHideOverlay();
   }  
  }

  clearDisclaimerBox = function(div){
   $jq(div).fadeOut("slow", function(){$jq(div).remove();} ) 
   centerThis('.hsdisclaimer');   
  }  


 /* This is what happens if the user declines... */
 doDisagreeAction = function(action){
   setCookie(null);
   if (action == 'clear'){
    if (options.UsesDisagreeMessage){
     $jq('.hsdisclaimer').html(options.DisagreeMessage)
    } else {
     clearDisclaimer();
    }
    return false;
   }
   if (action == 'back'){
    if (options.UsesDisagreeMessage){
     $jq('.hsdisclaimer').html(options.DisagreeMessage)
    }  
    else {    
     history.go(-1);
    }
    return false;
   }  
   
  }
  

  
  /* calculates the central area on the page */
  function centerThis(div) {
    var arrPageSizes = getPageSize();    
    var winH = $jq(window).height();
    var winW = $jq(window).width();
    $jq(div).each(function(){
     if(options.AlignVertical){
     $jq(this).css('top', winH/2-$jq(this).height()/2+$jq(window).scrollTop());
     }
     else {
     
     $jq(this).css('top', "20px");
     }
     if(options.AlignHorizontal){
     $jq(this).css('left', winW/2-$jq(this).width()/2)
     }
     
     }
    );    
  };
  
  /* shows the overlay (if enabled) */
  doShowOverlay = function(settings){
    $jq("body").addClass("disclaimer_body");  
    //$jq("body").css("overflow-x","hidden");  
  if(options.UseOverlay){
    $jq('embed, object, select').css({ 'visibility' : 'hidden' });

    $jq("body").append("<div class='hsdisclaimeroverlay'></div>");
    var arrPageSizes = getPageSize();    
    $jq('.hsdisclaimeroverlay').css({
      width:        arrPageSizes[0],
      height:       arrPageSizes[1]  + 200
      })
      if(options.useOverlayFades){
      $jq('.hsdisclaimeroverlay').fadeIn();  
      }
      else
      {
      $jq('.hsdisclaimeroverlay').show();  
      }
      $jq(window).resize(function(){
        var arrPageSizes = getPageSize();    
        $jq('.hsdisclaimeroverlay').css({
          width:        arrPageSizes[0],
          height:       arrPageSizes[1]
        });
        centerThis('.hsdisclaimer');
      });
     } else {
     $jq(window).resize(function(){
        centerThis('.hsdisclaimer');
     });   
     $jq(window).scroll(function(){        
        centerThis('.hsdisclaimer');
     });        
    }
    if(options.AlwaysScroll){
     $jq(window).scroll(function(){
        centerThis('.hsdisclaimer');
     });     
    }
    
  }
  
  /* hides the overlay (again, if enabled) */
  doHideOverlay = function(){
  
   if(options.UseOverlay){
   $jq('embed, object, select').css({ 'visibility' : 'visible' });
    if(options.useOverlayFades){
         $jq('.hsdisclaimeroverlay').fadeOut(function() { $jq('.hsdisclaimeroverlay').remove(); });
         }
         else
         {
         $jq('.hsdisclaimeroverlay').hide().remove();  
      }
      
    } 
  $jq("body").removeClass("disclaimer_body");    
  //$jq("body").css("overflow-x","auto");      
  }
  
  /* calculates the scrolling size of the page */
  getPageSize = function()  {
        var xScroll, yScroll;
        if (window.innerHeight && window.scrollMaxY) {  
          xScroll = window.innerWidth + window.scrollMaxX;
          yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
          xScroll = document.body.scrollWidth;
          yScroll = document.body.scrollHeight;
        } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
          xScroll = document.body.offsetWidth;
          yScroll = document.body.offsetHeight;
        }
        var windowWidth, windowHeight;
        if (self.innerHeight) { // all except Explorer
          if(document.documentElement.clientWidth){
            windowWidth = document.documentElement.clientWidth; 
          } else {
            windowWidth = self.innerWidth;
          }
          windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
          windowWidth = document.documentElement.clientWidth;
          windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
          windowWidth = document.body.clientWidth;
          windowHeight = document.body.clientHeight;
        } 
        // for small pages with total height less then height of the viewport
        if(yScroll < windowHeight){
          pageHeight = windowHeight;
        } else { 
          pageHeight = yScroll;
        }
        // for small pages with total width less then width of the viewport
        if(xScroll < windowWidth){  
          pageWidth = xScroll;    
        } else {
          pageWidth = windowWidth;
        }
        arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
        return arrayPageSize;
      };
};


