function Validate(frm){
	var returnValue = false;
	if( frm.user.value.replace(/(^\s+)|(\s+$)/g, '').length < 2 ){
			alert("Please enter your User Name.");
    	frm.user.focus();
	} else if( frm.pass.value.replace(/(^\s+)|(\s+$)/g, '').length < 2 ){
    	alert("Please enter a your Password.");
    	frm.pass.focus();
  } else {
  		returnValue = true;
  }
  return returnValue;
}

function goto(val) {
	window.location.href=val;
}

function checkall(form, match) {
 	var re = new RegExp(match);
	for(var x=0;x<((c = document.forms[form].elements).length);x++){
		if(c[x].type=='checkbox' && re.test(c[x].id))
			c[x].checked=true;
	}
}

function uncheckall(form, match) {
 	var re = new RegExp(match);
	for(var x=0;x<((c = document.forms[form].elements).length);x++){
		if(c[x].type=='checkbox' && re.test(c[x].id))
			c[x].checked=false;
	}
}

function conf(item,yeslink,extra) {
	var str = '';
	if(extra!=null)
		str = extra;

	Dialog.confirm("Are you sure you want to delete this "+item+"?<br />"+str, {
		windowParameters: {className:"alphacube",width:400},
		okLabel: "Yes",
        buttonClass: "button",
       	cancel:function(win) {return true;},
    	ok:function(win) {window.location.href=yeslink; return true;}
	});
}

function info(message) {
	Dialog.alert(message, {
		windowParameters: {className:"alphacube_msg",width:400},
		okLabel: "Close",
        buttonClass: "button",
    	ok:function(win) {return true;}
	});
}

function error(message) {
	Dialog.alert(message, {
		windowParameters: {className:"alphacube_error",width:400},
		okLabel: "Close",
        buttonClass: "button",
    	ok:function(win) {return true;}
	});
}
function specialflag(prop) {
	if(prop==99){
		document.getElementById('flagblock').style.display = 'block';
	} else {
		document.getElementById('flagblock').style.display = 'none';
	}
}

function toggler(e,target,other) {
	if(e.checked==true){
		document.getElementById(target).style.display = 'block';
		document.getElementById(other).style.display = 'none';
	}
}

function show_hide(e,target) {
	if(e.checked==true){
		document.getElementById(target).style.display = 'block';
		Windows.focusedWindow.updateHeight();
	}else{
		document.getElementById(target).style.display = 'none';
	}	
}

function openpopwide(thelink) {
    window.open(thelink,"","resizable=yes,scrollbars=yes,width=800,height=500,status=no");
}

function openpop(thelink) {
    window.open(thelink,"","resizable=yes,scrollbars=yes,width=500,height=500,status=no");
}

/* tracker */
function monthly(id,year,month) {
	window.open("report.php?op=monthly&ID="+id+"&year="+year+"&month="+month,"windoze","resizable=no,scrollbars=no,width=740,height=400,status=no");
}

function cmonthly(id,year,month) {
	window.open("report.php?op=cmonthly&ID="+id+"&year="+year+"&month="+month,"windoze","resizable=no,scrollbars=no,width=740,height=400,status=no");
}

function yearly(id,year) {
	window.open("report.php?op=yearly&ID="+id+"&year="+year,"windoze","resizable=no,scrollbars=no,width=740,height=400,status=no");
}

function cyearly(id,year) {
	window.open("report.php?op=cyearly&ID="+id+"&year="+year,"windoze","resizable=no,scrollbars=no,width=740,height=400,status=no");
}

function openexport(thelink) {
    window.open(thelink,"windoze","resizable=yes,scrollbars=yes,width=500,height=500,status=no");
}
/* end tracker */

function closeit(what) {
    document.getElementById('messages').style.display = 'none';
}

function revertback(what,thelink) {
    document.getElementById('editme1_'+what).innerHTML = thelink;
}

/* admin */
function pickimage() {
    window.open('picker.php',"windoze","resizable=yes,scrollbars=yes,width=500,height=500,status=no");
}

/* mcc */
function viewimages(id, type)
{
	if(type==undefined)
		type=1;
	if(parseInt(id)==id)
		window.open("pop.php?ID="+id+"&type="+type,"","resizeable=yes,width=500,height=500,status=no,scrollbars=yes");
	else
		alert('Invalid client id:'+id+'. Please make sure you have a property selected.');
}

function view_venues(list, item){
    window.open("mcc_popup.php?op=venues&ID="+list+"&rssid="+item,"","resizeable=yes,scrollbars=yes,width=720,height=600,status=no");
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function checklanguagegroups(e, tree)
{
	var i;
	var j;
	var k;
	var boxes;
	var lang;
	lang=tree.getElementsByTagName('ul');
	for(j=0; j<lang.length; j++)
	{
		boxes=lang[j].getElementsByTagName('input');
		if(e.checked)
		{
			for(i=0; i<boxes.length; i++)
			{
				if(boxes[i].className.length>0 && boxes[i].className!=e.className)
						boxes[i].checked=false;
				else
					if(boxes[i]==e||((e.className.length>0)&&(e.className==boxes[i].className)))
					{
						for(k=0; k<boxes.length; k++)
							if(boxes[k].checked&&(boxes[k]!=boxes[i]))
							{
								boxes[k].checked=false;
								checklanguagegroups(boxes[k], tree);
							}
						boxes[i].checked=true;
					}
			}
		}
		else
			if(e.className.length>0)
				for(i=0; i<boxes.length; i++)
					if(boxes[i].className==e.className)
						boxes[i].checked=false;
	}
}
