// global value for long expiry date cookie
var longcookie = 14;

// preload some images:

NewImg = new Array(
'/images/bot_left.gif',
'/images/bot_right.gif',
'/images/top_left.gif',
'/images/top_right.gif',
'/images/hb_tb_right.gif',
'/images/hb_t_bottom.gif',
'/images/hb_tb_left.gif',
'/images/hb_t_right.gif',
'/images/hb_t_top.gif',
'/images/hb_t_left.gif',
'/images/hb_tt_right.gif',
'/images/hb_tt_left.gif'
);
arImageList = new Array();

for (counter in NewImg)
{
  arImageList[counter] = new Image();
  arImageList[counter].src = NewImg[counter];
}
function logout(usr)
{
  if (confirm('Are you sure you wish to logout, '+usr+'?\n\n\nClick "OK" to logout of Kingston Online Services.\nClick "Cancel" to return to Kingston Online Services.'))
    document.location.href = '/logout.kos';
  return false;
}
function checkLogin(form)
{
  if (form.kos_user.value == '')
  {
    alert('Please enter your username.');
    form.kos_user.focus();
    return false;
  }

  if (form.kos_user.value.indexOf('@kos.net') != -1)
  {
    alert('Your My Account login is your main KOS username, without "@kos.net"\n\nIt will now be removed, please try again.');
    var newtmp = form.kos_user.value.split('@');
    form.kos_user.value = '';
    form.kos_user.value = newtmp[0];
    if (form.kos_pass.value=='') form.kos_pass.focus();
    else form.sbutton.focus();
    return false;
  }
  if (form.kos_pass.value == '')
  {
    alert('Please enter your password.');
    form.kos_pass.focus();
    return false;
  }
}
NewImg = new Array ('/images/arrow_b_d.gif', '/images/arrow_b_u.gif', '/images/arrow_w_d.gif', '/images/arrow_w_u.gif');

arImageList = new Array();

for (counter in NewImg)
{
  arImageList[counter] = new Image();
  arImageList[counter].src = NewImg[counter];
}
function ShowIt(where, arrow_col, id)
{
  show = new Image();
  show.src = '/images/arrow_'+arrow_col+'_d.gif';

  hide = new Image();
  hide.src = '/images/arrow_'+arrow_col+'_u.gif';

  if (document.getElementById)
  {
    if (document.getElementById(where).style.display == 'block')
    {
      document.getElementById(where).style.display = 'none';
      document.getElementById('show_'+where).src = show.src;
      document.getElementById('show_'+where).title = 'show';
      if (document.getElementById('link_'+where)) document.getElementById('link_'+where).title = 'click to show';
    }
    else
    {
      document.getElementById(where).style.display = 'block';
      document.getElementById('show_'+where).src = hide.src;
      document.getElementById('show_'+where).title = 'hide';
      if (document.getElementById('link_'+where)) document.getElementById('link_'+where).title = 'click to hide';
	 if (id) document.getElementById(id).focus();
    }
  }
  createCookie(where, document.getElementById(where).style.display, longcookie, '/');
}
// end showhide

// start showhide sub nav
function start_sub_nav(divName, sec, group, stype)
{
  var colour = 'transparent';
  var pad = 2;
  var id = group+'_'+divName;
  var show_div;

  if (!id.indexOf(group)) var show_or_hide = (stype==divName) ? 'block' : 'none';
  document.write('<div id="'+id+'" style="background-color:'+colour+'; padding:'+pad+'px;display:'+show_or_hide+';">');
}
function end_sub_nav()
{
  document.write('<div style="padding:5px"></div></div>')
}
// end showhide sub nav
function hideDivs(group)
{
  var divs = document.getElementsByTagName('div');

  for (var i=0; i < divs.length; i++)
  {
    var div = divs[i];
    var id = div.id;
    if (!id.indexOf(group+'_'))
      div.style.display = 'none';
  }
}
function showPlans(divName, group)
{
  var id = group+'_'+divName;

  if (document.getElementById(id).style.display=='block')
  {
    hideDivs(group);
    document.getElementById(group+'_intro').style.display='block';
    if (group=='hosting') document.getElementById('plesk_features').style.display='none';
  }
  else
  {
    hideDivs(group);
    document.getElementById(id).style.display = 'block';
    if (group=='hosting') document.getElementById('plesk_features').style.display='block';
  }
}
// I don't think sec is being used, but in a lot
// of showSec calls, so I didn't bother removing it...
function showSec(divName, sec, group)
{
  var id = group+'_'+divName;

  if (document.getElementById(id).style.display == 'block') hideDivs(group);
  else
  {
    hideDivs(group);
    document.getElementById(id).style.display = 'block';
  }
}
// end showhide sub nav
// start rounded css box
function start_rounded_box(s_name, width, bcolour, fcolour, pad)
{
  if (fcolour=='') fcolour = '#000';
  if (pad == '') pad = 5;
  fwidth = (width=='100%') ? '' : 'px';
  document.write(''
  +'<style type="text/css">'
  +'div.'+s_name+'1 {text-align:left; width:'+width+''+fwidth+'; background:'+bcolour+' url("/images/top_right.gif") no-repeat top right;}'
  +'div.'+s_name+'2 {background:transparent url("/images/top_left.gif") no-repeat top left;color:'+fcolour+';}'
  +'div.'+s_name+'3 {background:transparent url("/images/bot_right.gif") no-repeat bottom right;color:'+fcolour+';}'
  +'div.'+s_name+'4 {background:transparent url("/images/bot_left.gif") no-repeat bottom left; padding:'+pad+'px; color:'+fcolour+';}'
  +'</style>'
  +'<div class="'+s_name+'1"><div class="'+s_name+'2"><div class="'+s_name+'3"><div class="'+s_name+'4">');
}
function end_rounded_box()
{
  document.write('</div></div></div></div>')
}
// end rounded css box

function google(obj, usr)
{
  var msg = '';
  if (obj.value == '')
  {
    if (usr != '') msg = usr+', p';
    else msg = 'P';
    alert(msg+'lease enter something to search for.');
    obj.focus();
    return false;
  }
  return true;
}
// start hollow box
function start_hollow_box(width, align, pad, tColour, bColour, tSize, tAlign, cHeight, tText)
{
  var dif = width - 4;
  if (!align) align = 'left';
  if (!pad) pad = 6;
  if (!tText) var bImg = ' background="/images/hb_t_top.gif"';
  if (!tSize) tSize = 12
  if (!cHeight) cHeight = 0;
  if (!tAlign) tAlign = 'left';
  if (!tColour) tColour = '#000';
  if (width=='100%') dif = 0;
  if (!tText)
  {
    tText = '';
    cHeight = 0;
    tPad = 0;   
  }
  else tPad = 2;//2
  document.write(''
  +'<table border="0" cellpadding="0" cellspacing="0" width="'+width+'">'
  +'  <tr>'
  +'    <td width="2" height="2" valign="top" bgcolor="'+bColour+'"><img src="/images/hb_tt_left.gif" alt=""></td>'
  +'    <td width="'+dif+'" bgcolor="'+bColour+'" style="padding:'+tPad+'px;height:'+cHeight+'px;color:'+tColour+';font-size:'+tSize+'px;vertical-align:bottom;text-align:'+tAlign+'"'+bImg+'>'+tText+'</td>'
  +'    <td width="2" valign="top" bgcolor="'+bColour+'"><img src="/images/hb_tt_right.gif" alt=""></td>'
  +'  </tr>'
  +'  <tr>'
  +'    <td width="2" bgcolor="'+bColour+'" background="/images/hb_t_left.gif"></td>'
  +'    <td valign="top" align="'+align+'" style="padding:'+pad+'px">');
}
function end_hollow_box(width, bColour)
{
  var dif = width - 4;
  document.write(''
  +'    </td>'
  +'    <td bgcolor="'+bColour+'" background="/images/hb_t_right.gif"></td>'
  +'  </tr>'
  +'  <tr>'
  +'    <td width="2" height="2" bgcolor="'+bColour+'" background="/images/hb_tb_left.gif"></td>'
  +'    <td width="'+dif+'" bgcolor="'+bColour+'" background="/images/hb_t_bottom.gif"></td>'
  +'    <td width="2" bgcolor="'+bColour+'" background="/images/hb_tb_right.gif"></td>'
  +'  </tr>'
  +'</table>');
}
// end hollow box
// start rounded css table
function start_rounded_table(width, bcolour, fcolour, pad)
{
  if (fcolour=='') fcolour = '#000000';
  if (pad=='') pad = 5;
  var dif = width - 2;
  document.write(''
  +'<table border="0" cellpadding="0" cellspacing="0" width="'+width+'" bgcolor="'+bcolour+'">'
  +'  <tr>'
  +'    <td width="2" height="2" bgcolor="'+bcolour+'"><img src="/images/top_left.gif" alt=""></td>'
  +'    <td width="'+dif+'" bgcolor="'+bcolour+'"></td>'
  +'    <td width="2" bgcolor="'+bcolour+'"><img src="/images/top_right.gif" alt=""></td>'
  +'  </tr>'
  +'  <tr>'
  +'    <td width="2" bgcolor="'+bcolour+'"></td>'
  +'    <td valign="top" style="padding:'+pad+'px; color:'+fcolour+'">');
}
function end_rounded_table(width, bcolour)
{
  var dif = width - 2;
  document.write(''
  +'    </td>'
  +'    <td bgcolor="'+colour+'"></td>'
  +'  </tr>'
  +'  <tr>'
  +'    <td width="2" height="2" bgcolor="'+bcolour+'"><img src="/images/bot_left.gif" alt=""></td>'
  +'    <td width="'+dif+'" bgcolor="'+bcolour+'"></td>'
  +'    <td width="2" bgcolor="'+bcolour+'"><img src="/images/bot_right.gif" alt=""></td>'
  +'  </tr>'
  +'</table>');
}
// end rounded css table
// start div hide
function start_div_hide(title, div_name, width, a_class, id, soh, arrow_col)
{
  if (a_class=='') a_class = 'showhide';

  var show_or_hide = (soh=='show') ? 'block' : 'none';
  var show_div = readCookie(div_name);
  var t_text = (show_or_hide=='none') ? 'click to show' : 'click to hide';
  var d_img = (show_or_hide=='none') ? 'd' : 'u';
  if (show_div) d_img = (show_div=='none') ? 'd' : 'u';
  document.write(''
  +'<style type="text/css">'
  //  +'div.'+div_name+'_x {width:100%; height:100%}'
  +'div.'+div_name+'_x a {border:0px solid #ff0000;vertical-align:middle;height:16px;width:100%;display:block}'
  +'</style>'
  +'<div class="'+div_name+'_x">'
  +'<table width="'+width+'" cellpadding="0" cellspacing="0">'
  +'  <tr>'
  +'    <td style="width:90%; padding-left:1px"><a href="javascript:void(0)" onclick="ShowIt(\''+div_name+'\', \''+arrow_col+'\', \''+id+'\');" id="link_'+div_name+'" title="'+t_text+'" class="'+a_class+'" style="padding-top:1px">'+title+'</a></td>'
  +'    <td style="width:10%; text-align:right; vertical-align:middle"><a href="javascript:void(0)" onclick="ShowIt(\''+div_name+'\', \''+arrow_col+'\', \''+id+'\')" id="link_'+div_name+'" title="'+t_text+'" class="'+a_class+'"><img src="/images/arrow_'+arrow_col+'_'+d_img+'.gif" id="show_'+div_name+'" title="'+t_text+'" border="0" style="margin-top:3px"></a></td>'
  +'  </tr>'
  +'</table>'
  +'</div>');
  if (show_div) document.write('<div id="'+div_name+'" style="display:'+show_div+'">');
  else document.write('<div id="'+div_name+'" style="display:'+show_or_hide+'">');
}
function end_div_hide()
{
  document.write('</div>')
}
// end div hide
// these functions will remove dotted lines (focus) from ALL links when the page is first loaded
// This MAY piss people off if they cannot tab to a link...if so, use the other function
function unblur()
{
  this.blur()
}
function blurLinks()
{
  theLinks = document.getElementsByTagName('a');
  for (i=0; i<theLinks.length; i++) theLinks[i].onfocus = unblur;
}
window.onload = blurLinks;
//
// this function will hide the focus around a link using the onclick event (allows people to tab to a link)
/*
function hideFocus(evt)
{
  evt = (evt) ? evt : ((event) ? event : null);
  if (evt)
  {
    var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    if (elem)
    {
	 elem = (elem.tagName != 'A') ? elem.parentNode : elem;
	 if (elem.tagName == 'A')
	   elem.blur();
    }
  }
}
document.onclick = hideFocus;
*/
// start More Info popup
function more_info(which, des, itype)
{
  document.write('<a href="javascript:void(0)" onclick="openMoreInfo(\''+which+'\')" onfocus="this.blur()" title="'+des+' - click for more" style="cursor:help"><img src="/images/'+itype+'" style="vertical-align:middle" alt="'+des+' - click for more" border="0"></a>')
}
function openMoreInfo(item)
{
  var w = 400;
  var h = 300;
  var LeftPosition = (Math.floor(screen.availWidth)) ? (Math.floor(screen.availWidth) - w) / 2 : 5;
  var TopPosition = (Math.floor(screen.availHeight)) ? (Math.floor(screen.availHeight) - h) / 2 : 5;
  window.open('/minfo.kos?'+item, 'mi', 'width='+w+', height='+h+',resizable=yes,status=yes,location=no,menubar=no,toolbar=no,scrollbars=yes,left='+LeftPosition+', top='+TopPosition);
}
function globalcpop(url, w, h)
{
  var LeftPosition = (Math.floor(screen.availWidth)) ? (Math.floor(screen.availWidth) - w) / 2 : 5;
  var TopPosition = (Math.floor(screen.availHeight)) ? (Math.floor(screen.availHeight) - h) / 2 : 5;
  window.open(url, 'gcpop', 'width='+w+', height='+h+',resizable=yes,status=yes,location=no,menubar=no,toolbar=no,scrollbars=yes,left='+LeftPosition+', top='+TopPosition);
}
function openHalf(url)
{
  var w = screen.availWidth / 2;
  var h = screen.availHeight;
  window.open(url, 'fullwin', 'width='+w+',height='+h+',location=no,menubar=yes,toolbar=no,scrollbars=yes,resizable=yes,left=0,top=0');
}
function PrintFriendly(page)
{
  if (page == 'na')
  {
    if (confirm('For security purposes, we cannot offer\na printer friendly verison of this page.\n\n\nClick "OK" to print the entire page, or "Cancel"')) window.print();
    else return;
  }
  else
  {
    var w = 640;
    var h = 480;

    var LeftPosition = (Math.floor(screen.availWidth)) ? (Math.floor(screen.availWidth) - w) / 2 : 5;
    var TopPosition = (Math.floor(screen.availHeight)) ? (Math.floor(screen.availHeight) - h) / 2 : 5;
    window.open(page, 'pf', 'width='+w+', height='+h+',resizable=yes,status=yes,location=no,menubar=yes,toolbar=no,scrollbars=yes,left='+LeftPosition+', top='+TopPosition); 
  }
}
function gpicpop(pic,w,h)
{
  var LeftPosition = (Math.floor(screen.availWidth)) ? (Math.floor(screen.availWidth) - w)/2 : 5;
  var TopPosition = (Math.floor(screen.availHeight)) ? (Math.floor(screen.availHeight) - h)/2 : 5;
  window.open('/gpop.kos?pic='+pic,'gpop','width='+w+',height='+h+',resizable=yes,status=no,location=no,menubar=no,toolbar=no,scrollbars=no,left='+LeftPosition+',top='+TopPosition);
}
function SelectIt(list)
{
  if (list.options[list.selectedIndex].value != '')
  {
    url = list.options[list.selectedIndex].value.split('|');
    if (url[0]=='new') window.open(url[1]);
    else if (url[0]=='targetwin')
    {
	 var targetwin = url[1];
	 if (typeof window[targetwin] != 'undefined') setTimeout("window."+targetwin+".location.href = url[2]", 1);
    }
    else setTimeout("location.href = url[0]",1);
  }
}
// start autotab for DSL check
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
// end autotab for DSL check
// start DSL check
function check_dsl_frm()
{
  var frm = document.dslcheck;

  if (frm.phone1.value.length <= 2)
  {
    alert('Please enter your area code.');
    frm.phone1.focus();
    return false;
  }
  if (frm.phone2.value.length <= 2)
  {
    alert('Please enter the first three digits of your phone number.');
    frm.phone2.focus();
    return false;
  }
  if (frm.phone3.value.length <= 3)
  {
    alert('Please enter the last four digits of your phone number.');
    frm.phone3.focus();
    return false;
  }
}
// end DSL check
// start residential/business service switcher
function s_switch(toshow, tohide)
{
  if (document.getElementById(toshow).style.display == 'none') document.getElementById(toshow).style.display = 'block';
  else document.getElementById(toshow).style.display = 'none';

  if (document.getElementById(tohide).style.display == 'block') document.getElementById(tohide).style.display = 'none';
  else document.getElementById(tohide).style.display = 'none';
}
// end residential/business service switcher
/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

// put menu details in /includes/header.inc.kos

var menuwidth = '107px';      //default menu width
var menubgcolor = '#003399';  //menu bgcolor
var disappeardelay = 350;     //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick = 'no'; //hide menu when user clicks within menu?
var xpad = 4;
var ypad = 1;

/////No further editting needed
var ie4=document.all;var ns6=document.getElementById && !document.all; if (ie4||ns6) document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onmouseover="clearhidemenu()" onmouseout="dynamichide(event)"></div>');

// Hide all select boxes
function hideSelect()
{
  if (document.all)
  {
    for (formIdx=0; formIdx<document.forms.length; formIdx++)
    {
      var theForm = document.forms[formIdx];
      for (elementIdx=0; elementIdx<theForm.elements.length; elementIdx++)
      {
        if (theForm[elementIdx].type == "select-one")
        {
          theForm[elementIdx].style.visibility = "hidden";
        }
      }
    }
  }
}
// Unhide all select boxes
function unhideSelect()
{
  if (document.all)
  {
    for (formIdx=0; formIdx<document.forms.length; formIdx++)
    {
      var theForm = document.forms[formIdx];
      for (elementIdx=0; elementIdx<theForm.elements.length; elementIdx++)
      {
        if (theForm[elementIdx].type == "select-one")
        {
		theForm[elementIdx].style.visibility = "visible";
	   }
	 }
    }
  }
}

function getposOffset(what, offsettype){var totaloffset=(offsettype == 'left') ? what.offsetLeft : what.offsetTop; var parentEl=what.offsetParent;while (parentEl!=null){totaloffset = (offsettype == 'left')? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;parentEl=parentEl.offsetParent;}return totaloffset;}
function showhide(obj, e, visible, hidden, menuwidth) {if (ie4||ns6) dropmenuobj.style.left=dropmenuobj.style.top=-500;if (menuwidth!=""){dropmenuobj.widthobj=dropmenuobj.style;dropmenuobj.widthobj.width=menuwidth;}if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){obj.visibility=visible;hideSelect();}else if (e.type=="click") {obj.visibility=hidden;unhideSelect()}}
function iecompattest(){return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body}
function clearbrowseredge(obj, whichedge){var edgeoffset=0; if (whichedge=="rightedge") {var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15;dropmenuobj.contentmeasure=dropmenuobj.offsetWidth;if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth;}else{var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18;dropmenuobj.contentmeasure=dropmenuobj.offsetHeight;if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight;}return edgeoffset}
function populatemenu(what) {if (ie4||ns6) dropmenuobj.innerHTML=what.join('') }
function dropdownmenu(obj, e, menucontents, menuwidth) {if (window.event) {event.cancelBubble=true;}  else if (e.stopPropagation) {e.stopPropagation();} clearhidemenu();  dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv;  populatemenu(menucontents);if (ie4||ns6) {showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth);dropmenuobj.x=getposOffset(obj, "left") - xpad; dropmenuobj.y = ypad+getposOffset(obj, "top");dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px";dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px";}return clickreturnvalue()}
function clickreturnvalue() {if (ie4||ns6) return false; else return true}
function contains_ns6(a, b) {while (b.parentNode)if ((b = b.parentNode) == a)return true;return false;}
function dynamichide(e) {if (ie4&&!dropmenuobj.contains(e.toElement)) {delayhidemenu()} else if (ns6 && e.currentTarget != e.relatedTarget) { delayhidemenu()}} // new
// original function dynamichide(e) {if (ie4&&!dropmenuobj.contains(e.toElement)) {delayhidemenu()} else if (ns6 && e.currentTarget != e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget)) { delayhidemenu()}}
function hidemenu(e) {if (typeof dropmenuobj!="undefined"){if (ie4||ns6)dropmenuobj.style.visibility='hidden';unhideSelect()}}
function delayhidemenu() {if (ie4 || ns6) delayhide=setTimeout("hidemenu()", disappeardelay)}
function clearhidemenu() {if (typeof delayhide != 'undefined') clearTimeout(delayhide)}
if (hidemenu_onclick=='yes') {document.onclick = hidemenu;unhideSelect()}

// start hide email
// this script will help hide email address from spammers
// call like so: <script type="text/javascript">h_mail('support', '')</script>
function h_mail(b, c)
{
  var a = '@';
  var dom = 'kos.net';
  var x = 'ma';
  var y = 'il';
  var z = 'to:';
  document.write('<a href="'+x+y+z+b+a+'kos.net'+'" class="'+c+'">'+b+a+dom+'</a>');
}
// end hide email
// start domain name check
function checkDomName(obj)
{
  if (obj.value == '')
  {
    alert('Please enter a domain name to search for.');
    obj.focus();
    return false;
  }

  if ((obj.value.indexOf('http://') == 0) || (obj.value.indexOf('http://www.') == 0))
  {
    var tmp = new String(obj.value);
    alert('Domain name cannot include http:// or www. and will automatically be removed.');
    tmp = tmp.replace('http://www.', '');
    tmp = tmp.replace('http://', '');
    tmp = tmp.replace('\/', '');
    obj.value = tmp;
    //document.getElementById('code').innerHTML = '<br>If correct, press <b>Enter</b> or click <b>go</b>';
    obj.focus();
    return false;
  }
  if (obj.value.indexOf('www.') == 0)
  {
    var tmp = new String(obj.value);
    alert('Domain name cannot include www. and will automatically be removed.');
    tmp = tmp.replace('www.', '');
    tmp = tmp.replace('\/', '');
    obj.value = tmp;
    //document.getElementById('code').innerHTML = '<br>If correct, press <b>Enter</b> or click <b>go</b>';
    obj.focus();
    return false;
  }
  if (obj.value.indexOf('.') != -1)
  {
    alert('Domain name cannot include a dot.');
    var newtmp = obj.value.split('.');
    obj.value = '';
    obj.value = newtmp[0];
    obj.focus();
    return false;
  }
  return true;
}
// end domain name check
// search for domain again
function sagain()
{
  document.getElementById('dsearch').style.display='none';
  document.DomainForm.domain.value='';
  document.DomainForm.domain.focus();
  document.DomainForm.domext.selectedIndex = 0
}
function dombox()
{
  if (document.DomainForm.domain.value=='') document.DomainForm.domain.focus();
  else document.DomainForm.button1.focus();
}
function pleskTuts(ver,page)
{
  var w = 785; // 780
  var h = 480; // 430
  var LeftPosition = (Math.floor(screen.availWidth)) ? (Math.floor(screen.availWidth) - w) / 2 : 5;
  var TopPosition = (Math.floor(screen.availHeight)) ? (Math.floor(screen.availHeight) - h) / 2 : 5;
  if (page != 'x') window.open('./plesk/mainpsa'+ver+'.kos?tutorial='+page+'&version=<?php echo $psa_ver ?>','dw','width='+w+', height='+h+',resizable=yes,status=yes,location=no,menubar=no,toolbar=no,scrollbar=yes,left='+LeftPosition+', top='+TopPosition);
}
function domSupportCheck(obj)
{
  if (obj.value == '')
  {
    alert('Please enter a domain name.');
    obj.focus();
    return false;
  }
  if ((obj.value.indexOf('http://') == 0) || (obj.value.indexOf('http://www.') == 0))
  {
    var tmp = new String(obj.value);
    alert('Domain name cannot include http://');
    tmp = tmp.replace('http://www.', '');
    tmp = tmp.replace('http://', '');
    tmp = tmp.replace('\/', '');
    obj.value = tmp;
    document.getElementById('code').innerHTML = '<br>If correct, press <b>Enter</b> or click <b>go</b>';
    document.domain_s.submit.focus();
    return false;
  }
  if (obj.value.indexOf('www.')==0)
  {
    var tmp = new String(obj.value);
    alert('Domain name cannot include www.');
    tmp = tmp.replace('www.', '');
    tmp = tmp.replace('\/', '');
    obj.value = tmp;
    document.getElementById('code').innerHTML = '<br>If correct, press <b>Enter</b> or click <b>go</b>';
    document.domain_s.submit.focus();
    return false;
  }
  if (obj.value.indexOf('.') == -1)
  {
    alert('Invalid domain name, please try again.');
    obj.focus();
    return false;
  }
  var isdone = '<?php echo $domain ?>';
  //if (isdone == obj.value)return false;
  return true;
}
function domWhois(url)
{
  var w = 580;
  var h = 435;
  var LeftPosition = (Math.floor(screen.availWidth)) ? (Math.floor(screen.availWidth) - w) / 2 : 5;
  var TopPosition = (Math.floor(screen.availHeight)) ? (Math.floor(screen.availHeight) - h) / 2 : 5;
  window.open(url,'dw','width='+w+', height='+h+',resizable=yes,status=yes,location=no,menubar=no,toolbar=no,scrollbars=yes,left='+LeftPosition+', top='+TopPosition);
}
function sameNum()
{
  document.getElementById('dsl_phone').value = '';
  document.getElementById('dsl_phone').value = document.getElementById('phone').value
}
// from support ticket form
function needSupport()
{
  if (confirm('To contact Technical Support by form,\nplease visit the KOS Support Centre:\n\n\http://www.kos.net/support/')) location.href='/support/';
  return false;
}
function noPcode()
{
  document.pinfo.pcode_1.value='';
  document.pinfo.pcode_2.value='';
  document.pinfo.pcode_1.focus()
}
function cSouth()
{
  if (document.getElementById('seo').style.display == 'none')
  {
    document.getElementById('intro').style.display = 'none';
    document.getElementById('seo').style.display = 'block';
    document.getElementById('pec').style.display = 'none';
    createCookie('warea', 'seo', longcookie, '/');
  }
}
function cPrince()
{
  if (document.getElementById('pec').style.display == 'none')
  {
    document.getElementById('intro').style.display = 'none';
    document.getElementById('pec').style.display = 'block';
    document.getElementById('seo').style.display = 'none';
    createCookie('warea', 'pec', longcookie, '/');
  }
}
function chgMain(url){if(window.opener){window.opener.location.href=url;self.close()}}
function openandclose(url){window.open(url);self.close()}

function textCounter(field, countfield, maxlimit)
{
  if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit);
  else countfield.value = maxlimit - field.value.length;
}

function post_comment(form)
{
  if (form.fullname.value=='')
  {
    alert('Please enter your name.');
    form.fullname.focus();
    return false;
  }
  if (form.url.value!='')
  {
    if (form.url.value.indexOf('http://')==-1)
    {
      alert('The URL must start with http://');
      form.url.focus();
      return false;
    }
  }
  if (form.email.value=='')
  {
    alert('Please enter your email address.');
    form.email.focus();
    return false;
  }
  if (form.email.value!='')
  {
    if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email.value))
    {
      alert('Your e-mail address appears to be invalid, please try again.');
      form.email.focus();
      return false;
    }
  }
  if (form.comment.value=='')
  {
    alert('Please enter some comments.');
    form.comment.focus();
    return false;
  }
  form.c.value='weriweurffu997e72hslw9f0';
  return true;
}

function checkEmail(email)
{
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) return true;
  alert('Your e-mail address appears to be invalid, please try again.');
  return false;
}

function HideComs(d)
{
  if (document.getElementById('comments_'+d).style.display=='none')
  {
    document.getElementById('comments_'+d).style.display='block';
    document.getElementById('comtxt_'+d).innerHTML='&laquo; Hide Comments';
  }    
  else
  {
    document.getElementById('comments_'+d).style.display='none';
    document.getElementById('comtxt_'+d).innerHTML='&raquo; Show Comments';
  }
}

function isURL(form, b1)
{
  if ((b1.value != '') && (b1.value.length >= 12))
  {
    form.pretestbutt.disabled = false;
  }
  else
  {
    form.pretestbutt.disabled = true;
  }
}

function validateurl(form) {

  if ((form.url.value == '') || (form.url.value.indexOf('http://') == -1) || (form.url.value.indexOf('.') == -1) || (form.url.value < 12))
  {
    alert('You must enter a valid URL');
    form.url.focus();
    form.url.select();
    return false;
  }
  else
  {
    if (form.url.value == '')
    {
      alert('You must enter a URL');
      form.url.focus();
      return true;
    }
    if (form.url.value != '') window.open(form.url.value);
  }
}

