<!--//
var agt=navigator.userAgent.toLowerCase();
var url;

function getURL(uri) {
   // Current Page Reference
   // copyright Stephen Chapman, 1st Jan 2005
   // you may copy this function but please keep the copyright notice with it

   uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
   uri.dom = uri.dir;
   if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
   uri.path = '';
   var pos = uri.dom.indexOf('\/');
   if (pos > -1) {
     uri.path = uri.dom.substr(pos+1);
     uri.dom = uri.dom.substr(0,pos);
   }

   uri.page = location.href.substring(uri.dir.length+1, location.href.length+1);
   pos = uri.page.indexOf('?');
   if (pos > -1) {
     uri.page = uri.page.substring(0, pos);
   }

   pos = uri.page.indexOf('#');
   if (pos > -1) {
     uri.page = uri.page.substring(0, pos);
   }

   uri.ext = '';
   pos = uri.page.indexOf('.');
   if (pos > -1) {
     uri.ext = uri.page.substring(pos+1);
     uri.page = uri.page.substr(0,pos);
   }

   uri.file = uri.page;
   if (uri.ext != '') uri.file += '.' + uri.ext;
   if (uri.file == '') uri.page = 'index';

   uri.args = location.search.substr(1).split("?");

  return uri;
}

var uri = new Object();
url = getURL(uri);

function getContent(screen, divname, urlname) {
  var ajax = new Ajax.Updater(
				divname,
				'controller.php',
				{
					option:		'Calling Using Ajax',
					parameters:	'screen=' + urlname  + screen,
					evalScripts: 	true, 
					contentType:	'application/x-www-form-urlencoded',
					asynchronous: 	true,
					encoding: 	'UTF-8',
					method:		'post'
				});

  return false;
}

function getComplete(tblField, text_input) {
        //getContent('lookup', 'auto_complete_div');
	var ajax = new Ajax.Autocompleter(
				text_input, 
				'auto_complete_div', 
				root + '/controller.php', 
				{
					parameters:	'screen=lookup&field=' + tblField,
				//	indicator:	Element.show('indicator'),
					asynchronous: 	true
				});
  return false;
}

function createPopUp(urlfile, title, wh) {
  window.open(urlfile, 'my_Customer_Report', "menubar=no,location=no,resizable=no,scrollbars=yes,status=no," + wh);
  return false;
}

function IsNumeric(strString) {  //  check for valid numeric strings	
   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++) {
     strChar = strString.charAt(i);
     if (strValidChars.indexOf(strChar) == -1) {
      blnResult = false;
     }
   }
   return blnResult;
}

function CheckEmail(fieldname) {
	var rejectedDomain = new Array();
	var index = 0;
	//rejectedDomain[index++]="hotmail"

	var rejected = false;
	var testresults = true;
	var str = fieldname.value;
	var filter=/^.+@.+\..{2,3}$/;
	if (filter.test(str)) {
		var tempstring = str.split("@");
		tempstring = tempstring[1].split(".");
		for (i=0; i<rejectedDomain.length; i++) {
			if (tempstring[0] == rejectedDomain[i]) {
			  rejected=true;
 			}
		}
		if (rejected) {
			var message = "Please input a more official email address!\n";
			message += "The following addresses are not allowed:\n";
			for (i=0; i<rejectedDomain.length; i++) {
				message += "\t" + rejectedDomain[i] + "\n";
			}
			validatePrompt(form.email, message);
			testresults = false;
		}
	} else {
		message="Please input a complete and valid email address!";
		//validatePrompt(fieldname, message);
		testresults = false;
	}
	return (testresults)
}

function validatePrompt(Ctrl, PromptStr) {
        var message = $("message");
	//alert(PromptStr);
        Ctrl.focus();
        message.innerHTML = PromptStr;
	return;
}

function QuickPopUp(objname) {
  if(Element.visible(objname)) {
   new Effect[false ? 'BlindUp' : 'BlindDown'](objname, {duration: .45});
  }
}

function cMTab(id) {
  var TBODY = $("Menu");
  var td = TBODY.getElementsByTagName("td");
  for(var x=0; x<td.length; x++) {
    if(id == x) {
     td[x].setAttribute("id", "active");
     $("item" + x).style.display = "Block";
    } else {
     td[x].setAttribute("id", "");
     td[x].setAttribute("class", "unActiveTab");
     $("item" + x).style.display = "None";
    } 
  }
}

function cgTab(id) {
  var Tabs = $("Tabs");
  var lis = Tabs.getElementsByTagName("li");
  for(var x=0; x<lis.length; x++) {
    var li = lis[x];
    if(id == x) {
      li.id = 'current';
      var ahref = li.getElementsByTagName("a");
      getContent('', 'centerdata', ahref[0].innerHTML.toLowerCase());
    } else {
      li.id = '';
    }
  }
}

function getFormContent(frmname) {
 var obj = $(frmname);
 var args = "&";

 for(var x=0; x<obj.elements.length; x++) {
  switch(obj.elements[x].type) {
    case "text":
    case "password":
    case "textarea":
    case "hidden":
    case "select-one":
     args += obj.elements[x].name + "=" + escape(obj.elements[x].value) + "&";
     break;
   case "checkbox":
   case "radio":
     if(obj.elements[x].checked) {
       args += obj.elements[x].name + "=1&"; 
     } else {
       args += obj.elements[x].name + "=0&"; 
     } 
    break;
   }
 }
  return args.slice(0, (args.length-1));
}

function getPopUp(name, args) {
 var obj = $(name);
 var arg = "&" + args;
 getContent(name + arg, 'popupFrame');

 dragWindow('popupContainer');
 showPopWin(name, 650, 400, true);
 return false;
}

function myWindowSize() {
  var myWidth = 0, myHeight = 0;
  var rs = new Array();

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && 
		( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  rs[0] = myWidth;
  rs[1] = myHeight;

  return rs;
}

function singup() {
  var data  = getFormContent("frmsignup");
  var obj = $("frmsignup");

 
  if(obj.txtmetaname.value == "") {
    alert("Please provide a meta name!");
  } else if(obj.txtmetatags.value == "") {
    alert("You must provide key word to be searched upon");
  } else if(obj.txttitle.value == "") {
    alert("You forgot to enter a title!");
  } else {
    getContent(data, 'centerdata', "signup");
  }


  return false;
}

function getLogin() {
  alert("This function is coming soon. Please excuse us!");
  return false;
}

function getLink(name) {
  getContent('', 'centerdata', name);
}

//-->
