var oInterval = window.setInterval("words_counter()",15000);

function words_counter()  {
	
	var str1 = parseInt(Math.random()*100) + 100;
	var str2 = parseInt(Math.random()*100) + 100;
	var str3 = parseInt(Math.random()*100) + 100;

	var query = "?a="+str1+"&b="+str2+"&c="+str3;

	//document.getElementById("mycounter").disabled=true;

  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
	    document.getElementById("mycounter").value=xmlHttp.responseText;
        }
      }
    xmlHttp.open("GET","get_count_ajax.php"+query,true);
    xmlHttp.send(null);
}

function check_user()  {
	

	var str1 = parseInt(Math.random()*100) + 100;
	var str2 = parseInt(Math.random()*100) + 100;
	var str3 = parseInt(Math.random()*100) + 100;
	
	var user = document.getElementById("rusername").value;
	
	var query = "?user="+user+"&a="+str1+"&b="+str2+"&c="+str3;
	
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari, IE7
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // < IE 7
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {	 
	    document.getElementById("user_check").value=xmlHttp.responseText;
        }
      }
    xmlHttp.open("GET","check_user.php"+query,true);
    xmlHttp.send(null);


}

function show_menu(menu) {

	//document.getElementById('"+eval(menu)+"').style.display = 'block';
	eval('document.getElementById("'+menu+'").style.display = "block"');


}

function pagejump(page) {

	document.location.replace(page+'.php');
}

function site_help(topic) {

	var s = '';

	var t = "inc/inc_admin_help.php?topic="+topic+"#"+topic;
	var w = "650";
	var h = "300";

	var w = window.open(t,"site_help","width="+w+",height="+h+",scrollbars"+s);

}

function check_this(obj) {

	//process ids store in ids field
	var ids = eval("document.getElementById('"+obj.value+"').ids.value");

	ids = ids.substring(1);

	ids = ids.split(":");

	for (var i = 0;i<ids.length;i++) {

		var ch = eval("document.getElementById('"+obj.value+"').private" + ids[i]);

		if (obj.checked) {
			ch.checked = true;
			ch.value = 'N';
		} else {
			ch.checked = false;
			ch.value = 'Y';
		}
	}
}



function table_mouseover(obj, ncolor) {

	obj.style.backgroundColor = ncolor ;

}



function table_mouseout(obj, ncolor) {

	obj.style.backgroundColor = ncolor;

}

function verify (frmobj) {

	var empty_fields = "";
	var invalid_email_txt = "";
	var msg = "";

	els = frmobj.verify_fields.value.split(",");

	for (var i = 0; i < els.length; i++) {
		var e = eval("frmobj."+els[i]);
//   		alert('type ' + e.type + '!\n Name = ' + e.name + '!\nvalue = ' +e.value+'!');

		if ((e.type == "text") || (e.type == "textarea") || (e.type == "file") || (e.type == "password")) {
			if (e.name.indexOf("email") >= 0) {
				if (!valid_email(e.value)) {
					if (!isblank(e.value))
						invalid_email_txt = e.value + " appears to be invalid!";
				}
			}

			if ((e.value == null) || (e.value == "") || isblank(e.value)) {

				if ((e.name == null) || (e.name == "")) e.name = e.id;
				empty_fields += "\n     " + e.name;

				continue;
			}
		}
	}


if (!empty_fields && !invalid_email_txt )
	return true;

msg =  "______________________________________________________  \n\n";
msg += "The form was not submitted because of the following error(s).\n";
msg += "Please correct them and resubmit the form.\n";
msg += "______________________________________________________  \n\n";




if (empty_fields)	{

	if (!invalid_email_txt)
		msg += "\n\n";

	msg += " The following required fields are empty:\n" + empty_fields + '\n';

}

if (invalid_email_txt)
	msg += '\n\n' + invalid_email_txt;


alert(msg);

return false;

}

function isblank(s) {

	for (var i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n' ) && (c != '\t')) return false;
	}
	return true;

}
function valid_hex(hex) {
alert(hex);
  // check a hex value
  if (hex.match('[a-fA-F0-9]'))
    return true;
 else
    return false;

}

function valid_email(email) {

	//check an email address is possibly valid
  	if (email.match('^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$'))
  
  if (j.test(email.value)) 
    return true;
 else
    return false;

}


function pop_this(type, extra) {

	var s = '';

	switch (type) {
		case 'debug':
			var t = "debugwindow.php?error="+extra;
			var w = "400";
			var h = "200";
			break;

		case 'basicflash':
			var t = "flash/flash_basic.html";
			var w = "400";
			var h = "80";
			break;

		case 'enhancedflash':
			var t = "flash/flash_enhanced.html";
			var w = "420";
			var h = "80";
			break;

		case 'requestdetails':
			var t = "pop/pop_req_dets.php";
			var w = "400";
			var h = "200";
			s = ",scrollbars";
			break;

	}


	var w = window.open(t,"pop_this","width="+w+",height="+h+",menubar=no,resizable=no"+s);

}


