﻿function openWin(url, winName, width, height, scroll) {
    // Locate centre of screen
    var top = (screen.height - height) / 2;
    var left = (screen.width - width) / 2;
    var winProp = "toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=" + scroll + ",resizable=0,copyhistory=1,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left;
    var aWindow;
    aWindow = window.open(url, winName, winProp);
    aWindow.focus()
}

function get_hostname_from_url(url) {
    return url.match(/:\/\/(.[^/]+)/)[1]; 
} 

function switchToFlashVersion()
{
    var url = window.location.href;
    //alert(url);
    var hostname = get_hostname_from_url(url);
    var flashHostname = hostname + '/#';
    var flashURL = url.replace(hostname,flashHostname);
    //alert(flashURL);
    window.location = flashURL;
}

/* To jump to the next field */
		function autojump_list(listName, nextField){
		var myList=document.forms[document.forms.length - 1].elements[listName];
		var myNextField=document.forms[document.forms.length - 1].elements[nextField];
			if(myList.selectedIndex != 0){
				myNextField.focus();
			}
		}


		var downStrokeField;
		function autojump(fieldName,nextFieldName,fakeMaxLength)
		{
			var myForm	= document.forms[document.forms.length - 1];
			var myField = myForm.elements[fieldName];
			myField.nextField=myForm.elements[nextFieldName];

			if (myField.maxLength == null)
				myField.maxLength=fakeMaxLength;
				myField.onkeydown=autojump_keyDown;
				myField.onkeyup=autojump_keyUp;
		}

		function autojump_keyDown()
			{
			this.beforeLength=this.value.length;
			downStrokeField=this;
		}

		function autojump_keyUp()
		{
			if (
			(this == downStrokeField) && 
			(this.value.length > this.beforeLength) && 
			(this.value.length >= this.maxLength)
			)
			this.nextField.focus();
			downStrokeField=null;
		}
