var agt=navigator.userAgent.toLowerCase();
var is_safari = agt.indexOf("safari")!=-1;
function mainovr(div,name,status){
   if(is_safari){
      bHover=name; Act(div,name,false);window.status=status;}
   else{
      bHover=name;window.status=status;setTimeout('Act(\'' + div + '\', \'' + name + '\', false)',400);}
}
function findDiv(n, d) { 
   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=findDiv(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function tNav() { 
   var i,p,v,obj,args=tNav.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findDiv(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    if(v=='visible')setPosition(args[i]);    
    obj.visibility=v;} 
}
function hde(sect) {
  tNav('dom','','hide');tNav('host','','hide');tNav('sslhdr','','hide');tNav('em','','hide');tNav('eco','','hide');tNav('webs','','hide');showElement('select');
}
function hideDD(sect) {
  tNav(sect,'','hide');hde(sect);
}
var secSet = null;
var activeTimer = null;
var bHover = '';
function Act(sect, windowStatusVal, bshow) {
   hde(sect);
   if ((bHover==windowStatusVal)||(bshow)){     
      tNav(sect,'','show');
      if (secSet != null) window.clearTimeout(secSet);      
      hideElement('select', document.all[sect]); 
   }
}
function setPosition(sect)
{
  var obj, objstyle, overobj, len=0;
  overobj=findDiv(sect+"_td");
  obj=findDiv(sect);
  if (eval(overobj.offsetLeft+obj.offsetWidth) > overobj.offsetParent.offsetWidth){
   len = eval(overobj.offsetLeft+obj.offsetWidth)-overobj.offsetParent.offsetWidth;}
  if (obj.style) { objstyle=obj.style;
  objstyle.left = overobj.offsetLeft-len + "px";
  }
}
function Tim(sect){
   if (secSet != null) window.clearTimeout(secSet);
   secSet = window.setTimeout('hideDD("' + sect + '")',500);
}

function hideElement( elmID, overDiv ) {

  if(document.all) {
   for(i = 0; i < document.all.tags( elmID ).length; i++) {
      obj = document.all.tags( elmID )[i];
      if(!obj || !obj.offsetParent) continue;
      // Find the element's offsetTop and offsetLeft relative to the BODY tag.
      objLeft   = obj.offsetLeft - overDiv.offsetParent.offsetLeft;
      objTop    = obj.offsetTop;
      objParent = obj.offsetParent;
      while(objParent.tagName.toUpperCase() != 'HTML')
      {
        objLeft  += objParent.offsetLeft;
        objTop   += objParent.offsetTop;
        objParent = objParent.offsetParent;
      }
      objHeight = obj.offsetHeight;
      objWidth  = obj.offsetWidth;            
      if((overDiv.offsetLeft + overDiv.offsetWidth) <= objLeft);
      else if((overDiv.offsetParent.offsetTop + overDiv.offsetHeight + 50) <= objTop);
      else if(overDiv.offsetTop >= eval(objTop + objHeight));
      else if(overDiv.offsetLeft >= eval(objLeft + objWidth));
      else {
        obj.style.visibility = 'hidden';
      }
    }
  }
}

function showElement(elmID) {
  if(document.all) {
    for(i = 0; i < document.all.tags( elmID ).length; i++) {
      obj = document.all.tags(elmID)[i];
      if(!obj || !obj.offsetParent) continue;
      obj.style.visibility = '';
    }
  }
}






if (document.images){
   status_open = new Image();status_close = new Image();
   status_open.src = "https://imagesak.securepaynet.net/aaa/sb/bul_open.gif";status_close.src = "https://imagesak.securepaynet.net/aaa/sb/bul_close.gif";}
   
function gosb(url,t){
   if(t == "")t="_self";window.open(url,t);}

function sbStatus(){
   var dpClosed = false;
   var item = new Array("qs","mc","ma","s","e","rp","b","cr","mr","mn","rg"); //sidebar open/close
   for(x=0;x<item.length;x++){
      if(getCookie('sidebar_' + item[x]) == "1"){
         if(document.images [item[x]+"_img"]) document.images [item[x]+"_img"].src = status_close.src;
         if(document.getElementById(item[x]+'_div')) document.getElementById(item[x]+'_div').style.display = "";
         if((item[x]=="rp")||(item[x]=="s")) dpClosed = true;}
   }

   var item = new Array("customize","test");//landing page open/close
   for(x=0;x<item.length;x++){
      if(getCookie('sidebar_' + item[x]) == "1"){
         if (document.images [item[x]+"_img"]){
            document.images [item[x]+"_img"].src = status_open.src;document.getElementById(item[x]+'_div').style.display = "none";}
}}}

function checkHome(item)
{
   //homepage sidebar hasnt been activated yet, reload   
   var url = "https://www.securepaynet.net/gdshop/default.asp?prog%5Fid=cdhd2&app%5Fhdr=&sb=1&item=sbitem";
   url = url.replace('sbitem', item);window.open(url,'_self');}

function togSB(item){
   if(document.images [item+"_img"])   document.images [item+"_img"].src = (document.images [item+"_img"].src == status_open.src) ? status_close.src:status_open.src;
   if(document.getElementById(item+'_div')) document.getElementById(item+'_div').style.display = (document.getElementById(item+'_div').style.display=="none") ? "":"none";
   if(getCookie('sidebar_' + item) == "1"){
      eraseCookie('sidebar_' + item);
      if((document.getElementById('dp_divB'))&&(getCookie('sidebar_rp') != "1")&&(getCookie('sidebar_s') != "1")) document.getElementById('dp_divB').style.display = "";      
   }
   else{
      createCookie('sidebar_' + item,1,'');
      if((document.getElementById('dp_divB'))&&((getCookie('sidebar_rp') == "1")||(getCookie('sidebar_s') == "1"))) document.getElementById('dp_divB').style.display = "none";      
}}

function linkSB(url){
   location.href = url;}

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 getCookie(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;
}

function eraseCookie(name){
   createCookie(name,"",-1);}

function editSBselected(theForm, theVal, theDomain){
   if (theVal){
      theForm.searchSBselected.value = theForm.searchSBselected.value + '|' + theDomain + '|'}
   else{
      var theStr = theForm.searchSBselected.value;theStr = theStr.replace('|' + theDomain + '|', '');theForm.searchSBselected.value = theStr
}}

function checkSBDomain(searchForm){
   var canSubmit = false;
   var searchValue;
   if ('' == '' && searchForm.domainToCheck){
      searchValue = searchForm.domainToCheck.value;
      if (searchValue != ''){
         var regExInvalidChars = /[^a-zA-Z0-9-\s.]+/;
         if (regExInvalidChars.test(searchValue)){
            alert('Invalid character in domain.\n\nOnly letters, numbers or hyphens are allowed.')}
         else{
         canSubmit = true;}
      }
   }
   if (canSubmit){
      return true;
   }
   else{
      return false;}
}




function enterkey(frm,e){
   var keycode;
   if (window.event) keycode = window.event.keyCode;
   else if (e) keycode = e.which;
   if (keycode == 13) frm.submit();
}

function popPage(pagename, cici, progid, apphdr){
   var pgurl = 'prog%5Fid=cdhd2&app%5Fhdr=0&ci=cici';
   pgurl = pgurl.replace('cici', cici);
   if (progid != '') pgurl = pgurl.replace('cdhd2', progid);
   if (apphdr != '') pgurl = pgurl.replace('hdr=0', 'hdr=' + apphdr);
   if (pagename.indexOf('?') <= 0){
      pgurl = '?' + pgurl}
   else{
      pgurl = '&' + pgurl}
   if ((pagename.indexOf('http://') < 0)&&(pagename.indexOf('https://') < 0)){
      pgurl = ('https://www.securepaynet.net/gdshop/' + pagename + pgurl);}
   else{
      pgurl = (pagename + pgurl);   }
   var win=window.open(pgurl, 'spop', 'left=20,top=20,resizable=yes,scrollbars=yes,width=610,height=620');
}
function popAnchor(pagename, cici, anchor){
   var pgurl = 'prog%5Fid=cdhd2&app%5Fhdr=0&ci=cici';
   pgurl = pgurl.replace('cici', cici);
   if (pagename.indexOf('?') <= 0){
      pgurl = '?' + pgurl}
   else{
      pgurl = '&' + pgurl}
   if ((pagename.indexOf('http://') < 0)&&(pagename.indexOf('https://') < 0)){
      pgurl = ('https://www.securepaynet.net/gdshop/' + pagename + pgurl);}
   else{
      pgurl = (pagename + pgurl);   }
   if (anchor != '') pgurl = pgurl + '#' + anchor
   var win=window.open(pgurl, 'spop', 'left=20,top=20,resizable=yes,scrollbars=yes,width=610,height=620');
}
function popFaq(article_id){
   var faqurl = 'http://help.securepaynet.net/article.php?prog%5Fid=cdhd2&app%5Fhdr=0&article%5Fid=fff';
   faqurl = faqurl.replace('fff', article_id);
   var win=window.open(faqurl, 'spop', 'left=20,top=20,resizable=yes,scrollbars=yes,width=610,height=620');
}
function popFaqTopic(topic_id){
   var faqurl = 'http://help.securepaynet.net/article_list.php?prog%5Fid=cdhd2&app%5Fhdr=0&topic%5Fid=fff';
   faqurl = faqurl.replace('fff', topic_id);
   var win=window.open(faqurl, 'spop');
}
function popFaqTopic2(topic_id){
   var faqurl = 'http://help.securepaynet.net/topic_list.php?prog%5Fid=cdhd2&app%5Fhdr=0&topic%5Fid=fff';
   faqurl = faqurl.replace('fff', topic_id);
   var win=window.open(faqurl, 'spop');
}
var internal_clicked = false;  //for abandon popup
function processLinks(){ //set internal_clicked on all links
  var links = document.getElementsByTagName("A");
  for (var i=0; i < links.length; i++){
      if(!links[i].onclick) links[i].onclick = function(){internal_clicked = true;}}
  //set internal_clicked on all form submits
  var forms = document.getElementsByTagName("FORM");
  for (var i=0; i < forms.length; i++){
    if(!forms[i].onsubmit) forms[i].onsubmit = function(){internal_clicked = true;}}
}
function abandonWin(){
   if (!internal_clicked){ //show abandon popup 
      var target = "_abandon";      
      var url = "https://www.securepaynet.net/gdshop/jump_pages/abandon.asp?prog%5Fid=cdhd2&app%5Fhdr=99&location=locationurl";
      var loc = document.location.href; loc += (loc.indexOf('?') > 0) ? "&":"?";
      if (loc.indexOf('domainToCheck') < 1) loc += "domainToCheck=&tld=&checkAvail=&currStep="
      loc = passedURLEncode(loc);
      url = url.replace('locationurl', loc);    
      var winWidth = 420; var winHeight = 370;
      var options = "resizable=0,scrollbars=0,status=0,location=0,menubar=0,toolbar=0,width=" + winWidth + ",height=" + winHeight + ",top=" + ((screen.availHeight - winHeight) /2) + ",left=" + ((screen.availWidth - winWidth) /2) + ",screenX=" + ((screen.availWidth - winWidth) /2) + ",screenY=" + ((screen.availHeight - winHeight) /2) + ",";
      var win = window.open(url,target,options); win.focus();}
}
function passedURLEncode(str)
{
   str = str.replace(/\?/g,"!");str = str.replace(/=/g,"^");str = str.replace(/&/g,"$");
   return str;
}




function openPopup(url,name,width,height,navbar)
{
   var feat;
   
   feat = "width=" + width + ",";
   feat += "height=" + height;
   if(navbar == false)
   {
      feat += ",menubar=0,location=0,toolbar=0";
   }
   //alert(feat);
   window.open(url,name,feat);
   
}  

function enterkeySearch(frm,e)
{
   var keycode;
   if (window.event) keycode = window.event.keyCode;
   else if (e) keycode = e.which;
   if (keycode == 13) return setFormForCart();
}

function showSec(n) {

hideSec();
document.getElementById('sec' + n).style.visibility = "visible";
   
}
function hideSec() {
   document.getElementById('sec1').style.visibility = "hidden";
   document.getElementById('sec2').style.visibility = "hidden";
   document.getElementById('sec3').style.visibility = "hidden";
}


function openHostingCompare()
{
   window.open('https://www.securepaynet.net/gdshop/jump_pages/host_compare.asp?prog%5Fid=cdhd2&app%5Fhdr=99&ci=4776', 'display', 'left=20,top=20,scrollbars=yes,resizable=yes,width=620,height=500');
}
function openHostingAward()
{
   window.open('https://www.securepaynet.net/gdshop/jump_pages/besthost_award.asp?prog%5Fid=cdhd2&app%5Fhdr=99&ci=5989', 'display', 'left=20,top=20,scrollbars=yes,resizable=yes,width=410,height=600');
}

function openGoogleAdWords()
{
   window.open('https://www.securepaynet.net/gdshop/jump_pages/reseller_words.asp?prog%5Fid=cdhd2&app%5Fhdr=99&ci=3244', 'display', 'left=20,top=20,scrollbars=yes,resizable=yes,width=620,height=500');
}
   function openCFPopup(openThisURL)
   {
      var win=window.open(openThisURL, 'display1', 'left=50,top=50,resizable=yes,scrollbars=yes,width=400,height=220');
   }

   function openInfoPopup(openThisURL)
   {
      var win=window.open(openThisURL, 'display1', 'left=50,top=50,resizable=yes,scrollbars=yes,width=780,height=700');
   }
   
   function openEulaPopupAnchored()
   {
      var win=window.open('https://www.securepaynet.net/gdshop/jump_pages/server_availability.asp?prog%5Fid=cdhd2&app%5Fhdr=&ci=1412', 'display1', 'left=50,top=50,resizable=yes,scrollbars=yes,width=540,height=350');
   }

   function uncheckplans(thisField)
   {
      var total = document.frmHostMain.elements.length;
      var objStr;
      for(i=0;i<total;i++)
      {
         objStr = document.frmHostMain.elements[i].name;
         if (objStr.substring(0,4)=='plan')
        {
            if (objStr != thisField.name)
            {
               document.frmHostMain.elements[i].checked = false;
               
            } 
        } 
      }
   }

   function uncheck(item)
   {
      var elname;
      xItems = item.split("~");
      for(i=0; i<xItems.length; i++)
      {
         elname = xItems[i];
         document.getElementById(elname).checked = false;
      }
   }

var frm = document.frmHostMain;
function getHash(cnt)
{
   val = frm.elements['duration_'+cnt].options[frm.elements['duration_'+cnt].selectedIndex].value;
   frm.elements['Duration_Hash_'+cnt].value = frm.elements['Duration_Hash_'+cnt+'_'+val].value;
}
   
function setFormForCart()
{
   var total = frm.elements.length;
   var objStr;
   var pf_id_field;
   var pf_id;  
   var buy_count = 0;
   var numMonths = 0;
   var os_sel;

   for(i=0;i<total;i++)
   {
      objStr = frm.elements[i].name;
      objStr = objStr.toLowerCase();
      
      if (objStr.substring(0,4)=='plan')
     {
         if (frm.elements[i].checked == true)
         {
            os_sel = frm['osPlatform_'+objStr.substring(5,8)].options[frm['osPlatform_'+objStr.substring(5,8)].selectedIndex].value;
            buy_count = 1;
            numMonths = frm.elements[i].value;
            pf_id_field = objStr.replace('plan', os_sel);            
            pf_id = frm.elements[pf_id_field].value;
            frm.item_1.value = 1;
            frm.qty_1.value = numMonths;
            frm.pf_id_1.value = pf_id;
            
         } 
     } 
     else if (objStr.substring(0,5)=='item_')
     {
         if (frm.elements[i].checked == true)
         {
            buy_count = 1;
         }
     }
   }
   if (buy_count > 0)
   {
      //let form submit
      
      frm.action = "https://www.securepaynet.net/gdshop/xt_orderform_addmany.asp?prog%5Fid=cdhd2&config=hosting1&app%5Fhdr=&ci=5742";
      
   }
   else
   {
      alert("You have not selected any product on this page.");
      return false;
   }
}




function checkQty(frm)
{
   for(i=0;i<frm.plan.length;i++)
  {
    if (frm.plan[i].checked==true)
    {
         var pfVal = frm.plan[i].value;
         if (pfVal=='Eco')
         {

            for(i=0;i<frm.qty_1.length;i++)
           {
             if (frm.qty_1[i].checked==true)
             {
                  var qtyVal = frm.qty_1[i].value;
                  if (qtyVal==1)
                  {
                     frm.qty_1[i].value = 2;
                  }
               }
            }

         }
      }
   }
}



var agt=navigator.userAgent.toLowerCase();
var is_opera = (agt.indexOf("opera") != -1);

function ShowHelp(obj,field,hide)
{
  //Get help object
  var helpObj;
  if (document.all){
  helpObj = document.all[field+"_help"];}
  else if (document.getElementById){
    helpObj = document.getElementById(field+"_help");}
  if (helpObj) {
    //if help object is shown, hide it ; if object hidden, show it
    if (hide){
      helpObj.style.display = "none";}
    else{
      helpObj.style.display = "";}

    //Get location of mouseover object, move help object to the left if will display off-screen
    var divWidth = 340;
    var offsetLeft = getOffsetLeft(obj);
    var screenWidth = (window.innerWidth) ? window.innerWidth - 25 : document.body.clientWidth;
    if ((offsetLeft + divWidth) > screenWidth) offsetLeft = screenWidth - divWidth;
    newX = offsetLeft;

    //Get location of mouseover object, move help object on top if will display off-screen
    var divHeight = helpObj.offsetHeight;
    var offsetTop = getOffsetTop(obj) + obj.offsetHeight;
    var screenHeight = (window.innerHeight) ? window.innerHeight - 25 : document.body.clientHeight;
    if ((offsetTop + divHeight) > screenHeight + getScrollY()) offsetTop = getOffsetTop(obj) - divHeight;
    newY = offsetTop;

    helpObj.style.top = newY;
    helpObj.style.left = newX;

    if (!hide){
      qh_hideElement("select",helpObj);
      qh_hideElement("object",helpObj);
      qh_hideElement("embed",helpObj);  }
    else{
      qh_showElement("select");
      qh_showElement("object");
      qh_showElement("embed");}
  }
}

function getOffsetTop (elm) {
  var mOffsetTop = elm.offsetTop;
  var mOffsetParent = elm.offsetParent;
  while (mOffsetParent) {
    mOffsetTop += mOffsetParent.offsetTop;
    mOffsetParent = mOffsetParent.offsetParent;}
  return mOffsetTop;
}

function getOffsetLeft (elm) {
  var mOffsetLeft = elm.offsetLeft;
  var mOffsetParent = elm.offsetParent;
  while (mOffsetParent) {
    mOffsetLeft += mOffsetParent.offsetLeft;
    mOffsetParent = mOffsetParent.offsetParent;}
  return mOffsetLeft;
}

function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape
    scrOfY = window.pageYOffset;}
  else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM
    scrOfY = document.body.scrollTop;}
  else if( document.documentElement &&
      ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6
    scrOfY = document.documentElement.scrollTop;}
  return scrOfY;
}

function qh_hideElement( elmID, overDiv ) {
  if(document.all) {
    for(i = 0; i < document.all.tags( elmID ).length; i++) {
      obj = document.all.tags( elmID )[i];
      if(!obj || !obj.offsetParent) continue;

      // Find the element's offsetTop and offsetLeft relative to the BODY tag.
      objLeft   = obj.offsetLeft;
      objTop    = obj.offsetTop;
      objParent = obj.offsetParent;

      while(objParent.tagName.toUpperCase() != 'BODY') {
        objLeft  += objParent.offsetLeft;
        objTop   += objParent.offsetTop;
        objParent = objParent.offsetParent;
      }

      objHeight = obj.offsetHeight;
      objWidth  = obj.offsetWidth;

      if((overDiv.offsetLeft + overDiv.offsetWidth) <= objLeft);
      else if((overDiv.offsetTop + overDiv.offsetHeight) <= objTop);
      else if(overDiv.offsetTop >= (objTop + objHeight));
      else if(overDiv.offsetLeft >= (objLeft + objWidth));
      else {
        obj.style.visibility = 'hidden';
      }
    }
  }
}
function qh_showElement(elmID) {
  if(document.all) {
    for(i = 0; i < document.all.tags( elmID ).length; i++) {
      obj = document.all.tags(elmID)[i];
      if(!obj || !obj.offsetParent) continue;
      obj.style.visibility = '';
    }
  }
}
function openGooglePopup()
{
   var win=window.open('https://www.securepaynet.net/gdshop/popup.asp?prog%5Fid=cdhd2&display=google&ci=10463', 'display2', 'left=50,top=50,resizable=yes,scrollbars=yes,width=410,height=200');
}
function openMicrosoftAdCenter()
{
   window.open('https://www.securepaynet.net/gdshop/jump_pages/adCenter.asp?prog%5Fid=cdhd2&app%5Fhdr=99&ci=8845', 'display', 'left=20,top=20,scrollbars=yes,resizable=yes,width=620,height=500');
}
