﻿<!-- begin hiding from old browsers
// opens new window centered. If users clicks off and clicks back in it comes back instead
// of staying hidden
var myWindow = null;
var curWindow = null;

// toggles fields to enabled or disabled
function toggleEnable(whichObj) {
	whichObj.disabled = !(whichObj.disabled);
	var z = (whichObj.disabled) ? 'disabled' : 'enabled';
// 	alert(whichObj.type + ' now ' + z);
}

function extraCheck(whichObj) {
	return !whichObj.disabled;
}

function openWindow(theURL,winName,features, myWidth, myHeight) {
	var screen_w = screen.width;
	var screen_h = screen.height;
	var xpos = (screen_w - myWidth) / 2;
	var ypos = (screen_h - myHeight) / 2;
	var position = "width=" + myWidth + ",height=" + myHeight + ",screenX=" + xpos + ",screenY=" + ypos + ",left=" + xpos + ",top=" + ypos;

    if (features == "") {
        features = position;
    } else {
        features = features + "," + position;
    }

	if (curWindow == "EndoCam" && curWindow != null) {
		myWindow.close();
	}
	
	if (myWindow != null && !myWindow.closed) {
		if (winName == curWindow) {
			myWindow.focus();
		} else {
			myWindow.close();
		}
	}
	if (winName != curWindow || myWindow.closed) {
		myWindow = window.open(theURL,winName,features);
	}
	curWindow = winName;
}


// makes the counter down for textarea fields
function counterTextArea(textField, counterField, limitTextField) {
	if (textField.value.length > limitTextField) {
		textField.value = textField.value.substring(0, limitTextField);
	} else {
		counterField.value = limitTextField - textField.value.length;
	}
}

// checks if the fields has a value
function emptyField(textObj) {
	if (textObj.value.length==0) return true;
	for(var i=0; i<textObj.value.length; i++)
	{
		var ch=textObj.value.charAt(i);
		if (ch != ' ' && ch != '\t') return false;
	}
	return true;
}

// validates the email field parameter is formobject.value
function validEmail(email) {
	var index;
	
	if (email == "") {
		return true;
	}

    var emailReg = /^([\w-\+]+(?:\.[\w-\+]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    var regex = new RegExp(emailReg);
    return regex.test(email);	
}

// Makes a block of html become visible or invisible adjusting it on the page
function blocking(nr)
{
	if (document.layers)
	{
		alert("in layers");
		current = (document.layers[nr].display == 'none') ? 'block' : 'none';
		document.layers[nr].display = current;
	}
	else if (document.all)
	{
		alert("in document.all");
		current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
		document.all[nr].style.display = current;
	}
	else if (document.getElementById)
	{
		alert("in getElementByID");
		vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}
// created by Brenner to mask email to avoid spiders to get emails for spam from our site
function antiSpamEmail(userName, domain, classToUse) {
	var emailToDisplay = (userName + "@" + domain);
	if (classToUse == "") {
		document.write('<a href="mailto:' + emailToDisplay + '">' + emailToDisplay + '</a>');
	} else {
		document.write('<a class="' + classToUse + '" href="mailto:' + emailToDisplay + '">' + emailToDisplay + '</a>');
	}
}
function checkDomain(nname)
{
var arr = new Array(
'.com','.net','.org','.biz','.coop','.info','.museum','.name',
'.pro','.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag',
'.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw',
'.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm',
'.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc',
'.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr',
'.cu','.cv','.cx','.cy','.cz','.de','.dj','.dk','.dm','.do','.dz',
'.ec','.ee','.eg','.eh','.er','.es','.et','.fi','.fj','.fk','.fm',
'.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm',
'.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy','.hk','.hm',
'.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq',
'.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li',
'.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg',
'.mh','.mk','.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt',
'.mu','.mv','.mw','.mx','.my','.mz','.na','.nc','.ne','.nf','.ng',
'.ni','.nl','.no','.np','.nr','.nu','.nz','.om','.pa','.pe','.pf',
'.pg','.ph','.pk','.pl','.pm','.pn','.pr','.ps','.pt','.pw','.py',
'.qa','.re','.ro','.rw','.ru','.sa','.sb','.sc','.sd','.se','.sg',
'.sh','.si','.sj','.sk','.sl','.sm','.sn','.so','.sr','.st','.sv',
'.sy','.sz','.tc','.td','.tf','.tg','.th','.tj','.tk','.tm','.tn',
'.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug','.uk','.um',
'.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu','.ws',
'.wf','.ye','.yt','.yu','.za','.zm','.zw');

var mai = nname;
var val = true;

var dot = mai.lastIndexOf(".");
var dname = mai.substring(0,dot);
var ext = mai.substring(dot,mai.length);
//alert(ext);
	
if(dot>2 && dot<57)
{
	for(var i=0; i<arr.length; i++)
	{
	  if(ext == arr[i])
	  {
	 	val = true;
		break;
	  }	
	  else
	  {
	 	val = false;
	  }
	}
	if(val == false)
	{
	  	 alert("Your domain extension "+ext+" is not correct");
		 return false;
	}
	else
	{
		for(var j=0; j<dname.length; j++)
		{
		  var dh = dname.charAt(j);
		  var hh = dh.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || hh==45 || hh==46)
		  {
			 if((j==0 || j==dname.length-1) && hh == 45)	
		  	 {
		 	  	 alert("Domain name should not begin are end with '-'");
			      return false;
		 	 }
		  }
		else	{
		  	 alert("Your domain name should not have special characters");
			 return false;
		  }
		}
	}
}
else
{
 alert("Your Domain name is too short/long");
 return false;
}	

return true;
}
// -->
