function Is() {
    var agent = navigator.userAgent.toLowerCase();
    var version = parseInt(navigator.appVersion);
    this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
    this.ns4 = (this.ns && (version >= 4));
    this.ie = (agent.indexOf("msie") != -1);
    this.ie3 = (this.ie && (version == 2));
    this.ie4 = (this.ie && (version >= 4));
    this.mac = (agent.indexOf("mac")!=-1);
}
var is = new Is();

function preload() {
    this.length = preload.arguments.length;
    for (var i = 0; i < this.length; i++) {
        this[i+1] = new Image();
        this[i+1].src = preload.arguments[i];
    }
}

function imgOn(i) {
    if (is.ie3) {} else {
        var src = document.images[i].src;
        var off = src.lastIndexOf("-off");
        if (off != -1) {
            var newsrc = src.substring(0,off) + "-on" + src.substring(off + 4, src.length);
            document.images[i].src = newsrc;
        }
    }
}

function imgOff(i) {
    if (is.ie3) {} else {
        var src = document.images[i].src;
        var on = src.lastIndexOf("-on");
        if (on != -1) {
            var newsrc = src.substring(0,on) + "-off" + src.substring(on + 3, src.length);
            document.images[i].src = newsrc;
        }
    }
}

function imgSwap(i,j) {
    if (is.ie3) {} else {
        var src = document.images[i].src;
        var hyp = src.lastIndexOf("-");
        var nam = src.substring(0,hyp);
        var dot = src.lastIndexOf(".");
        var ext = src.substring(dot, src.length);
        if (ext != -1) {
            var newsrc = nam + "-" + j + ext;
            document.images[i].src = newsrc;
        }
    }
}

function opWin(url,nam,w,h,sb) {
    specs = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no," +
            "scrollbars=" + sb + ",width=" + w + ",height=" + h;
    window.open(url,nam,specs);
}

function opWinStatus(url,nam,w,h,sb) {
    specs = "toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,copyhistory=no," +
            "scrollbars=" + sb + ",width=" + w + ",height=" + h;
    window.open(url,nam,specs);
}

function reloc(obj) {
    var i = obj.selectedIndex
    if (i != 0) {
        document.location.href = obj.options[i].value
    }
}

function validateForm(form, fields, names) {
	for (var i=0; i<fields.length; i++) {
		var field = form.elements[fields[i]];
		if ( (field.type == "select-one" && field.selectedIndex == "0") || ((field.type == "text" || field.type == "password")&& field.value == "" ) ){
			alert("You have not entered anything for the required field: \r\r" + names[i] + ".\r\rPlease try again.");
			return false;

		}

	}
	return true;
}

function validatePassword(form, pwd1, pwd2) {
	if (form.elements[pwd1].value == form.elements[pwd2].value){
		if (form.elements[pwd1].value.length >= 6){
			return true;
		}else {
			alert('Password must be at least 6 character long');
		}
	}else {
		alert('Password and Confirm password are different.\r\rPlease try again.');
	}
	return false;
}

function submitForm(form) {
	alert(form.country.value());
	return false;

}

function submitRegForm(element) {
        
        var form = element.form
	if (element.value.length > 0){		
                form.anchor.value=element.name;
		form.submit();
	}


}

function submitLinkNumber(page) {
    document.domainListForm.page.value=page;
    document.domainListForm.submit();

}

function checkAll(form) {
    for( var i = 0; i < form.elements.length;i++) {
        form.elements[i].checked = true;
    }
}

function disableButton(button) {
    button.disabled=true;
    return true;
}

var checkflag = "true";
function check(form) {
    if (checkflag == "false") {
        for (var i = 0; i < form.elements.length; i++) {
            if (form.elements[i].type == "checkbox") {
                form.elements[i].checked = true;
            }
        }
        checkflag = "true";
        return "Uncheck All"; 
    }else {
        for (i = 0; i < form.elements.length; i++) {
            if (form.elements[i].type == "checkbox") {
                form.elements[i].checked = false; 
            }
        }
        checkflag = "false";
        return "Check All";
    }
}

function disableSubmitButtons(form) {
        for (var i = 0; i < form.elements.length; i++) {
            if (form.elements[i].type == "submit") {
                form.elements[i].disabled = true;
            }
            
        }
}

function goTo(anchor) {
    window.location.hash = anchor;
}

function refreshPage(type){
    var a = window.top.location.protocol+"//"+window.top.location.host+window.top.location.pathname;
    if (type!=null) {
        window.top.location.href= a+"?a="+type;
    }else {
        window.top.location.href=a;
    }
}

function uncheckExt() {
    
    document.searchDomainsForm.extensions[0].checked=false;
    document.searchDomainsForm.extensions[1].checked=false;
    document.searchDomainsForm.extensions[2].checked=false;
    document.searchDomainsForm.extensions[3].checked=false;
    document.searchDomainsForm.extensions[4].checked=false;
    document.searchDomainsForm.extensions[5].checked=false;
}

/* 
Methods for resizing the flash stage at runtime.

setFlashWidth(divid, newW)
divid: id of the div containing the flash movie.
newW: new width for flash movie

setFlashWidth(divid, newH)
divid: id of the div containing the flash movie.
newH: new height for flash movie

setFlashSize(divid, newW, newH)
divid: id of the div containing the flash movie.
newW: new width for flash movie
newH: new height for flash movie

canResizeFlash()
returns true if browser supports resizing flash, false if not. 
*/
function setFlashWidth(divid, newW){
	document.getElementById(divid).style.width = newW+"px";
}
function setFlashHeight(divid, newH){
	document.getElementById(divid).style.height = newH+"px";		
}
function setFlashSize(divid, newW, newH){
	setFlashWidth(divid, newW);
	setFlashHeight(divid, newH);
}
function canResizeFlash(){
	var ua = navigator.userAgent.toLowerCase();
	var opera = ua.indexOf("opera");
	if( document.getElementById ){
		if(opera == -1) return true;
		else if(parseInt(ua.substr(opera+6, 1)) >= 7) return true;
	}
	return false;
}



