/* Rollover Script */
/*-----------------------------------------------*/
function rollover(link,id,overIm) {
  if(document.images) {
    im            = document.images[id];
    im.outIm      = new Image();
    im.overIm     = new Image();
    im.outIm.src  = document.images[id].src;
    im.overIm.src = overIm;
    im.src        =im.overIm.src;
    link.onmouseout  = new Function("var im=document."+id+"; im.src=im.outIm.src;");
    link.onmouseover = new Function("var im=document."+id+"; im.src=im.overIm.src;");
  }
}

/* Print window */
/*-----------------------------------------------*/
function printWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}


/* Popup window */
/*-----------------------------------------------*/
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}

/* Help Section */
/*-----------------------------------------------*/
var scrX = screen.availWidth;
var scrY = screen.availHeight;
var tgtX = 240;
var win1 = new Array (0, 0, (scrX - tgtX), scrY);
var win2 = new Array ((scrX - tgtX), 0, tgtX, scrY);
var malmi = false;
var winHandle = false;
var go = false;


function openHelp(whichPage) {

	help_w=230;help_h=460;help_l=640-help_w;help_t=0;

	window.resizeTo(win1[2],win1[3]);
	self.moveTo(win1[0],win1[1]);


	if(winHandle == false){
		self.name = "mainWindow";
	}else{
		go = true;
	}
		winHandle = window.open('help.php?whichPage=' + whichPage ,'popHelp','scrollbars=no,resizable=no,menubar=no,personalbar=no,titlebar=no,toolbar=no,status=yes');

		winHandle.resizeTo(win2[2],win2[3]);
		winHandle.moveTo(win2[0],win2[1]);
 		self.focus();
		winHandle.focus();
}

function closeHelp() {


		if(go == false){
		winHandle = false;
		window.moveTo(0,0);
		window.resizeTo(screen.availWidth,screen.availHeight);
		}
}

function breakFrame() {
	if(top != self){top.location = location;}
}

/* Set focus to a page's first form's, first text field */
/*-----------------------------------------------*/
function set_text_focus() {

	// Since we want to set the focus in the first form's text box after changeCurrency (if it exists),
	// we need to only loop through all the forms and find the first one containing the first text element and 
	// set the focus there (as changeCurrency does not have any text field).

	var flag_focus_set = 0;

	// Looping through the forms...
	for (i = 0; i < document.forms.length; i++)
	{
		var loop_forms = document.forms[i];

		// Increment the counter to point at the correct
		// form to now point at (as want to elimnate the currency change form)
		field = document.forms[i];

		// Now that we've got the correct form, loop through it's elements to test to see that it contains a 
		// textarea or textfield
		for (j = 0; j < field.length; j++) 
		{
			if ((field.elements[j].type == "text") || (field.elements[j].type == "textarea") || (field.elements[j].type == "password")) 
			{
				// j contains the firt non-changeCurrency form's text's element position.
				field.elements[j].focus();

				flag_focus_set = 1;
				break;	
			}
		}

		// If set the focus then break.
		if (flag_focus_set)
		{
			break;
		}	
	}
}


/* Creates a pop up windown with ok & cancel buttons, and a message. */
/*-----------------------------------------------*/
function ok_cancel( formname, message )
{
	
	if( confirm(message) ){

		document.forms[formname].submit();
		return true; 
	} 
	else { 
		return false;
	}
        	

}


