var rules = {	
	 
	'#province' : function(e1) {
		e1.onchange = function() { 
			$('city').style.display = 'none'; 
			$('startval').style.display = 'none'; 
			$('loadstatus').innerHTML = 'Loading cities...';
			for (i=0;i<this.options.length;i++) {
				if (this.options[i].selected == true) {
					var myajax = new Ajax.Updater(
						'city',
						'loadcities.php?id=' + this.options[i].value,
						{ 
							method: 'get', 
							onComplete: function() { 
								$('loadstatus').innerHTML = ''; 
								$('city').style.display = 'block';
							}, 
							evalScripts: true
						});
					} //end if 
				} //end for
			} //end func
		},  //end func
	 
	
}; 
Behaviour.register(rules);

redirect = function(url) {
	window.location.href = url;
}

showLoader = function() {
	$('loader').innerHTML = '(Updating...)';
}

hideLoader = function() {
	$('loader').innerHTML = '';
}

function getX(evt) {
     if (document.all) { return (evt.clientX); }
     return (evt.layerX);
}
function getY(evt) {
     if (document.all) { return (evt.clientY); }
     return (evt.layerY);
}
function getScrollX() {
     if (document.all) { return (document.body.scrollLeft); }
     return (window.pageXOffset);
}
function getScrollY() {
     if (document.all) { return (document.body.scrollTop); }
     return (window.pageYOffset);
}
function showValues(e) {
      var posx = 0;
      var posy = 0;
      posx= getX(e) + getScrollX();
      posy= getY(e) + getScrollY();
	  $('iteminfo').style.left = posx+10 + 'px';
	  //alert(navigator.appName);
	  if (navigator.appName == "Microsoft Internet Explorer")
	  	  $('iteminfo').style.top = posy  + 'px';
	  else
	  	$('iteminfo').style.top = getY(e)  + 'px';
}

function showValues2(e) {
      var posx = 0;
      var posy = 0;
      posx= getX(e) + getScrollX();
      posy= getY(e) + getScrollY();
	  $('shippinginfo').style.left = posx+10 + 'px';
	  if (navigator.appName == "Microsoft Internet Explorer")
	  	$('shippinginfo').style.top = posy  + 'px';
	  else
	  	$('shippinginfo').style.top = getY(e)  + 'px';
}

displayinfo = function(id) {
	var pars = "pid=" + id;
	$('iteminfo').style.display = 'block';
	var myajax = new Ajax.Updater(
		'iteminfo',
		'viewproducttext.php',
		{		
			method: 'get',
			parameters: pars,
			evalScripts: true
		});	
}
  
isNumberKey = function(evt)
{
	evt = ( evt ) ? evt : window.event;
	var charCode = ( evt.which ) ? evt.which : evt.keyCode;
	if (charCode == 8)
	{	
		if (parseInt(this.value) <= 9)
		{
			this.value = '1';
			return false;
		}		
	}
	
	if (charCode == 13) return false;

	return (charCode <= 31 || (charCode >= 48 && charCode <= 57));
}

LoadResume = function (x) 
{
	appData = window.open ("applicant-resume.php?ID=" + x, "appData","resizable=0,status=1,scrollbars=1,height='100%', width=800");
	appData.moveTo(0,0);
	if (window.focus) {
		appData.focus()
	} 
}

LoadScheduler = function(hgt, wdt, url) {
	var winSked = null; 
	var dimension = "height=" + hgt + ", width=" + wdt + ","
	var location = "top=" + (screen.height - hgt)/2 + ",left=" + (screen.width - wdt)/2
	winSked = window.open (url, "_blank", "scrollbars=0, " +  dimension + location);
	winSked.focus();
}

LoadSchedulerWin = function(hgt, wdt, url, win) {
	var winSked = null; 
	var dimension = "height=" + hgt + ", width=" + wdt + ","
	var location = "top=" + (screen.height - hgt)/2 + ",left=" + (screen.width - wdt)/2
	winSked = window.open (url, win, "scrollbars=0, " +  dimension + location);
	winSked.focus();
}
