function openLink(link, width, height)
{
	if(!width) width = 917;
	if(!height) height = 606;
	
	var playerwin=window.open(link,"playerwin", "width="+width+",height="+height+",resizable=0,top=0,left=0");
}     


function validate(frm) 
{	
	var inputFields = new Array("el_name", "var_fld_contacts_email", "var_fld_contacts_phone", "var_fld_contacts_fax", "var_fld_contacts_address", "el_desc");
	var counter;
	var name;
	var msg = "Please complete the following fields:\n";
	var badFields = "";
	for (counter = 0; counter < inputFields.length; counter++) {
		name = inputFields[counter];		
		if (document.getElementById(name).value.length == 0) {
			if (name == "var_fld_contacts_email") {
				badFields = badFields + "  - email \n";
			} else {
				badFields = badFields + "  - " + name + "\n";
			}
		}
	}
	
	if (badFields.length != 0) {
		alert(msg + badFields);
		return false;
	}
	if (document.getElementById('var_fld_contacts_email').value.length > 0) {
		return emailCheck(document.getElementById('var_fld_contacts_email').value);
	} else {
		return true;
	}
}

function emailCheck(emailStr) {
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) {
		alert("Email address seems incorrect (check @ and .'s)");
		return false;
	}

	var user=matchArray[1];
	var domain=matchArray[2];

	if (user.match(userPat)==null) {
			alert("The username doesn't seem to be valid.");
		return false;
	}

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				alert("Destination IP address is invalid!");
			return false;
			}
			}
			return true;
	}

	var domainArray=domain.match(domainPat);
	if (domainArray==null) {
		alert("The domain name doesn't seem to be valid.");
			return false;
	}

	var atomPat=new RegExp(atom,"g");
	var domArr=domain.match(atomPat);
	var len=domArr.length;
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
	   alert("The address must end in a three-letter domain, or two letter country.");
		return false;
	}

	if (len<2) {
		var errStr="This address is missing a hostname!";
		alert(errStr);
	return false;
	}

	return true;
}

function handleFocus(o, title)
{
	if(trim(o.value) == title) o.value = '';
}

function handleBlur(o, title)
{
	if(trim(o.value) == '') o.value = '  ' + title;
}

function trim(string)
{
	return string.replace(/(^\s+)|(\s+$)/g, "");
}

function selectText(o)
{
	o.select();
	var therange = o.createTextRange()
	therange.execCommand("Copy")
}

var opened = 0;
var lastopened = 0;

function m_on(num)
{
	if(lastopened > 0 && lastopened != num) 
	{		
		realm_off(lastopened);
	}
	opened = num;	
	lastopened = num;
	var m = document.getElementById('menu-sub'+num);
	m.style.visibility = 'visible';
}

function m_off(num)
{	
	opened = 0;
	setTimeout('realm_off('+num+')', 200);	
}

function realm_off(num)
{
	if(opened > 0 ) return;
	var m = document.getElementById('menu-sub'+num);
	m.style.visibility = 'hidden';    
	lastopened = 0;
}

var msubOpened = false;
var lastName = '';
var lastStyleName = '';

function on_msub(name)
{
	if(lastName!='') do_out_msub(lastName);
	lastName = name;
	msubOpened = true;
	
	objOn(document.getElementById(name));

	divConteiner = document.getElementById(name+'_img');
	lastStyleName = divConteiner.src;
	if(lastStyleName.substr(lastStyleName.length-5,1)!='1') divConteiner.src = lastStyleName.substr(0,lastStyleName.length-5)+'1.gif';
	
}

function out_msub(name)
{
	msubOpened = false;
	setTimeout('do_out_msub("'+name+'","'+lastStyleName+'")',800);
}

function do_out_msub(name)
{
	
	if(msubOpened == false)
	{
		objOff(document.getElementById(name));
		/*
		divConteiner = document.getElementById('cont_'+name);
		if(arguments.length>1) divConteiner.className = arguments[1];
		else divConteiner.className = lastStyleName;
		*/
		divConteiner = document.getElementById(name+'_img');
		if(arguments.length>1) divConteiner.src = arguments[1];
		else if(lastStyleName!='') divConteiner.src = lastStyleName;
	}
}


function objOn(obj)
{
	obj.style.display = "block";
	obj.style.visibility = "visible";
}	

function objOff(obj)
{
	obj.style.visibility = "hidden";
	obj.style.display = "none";
}