function openWindow(page)
{
    var w = 1050;
    var h = 850;
    var win;
    if (page == "login")
    {
        win = window.open("https://www.bizUnlimited.com/bizUnlimitedWeb/Login.aspx", "bizUnlimited", "width=" + w + ", height=" + h + ", status=no, resizable=no, scrollbars=yes");   
        var output = "http://www.bizUnlimited.com/bizUnlimitedWeb/Login.aspx";
    }
    else
    {        
        win = window.open("https://www.bizUnlimited.com/bizUnlimitedWeb/registration/registrationDetails.aspx", "bizUnlimited", "width=" + w + ", height=" + h + ", status=no, resizable=no, scrollbars=yes");
        var output = "http://www.bizUnlimited.com/bizUnlimitedWeb/registration/registrationDetails.aspx";
    }
    
    var wleft = (screen.width - w) / 2;
    var wtop = (screen.height - h) / 2;
    //win.moveTo(wleft, wtop);
    win.focus();
}

    var badCol = '#CCFF66';

    var badGrpCol = '#CCFF66';

    var errorText = 'There was a problem with your request\n\nPlease fill in all fields correctly before submitting\n\
    The missing/incomplete fields have been highlighted for you'

        var debug = 0;

  function part2_validator(it){
        var el = it

        // Walk back up the DOM tree until we get to the table row
        while (el.parentNode){
                if (el.tagName.toUpperCase() == 'TR'){
                        // got the row, loop it and uncheck all the radios
                        // that aren't the one that triggered
                        var inputs = el.getElementsByTagName('INPUT');
                        for (var i=0; i<inputs.length; i++){
                                // make sure it's a radio button
                                if (inputs[i].type.toLowerCase() == 'radio'){
                                        // uncheck if it isn't the triggering element
                                        if (inputs[i] != it) inputs[i].checked = false;
                                }
                        }
                        // break out of the while loop
                        break;
                }else{
                        // move up the DOM one level and continue to loop
                        el = el.parentNode
                }
        }
  }
// (c) 2003-2005 Adestra Ltd.
// dan@adestra.com
// Do not reproduce without the permission of the author
// 
var groups = new Object();
var debugTxt = '';
function validateForm(it){
	debugTxt = '';
	var bad = 0;
	for (i in groups){
		groups[i] = 0;
	}
	var els = it.getElementsByTagName('*');
	for (var i=0; i<els.length; i++){
		
		var loopbad = 0;
		var el = els[i];
		//if (el.getAttribute('validate')){alert(el.getAttribute('validate'))}
		if (el.getAttribute('validate') == 'notempty' && (el.value == '' || el.value == ' ')){
			loopbad = 1;
		}else if (el.getAttribute('validate') == 'email' && !el.value.match(/^[\w\d\.\_\-\']+@[\w\d\.\-]+\.[\w]+$/)){
			loopbad = 1;
		}else if (el.getAttribute('validate') == 'custom' && !el.value.match(el.getAttribute('regexp'))){
			loopbad = 1;
		}else if (el.getAttribute('validate') == 'checkbox' && !el.checked){
			loopbad = 1;
		}else{
			if (el.getAttribute('validate')){
				debugTxt += 'The validation type: '+ el.getAttribute('validate') +' is unknown (for element: '+ el.name +')\n'
			}
			markGood(el);
		}
		if (el.getAttribute('group') && loopbad == 1){
			if (groups[el.getAttribute('group')] == 1){
				loopbad = 0;
				markGood(el)
			}else{
				markBad(el);
			}
		}
		if (loopbad == 1 && !el.getAttribute('group')){
			markBad(el)
			bad =1;
		}
	}
	for (i in groups){
		if (groups[i] == 0){
			bad = 1;
		}
	}

	if (debug == 1){
		if (debugTxt != ''){
			alert('DEBUG OUTPUT\n\n'+debugTxt);
		}else{
			alert('DEBUG MODE IS ON\nRemember to disable it before releasing to the wild ;)')
		}
	}						
	if (bad == 1){
		alert(errorText);
		return false;
	}
}
function markBad(el){
	if (el.getAttribute('group')){
		if (groups[el.getAttribute('group')] != 1){
			groups[el.getAttribute('group')] = 0;
		}
		if (document.getElementById(el.getAttribute('group'))){
			document.getElementById(el.getAttribute('group')).style.backgroundColor = badGrpCol
		}else{
			debugTxt += 'You need a container element for the group: '+ el.getAttribute('group') +' (for element: '+ el.name +')\n';
		}
	}else{
		el.style.backgroundColor = badCol;
	}
}
function markGood(el){

	if (el.getAttribute('group')){
		groups[el.getAttribute('group')] = 1;
		if (document.getElementById(el.getAttribute('group'))){
			document.getElementById(el.getAttribute('group'));
		}else{
			debugTxt += 'You need a container element for the group: '+ el.getAttribute('group') +' (for element: '+ el.name +')\n';
		}
	}
}
