var host = "www.conferenceplus.com";
var host1 = "global.conferenceplus.com";
//For ConferencePlus One Sign Up
var ft1 = "https://" + host + "/signup/signup.aspx?id=UbyuGoKZqpGDfP&tc=HP";
var ft2 = "https://" + host + "/signup/signup.aspx?id=UbyuGoKZqpGDfP&t=t&tc=HP";
//For Per Minute ConferencePlus Sign Up
var ft3 = "https://" + host + "/signup/signup.aspx?id=UKueRJNoGkNrdn&tc=HP";
var ft4 = "https://" + host + "/signup/signup.aspx?id=UKueRJNoGkNrdn&t=t&tc=HP";
//For CPOM sign up 75 sites
var ft5 = "https://" + host + "/signup/signup.aspx?id=UNURvvzMPowyDe&tc=HP";
var ft6 = "https://" + host + "/signup/signup.aspx?id=UNURvvzMPowyDe&t=t&tc=HP";
//For CPOM sign up 150 sites
var ft7 = "https://" + host + "/signup/signup.aspx?id=UWsLYvUNhFWoCd&tc=HP";
var ft8 = "https://" + host + "/signup/signup.aspx?id=UWsLYvUNhFWoCd&t=t&tc=HP";
//var rg1 = "https://" + host + "/onlineaccount.html"
var rg1 = "https://" + host + "/onlineaccount.html "

var loc = document.location.toString();
var index = loc.indexOf(":");
  
//var url = loc.substring(index, loc.length);
  
//if (index == "4") { 
//  secureUrl = "https" + url;
//  location.replace(secureUrl); // get rid of current page in history
//  location.href = secureUrl;
//}

function InitPage() {
  MM_preloadImages('/images/button_signUpNowOn.gif','/images/button_learnMoreOn.gif');
  CheckForErrors();
  document.getElementById("txtLoginName").focus(); 
}

function CheckForErrors() {
  var qs = QueryString();

  if (qs.error != null) {
    if (qs.error == 1) {
      alert("The login information you have provided is incorrect, please try again.\nIf you still need assistance, please call 877 333 CONF (877 333 2663).");
    }
    if (qs.error == 9) {
      alert("You have exceeded the maximum login attempts.\nThis account has been locked.");
    }
  }
}
  
function QueryString() {
   var qs = new Object();
   var query = location.search.substring(1);
   var pairs = query.split("&");

   qs.count = 0;

   for (var i = 0; i < pairs.length; i++) {
      var pos = pairs[i].indexOf('=');

      if (pos == -1) continue;

      var name = pairs[i].substring(0, pos).toLowerCase();
      var value = pairs[i].substring(pos + 1);

      qs[name] = unescape(value);

      qs.count++;
   }

   return qs;
}
  
function GetCookie(cookieName) {
  var cookieNameStart,valueStart,valueEnd,cookieValue,returnValue;
  cookieNameStart = document.cookie.indexOf(cookieName+'=');
  if (cookieNameStart < 0) {
    returnValue = null;
  } else {
    valueStart = document.cookie.indexOf(cookieName+'=') + cookieName.length + 1;
    valueEnd = document.cookie.indexOf(";",valueStart);
    if (valueEnd == -1) {
      valueEnd = document.cookie.length;
    }
    cookieValue = document.cookie.substring(valueStart,valueEnd );
    returnValue = (cookieValue == '') ? null : unescape(cookieValue);
  }
  return returnValue;
}

function GetHTTPObject() {
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
    http = new XMLHttpRequest();
  } else if (window.ActiveXObject) { // IE
    try {
      http = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (i) {
      try {
        http = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (i) {}
    }
  }
  
  return http;
}

function GetPressReleases() {
  var http = GetHTTPObject();
  var url = document.location.protocol + "//" + host + "/services/pressreleases.aspx";
  http.open("POST", url, false);
  http.setRequestHeader("Content-Type", "application/json");
  
  try {
  http.send("");
} catch (ex) {
alert(ex.message);
}

  return JSON.parse(http.responseText);
}

function GetNewsLetters() {
  var http = GetHTTPObject();
  var url = document.location.protocol + "//" + host + "/services/newsletters.aspx";
  http.open("POST", url, false);
  http.setRequestHeader("Content-Type", "application/json"); 
  http.send("");

  return JSON.parse(http.responseText);
}

function GetDropDownLists() {
  var http = GetHTTPObject();
  var url = document.location.protocol + "//" + host + "/services/contact.aspx";
  http.open("POST", url, false);
  http.setRequestHeader("Content-Type", "application/json"); 
  http.send("");

  return JSON.parse(http.responseText);
}

function openWindow(URL, features) {
  var winA = window.open(URL, "_blank", features);
}
          
function ValidateRegion() {
  var r = document.getElementById("regionMenu");
  
  if (r.value != 0) {
    if (r.value > 2) {
      parent.location = document.location.protocol + "//" + host1;
    }
    return;
  }
  
  alert("Please select a valid region.");
}

function DisplayPromo() {
  var d = document;
  var u1 = "https://" + host + "/signup/signup.aspx?id=UKueRJNoGkNrdn&t=t&tc=HP";
  d.write('<a href="', u1, '" target="_blank"><img src="/images/freetrial.gif" alt="Try us free - Audio and Web Conferencing Free Trial" width="159" height="213" border="0" /></a>');
}

function DisplayLoginForm() {
  var d = document;
  var u1 = "https://" + host + "/confcenterapp/processlogin.aspx?beid=100004";
  var u2 = "http://" + host + "/onlineaccount.html";
  var u3 = "https://" + host + "/confcenterapp/pwforgot.aspx?beid=100004";
  var np;
  var nm = "";
  var ch = "";
  
  var ld = GetCookie('login');
  
  if (ld != null) {
    np = ld.split('=');
  
    if (np[0] == 'ln') {
      nm = np[1];
      ch = 'checked="True"';
    }
  }
  
  d.write('<form id="frmLogin" action="', u1, '" method="post" style="margin-top: 0px; margin-bottom: 0px;">');
  d.write('<div id="dashholdertop"></div>');
  d.write('<div id="meetingdashrmiddle">');
  d.write('<div class="pullheading">Account Dashboard</div>');
  d.write('<div class="pullsection">LOG IN&nbsp;<input id="txtLoginName" name="txtLoginName" type="text" tabindex="10" size="10" maxlength="50" style="font-size: 9px;" value="', nm, '" /><br />');
  d.write('</div>');
  d.write('<div class="pullsection2">PASSWORD&nbsp;<input id="txtPassword" name="txtPassword" type="password" tabindex="20" size="10" maxlength="50" style="font-size: 9px;" value="" /><br />');
  d.write('<a href="', u3, '" title="Retrieve Your Password"><span style="font-style: italic;">retrieve password</span></a></div>');
  d.write('<div class="pullsection2" style="vertical-align: middle;">remember me &nbsp;<input id="cbRemember" name="cbRemember" type="checkbox" tabindex="30" ', ch, ' /></div>');
  d.write('<div style="padding-top: 10px; text-align: center;"><input type="image" src="/images/button_enter.gif" value="Submit" alt="ENTER" tabindex="40" /></div>');
  d.write('</div>');
  d.write('<div id="dashholderbottom"></div>');
  d.write('</form>');
}

//Commented: 12/05/2010 (Kirk)
//DisplayLoginForm2 used in Drop Down Panel
function DisplayLoginForm2() {
  var d = document;
  var u1 = "https://" + host + "/confcenterapp/processlogin.aspx?beid=100004";
  var u2 = "http://" + host + "/onlineaccount.html";
  var u3 = "https://" + host + "/confcenterapp/pwforgot.aspx?beid=100004";
  var np;
  var nm = "";
  var ch = "";
  
  var ld = GetCookie('login');
  
  if (ld != null) {
    np = ld.split('=');
  
    if (np[0] == 'ln') {
      nm = np[1];
      ch = 'checked="True"';
    }
  }
  
  d.write('<form id="frmLogin" action="', u1, '" method="post" style="margin-top: 0px; margin-bottom: 0px;">');
  d.write('<h1>Existing Users/Account Dashboard Log In</h1>');
  d.write('<div style="padding-left: 70px;">');
  d.write('<label class="grey">Username:</label>');
  d.write('<input class="field" type="text" name="txtLoginName" id="txtLoginName" value="', nm, '" size="23" />');
  d.write('<label class="grey">Password:</label>');
  d.write('<input class="field" type="password" name="txtPassword" id="txtPassword" value="" size="23" /><br /><br />');
  d.write('<input name="cbRemember" id="cbRemember" type="checkbox" ', ch, ' /> &nbsp;remember me &nbsp;|&nbsp; <a href="', u3, '">retrieve password</a>');
  d.write('<div class="clear"></div>');
  d.write('</div>');
  d.write('<br />');
  d.write('<div style="padding-left: 140px;"><input type="submit" name="submit" value="" class="submitButton"></div>');
  d.write('</form>');
}

function GoHome() {
	window.location = "/";
}

function DisplayRegionForm() {
  var d = document;
  d.write('<div id="divHome" style="width: 100%; cursor: pointer;" onclick="GoHome();"></div>');

  d.write('<img src="/images/globe20.gif" alt="Choose a region" width="20" height="20" align="absmiddle" />&nbsp;');
  d.write('<select name="regionMenu" id="regionMenu" style="font-size: 9px;" OnChange="ValidateRegion();">');
  d.write('<option value="0" selected="selected">Choose Region</option>');
  d.write('<option value="0">............................</option>');
  d.write('<option value="1">North America</option>');
  d.write('<option value="2">South America</option>');
  d.write('<option value="3">Europe</option>');
  d.write('<option value="4">Asia-PAC</option>');
  d.write('<option value="5">Middle East</option>');
  d.write('<option value="6">Africa</option>');
  d.write('<option value="0">............................</option>');
  d.write('</select>');
}

function DisplayMeetingCenter() {
  var d = document;
  var u1 = "https://" + host + "/ConfCenter/meeting_center/meeting_center.aspx?100004&jnhst=Y";
  var u2 = "https://" + host + "/ConfCenter/meeting_center/meeting_center.aspx?100004&jnhst=N";
  d.write('<div id="meetingholdertop"></div>');
  d.write('<div id="meetingholdermiddle">');
  d.write('<div class="pullheading">Meeting Center</div>');
  d.write('<div class="pullsection">');
  d.write('<a href="', u1, '" style="text-decoration: none;" title="Log in as the Meeting Host or Moderator">HOST/MODERATOR');
  d.write('<img width="19" height="19" align="absmiddle" src="/images/arrow.gif" style="padding-right: 4px; padding-left: 6px;" alt="" /></a></div>');
  d.write('<div class="pullsection2">');
  d.write('<a href="', u2, '" style="text-decoration: none;" title="Log in as a Meeting Participant">PARTICIPANT');
  d.write('<img width="19" height="19" align="absmiddle" src="/images/arrow.gif" style="padding-right: 4px; padding-left: 6px;" alt="" /></a></div>');
  d.write('</div>');
  d.write('<div id="meetingholderbottom"></div>');
}

//Commented: 12/05/2010 (Kirk)
//DisplayMeetingCenter2 used in Drop Down Panel
function DisplayMeetingCenter2() {
  var d = document;
  var u1 = "https://" + host + "/ConfCenter/meeting_center/meeting_center.aspx?100004&jnhst=Y";
  var u2 = "https://" + host + "/ConfCenter/meeting_center/meeting_center.aspx?100004&jnhst=N";
  d.write('<a href="', u2, '" title="Log in as a Meeting Participant">JOIN A MEETING</a>');
  d.write('<a href="', u1, '" title="Log in as the Meeting Host or Moderator">HOST A MEETING</a>');
}

function DisplayCreateAccount() {
  var d = document;
  d.write('<div id="createholdertop"></div>');
  d.write('<div id="createholdermiddle">');
  d.write('<div class="pullheading">Create An Account</div>');
  d.write('<div class="pullsection">');
  d.write('<a href="', rg1, '" style="text-decoration: none;" title="Create an Account Now">GET STARTED');
  d.write('<img width="19" height="19" align="absmiddle" src="/images/arrow.gif" style="padding-right: 4px; padding-left: 6px;" alt="" /></a></div>');
  d.write('</div>');
  d.write('<div id="createholderbottom"></div>');
}
function DoSubmission() {
document.MyForm.submit();
}

function ShowDial() {
 newwindow = window.open('http://www.conferenceplus.com/cttapp/?pgn=c2c-cp-contact', 'name', 'resizable=no,height=450,width=470');
}
