﻿// JScript File

//var pageLoaded=false;

function CheckDomainAvailability(sld, tld, destID, check) {
    var destElement = document.getElementById(destID);
    var hidElement = document.getElementById(destID + '_hid');

    if (destElement && hidElement) {
        destElement.style.display = 'none';
        hidElement.style.display = '';
        
        var dojoRequest = dojo.io.bind({
	        url: '/Async/Async.aspx?checkname=true&sld=' + sld + '&tld=' + tld + '&check=' + check,
	        load: function(type, data, evt) { 
	                hidElement.style.display = 'none';
			        destElement.style.display = '';
			        destElement.innerHTML = data;
			    },
	        error: processCheckError,
	        mimeType: 'text/plain'
        });
    }
}

function processCheckError(type, error, http) { /* handle error */ }

function openWin(url, name, width, height) {
    openNew = window.open(url, name, 'width=' + width + ',height=' + height + ',resize=yes,resizable=yes,scroll=yes,scrollbars=yes,location=yes,toolbar=yes,menubar=yes,status=yes,left=20,top=20');
    openNew.focus();
}               

function addLoadEvent(func) {  
    var oldonload = window.onload;  
    if (typeof window.onload != 'function') {  
        window.onload = func;  
    } else {  
        window.onload = function() {  
            oldonload();  
            func();  
        }  
    }  
}  

function doneChecking() {    
		var frm = document.forms[0];
		var checked = false;
		for (var i = 0; i < frm.elements.length; i++) {
			var e = frm.elements[i];
			if (e.type == 'checkbox' && e.checked) {
				checked = true;
				break;
			}
		}		
		if (!checked) { alert('Select a domain to add to cart.'); }
		return checked;
    }
    
function popUp(url) 
{
    sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=560,height=400');
    self.name = "mainWin";
}

/*
	This script forces a form field to only accept text.
	Include this file in the head of the doc
	Example of usage: <INPUT NAME="dollar" SIZE=5 MAXLENGTH=5 onKeyPress="return numbersonly(this, event)">	
*/

function numbersonly(myfield, e, dec)
{
var key;
var keychar;
if (window.event)
 key = window.event.keyCode;
else if (e)
 key = e.which;
else
 return true;
keychar = String.fromCharCode(key);
// control keys
if ((key==null) || (key==0) || (key==8) || 
 (key==9) || (key==13) || (key==27) )
 return true;
// numbers
else if ((("0123456789").indexOf(keychar) > -1))
 return true;
// decimal point jump
else if (dec && (keychar == "."))
 {
 myfield.form.elements[dec].focus();
 return false;
 }
else
 return false;
}

function toggleAgreeText(txtDiv) {
    if (document.getElementById(txtDiv).style.display == 'none') {
        document.getElementById(txtDiv).style.display = '';
    } else {
        document.getElementById(txtDiv).style.display = 'none';
    }
}

function validate_delete(strMsg)
{
    var fRet; 
    fRet = confirm(strMsg);         
    return fRet;
}

function confirmCancel()
{
    return confirm("Are you sure you want to delete your WSC site and all files associated with it when your reach the end of your billing contract?");
}

function undoCancel()
{
    return confirm("Click OK to cancel deletion and continue this service. You will be billed normally on your next billing date.");
}

//var pageLoaded=false;

function clearText(elem) {
	if (document.getElementById(elem) != null && document.getElementById(elem).value.indexOf('...') > 0)
		document.getElementById(elem).value = "";
}
	
