var days = new Array();
days[0] = "Sunday";
days[1] = "Monday";
days[2] = "Tuesday";
days[3] = "Wednesday";
days[4] = "Thursday";
days[5] = "Friday";
days[6] = "Saturday";

var months = new Array();
months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";

function GetSystemDate()
	{
	var now = new Date();
	document.write(days[now.getDay()] + ", " + months[now.getMonth()] + " " + now.getDate() + " " + now.getFullYear());
	}

function BookmarkPage()
	{
	var title = document.title;
	var url = this.location;
	if (window.sidebar)   //firefox
		{
		window.sidebar.addPanel(title, url, "");
		}
	else if(document.all) //msie
		{
		window.external.AddFavorite(url, title)
		}
	else
		{
		alert("Your browser doesn't support this function.");
		}
	}

function targetBlank()
	{
	var links = document.getElementsByTagName("a");
	if (links && links.length > 0)
		{
		for (var l = 0; l < links.length; l++)
			{
			var link = links[l];
			if (link.href.indexOf("shoppingcable.com") != -1)
				{
				if (link.href.indexOf(".html") == -1)
					{
					link.setAttribute("target", "_blank");
					}
				}
			else
				{
				link.setAttribute("target", "_blank");
				}
			}
		}
	}

function GetFlash()
	{	
	var bannerSwf = "images/linkweb.swf";
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab##version=6,0,29,0" width="800" height="170">' +
			       '<param name="movie" value="' + bannerSwf + '">' +
				   '<param name="quality" value="high">' +
				   '<param name="wmode" value="transparent">' +
				   '<embed src="' + bannerSwf + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="800" height="170" wmode="transparent"></embed>' +
				   '</object>');
	}

function AllowDigits(obj,e,allowDecimal,allowNegative)
	{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;		
	if(window.event)
		{
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
		}
	else if(e.which)
		{
		key = e.which;
		isCtrl = e.ctrlKey;
		}
	if(isNaN(key)) return true;	
	keychar = String.fromCharCode(key);	
	if(key == 8 || isCtrl)
		{
		return true;
		}								
	if(obj.name.substring(0,2) == 'rc' || obj.name.substring(obj.name.indexOf('_') + 1,obj.name.indexOf('_') + 3) == 'rc')
		reg = /[0|1]/;
	else
		reg = /\d/;	
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;	
	return isFirstN || isFirstD || reg.test(keychar);
	}

function AllowAlphaNumeric(obj,e,allowDecimal,allowNegative)
	{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;		
	if(window.event)
		{
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
		}
	else if(e.which)
		{
		key = e.which;
		isCtrl = e.ctrlKey;
		}	
	if(isNaN(key)) return true;	
	keychar = String.fromCharCode(key);	
	if(key == 8 || isCtrl)
		{
		return true;
		}
	reg = /[A-Za-z0-9+-?!@#$%&*().:;,\\\r ]/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;	
	return isFirstN || isFirstD || reg.test(keychar);
	}



/**************************************************************************************************************
*
* Validation - Administration
*
***************************************************************************************************************/
function validateActionForm(this_ctrl)
		{
		var ctrl_value = this_ctrl.value;
		if(ctrl_value == 0) return false;
		if(ctrl_value == 1) this_action = 'WARNING!!!\n\nThis operation will place job position in Top Jobs.\nDo you want to proceed?';
		if(ctrl_value == 2) this_action = 'WARNING!!!\n\nThis operation will remove job position from Top Jobs.\nDo you want to proceed?';		
		if(ctrl_value == 3) this_action = 'WARNING!!!\n\nThis operation will place job position in History.\nDo you want to proceed?';
		if(ctrl_value == 4) this_action = 'WARNING!!!\n\nThis operation will activate job position.\nDo you want to proceed?';
		if(ctrl_value == 5) this_action = 'WARNING!!!\n\nThis operation will copy job position into new one.\nDo you want to proceed?';		
		if(ctrl_value == 6)
			{
			document.positions.user_action.value = 'Edit_Position';
			document.positions.submit();
			form.action = "administration.html";
			}
		if(confirm(this_action))
			{
			if(ctrl_value == 1 || ctrl_value == 2) document.positions.user_action.value = 'Toggle_Top_Jobs';
			if(ctrl_value == 3 || ctrl_value == 4) document.positions.user_action.value = 'Toggle_Active_History';
			if(ctrl_value == 5) document.positions.user_action.value = 'Copy_Position';
			document.positions.submit();			
			form.action = "administration.html";			
			}
		else
			{
			return false;
			}
		}	



/**************************************************************************************************************
*
* AJAX - Initialize
*
***************************************************************************************************************/
var http_request = createRequestObject();
var this_browser;

function createRequestObject()
	{
	var request_object;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer")
		{
		this_browser = 'msie';
		request_object = new ActiveXObject("Microsoft.XMLHTTP");
		}
	else
		{
		this_browser = 'mozzila';			
		request_object = new XMLHttpRequest();
		}
	return request_object;
	}

/**************************************************************************************************************
*
* AJAX - Time Zones
*
***************************************************************************************************************/
function GetTimeZones()
	{	
	http_request.open('POST','include/process-ajax-time-zones.php',true);
	http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http_request.onreadystatechange = HandleGetTimeZones;
	http_request.send(null);	
	}

function HandleGetTimeZones()
	{
	try
		{
		if(http_request.readyState == 4)
			{
			 if(http_request.status == 200)
				{
				var response = http_request.responseText;
				document.getElementById('content_header_time_zones').innerHTML = response;
				g_interval = setTimeout("GetTimeZones()",118000);				
				}
			else
				alert('There was a problem with the request.');
			}
		}
	catch(e)
		{
		alert('Caught Exception: ' + e.description);
        }
	}
