function myconfirm(msg,url)
{
  if(confirm(msg))
  {
    location = url;
  }
}

function UpdatePrice(form) {
form.pricea.value = form.item_price.value;
form.priceb.value = form.item_price.value;
form.pricec.value = form.item_price.value;
form.priced.value = form.item_price.value;
form.pricee.value = form.item_price.value;
}
//-->
/** * Sets/unsets the pointer in browse mode * * @param   object   the table row * @param   object   the color to use for this row * * @return  boolean  whether pointer is set or not */function setPointer(theRow, thePointerColor){    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {        return false;    }    if (typeof(document.getElementsByTagName) != 'undefined') {        var theCells = theRow.getElementsByTagName('td');    }    else if (typeof(theRow.cells) != 'undefined') {        var theCells = theRow.cells;    }    else {        return false;    }    var rowCellsCnt  = theCells.length;    for (var c = 0; c < rowCellsCnt; c++) {        theCells[c].style.backgroundColor = thePointerColor;    }    return true;} // end of the 'setPointer()' function
<!-- Begin
function checkChoice(field, i)
{
//alert (field[1].checked);
//alert (i);
if (i == 0)
	{ // "All" checkbox selected.
	for (i = 1; i < field.length; i++)
		field[i].checked = true;
	}
else
	{  // A checkbox other than "Any" selected.
	for (i = 1; i < field.length; i++)
		field[i].checked = false;
   	}
}
/**
 * functions for moving select items up and down
 */
var select_changes = false;
function set_ordered_list(srcList, flatlist)
{
	flatlist.value = "";

	for(var i = 0; i < srcList.options.length; i++)
	{
		flatlist.value += srcList.options[i].value + ",";
	}
}
function move_select_item_up(srcList, flatlist)
{
	// set temp variables
	var a;
	var b;
	var temp_a;
	var temp_b;

	// Do nothing if nothing is selected
	if ((srcList.selectedIndex == -1))
	{
		return;
	}

	// new list
	for(var i = 0; i < srcList.options.length; i++ )
	{
		if(srcList.options[i + 1] != null )
		{
			a = srcList.options[i];
			b = srcList.options[i + 1];
			temp_a = new Option(a.text, a.value, a.defaultSelected, a.selected);
			temp_b = new Option(b.text, b.value, b.defaultSelected, b.selected);

			if (!a.selected && b.selected)
			{
				srcList.options[i] = temp_b;
				srcList.options[i + 1] = temp_a;
			}
		}
	}

	// set the list
	set_ordered_list(srcList, flatlist);
	select_changes = true;
}
function move_select_item_down(srcList, flatlist)
{
	// set temp variables
	var a;
	var b;
	var temp_a;
	var temp_b;

	// Do nothing if nothing is selected
	if ((srcList.selectedIndex == -1))
	{
		return;
	}
	// new list
	for(var i = (srcList.options.length - 1); i >= 0; i-- )
	{
		if(srcList.options[i + 1] != null )
		{
			a = srcList.options[i];
			b = srcList.options[i + 1];
			temp_a = new Option(a.text, a.value, a.defaultSelected, a.selected);
			temp_b = new Option(b.text, b.value, b.defaultSelected, b.selected);

			if (a.selected && !b.selected)
			{
				srcList.options[i] = temp_b;
				srcList.options[i + 1] = temp_a;
			}
		}
	}
	set_ordered_list(srcList, flatlist);
	select_changes = true;
}
function get_number_selected_items(srcList)
{
	// Do nothing if nothing is selected
	if ((srcList.selectedIndex == -1))
	{
		return 0;
	}

	var selectedCount = 0;

	for(var i = 0; i < srcList.options.length; i++)
	{
		if(srcList.options[i].selected)
		{
			selectedCount++;
		}
	}

	return selectedCount;
}
function change_location_from_select(url, srcList)
{
	// check that no changes have been made
	if(select_changes && !confirm("There are unsaved changes on this page. To continue without saving click 'ok'. To save changes click 'cancel' and submit the form."))
	{
		return
	}

	// check if one is selected
	if(srcList.selectedIndex == -1)
	{
		alert("There are no categories selected. You must select one to view and order it's subcategories.");
		return;
	}

	// check if more than one is selected
	if(get_number_selected_items(srcList) > 1)
	{
		if(confirm("There are " + get_number_selected_items(srcList) + " items selected. Click 'ok' to go to the first item (" + srcList.options[srcList.selectedIndex].text + ") or 'cancel' to select 'one' item from the list to view."))
		{
			document.location = url + srcList.options[srcList.selectedIndex].value;
		}
	}
	else if(get_number_selected_items(srcList) == 1)
	{
		document.location = url + srcList.options[srcList.selectedIndex].value;
	}
	else
	{
		alert("I've no idea!!!");
	}
}
//  End -->
function setCheckboxes(the_form, the_field, do_check)
{
    if (!document.forms[the_form].elements[the_field])
    {
    	return false;
    }

    var elts      = (typeof(document.forms[the_form].elements[the_field]) != 'undefined')
                  ? document.forms[the_form].elements[the_field]
                  : document.forms[the_form].elements['selected_tbl[]'];
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (!elts)
    {
    	return false;
    }

    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_check;
        } // end for
    } else {
        elts.checked        = do_check;
    } // end if... else

    return true;
} // end of the 'setCheckboxes()' function
function checked_form(the_form, the_field, message, display_error)
{
    var elts      = (typeof(document.forms[the_form].elements[the_field]) != 'undefined')
                  ? document.forms[the_form].elements[the_field]
                  : 0;
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (!document.forms[the_form].elements[the_field])
    {
    	return false;
    }

	if (!message)
	{
		message = 'Are you sure you want to delete the selected records?';
	}

	if ((!display_error) && (display_error != 0))
	{
		display_error = 1;
	}

    //Single record confirmation.
    if ((document.forms[the_form].elements[the_field].value!= 'undefined')&&(document.forms[the_form].elements[the_field].checked))
    {
	var agree=confirm(message);
	if (agree)
		return true ;
	else
		return false ;
    }

    if (elts_cnt)
    {
        for (var i = 0; i < elts_cnt; i++)
        {
            if (elts[i].checked)
            {
		var agree=confirm(message);
		if (agree)
			return true ;
		else
			return false ;
            }
        } // end for
    }

    if (display_error == 1)
    {
    	alert ('No records were selected');
    }
    return false;

} // end of the 'checked_form()' function
function delete_confirm()
{
		var agree=confirm("Are you sure you want to delete the record?");
		if (agree)
			return true ;
		else
			return false ;
}
function form_confirm(message)
{
		var agree=confirm(message);
		if (agree)
			return true ;
		else
			return false ;
}
function validate(form)
{ // form is passed as 'document.forms.myForm'
var valid=true;
var message='';

i = 0;
while (i<form.elements.length)
{
	var type='';
	var name='';
	var d=0;
	var display=1;
	var my_title = '';

	if (form.elements[i].title)
	{
		my_title = form.elements[i].title;
		for (var c=0; c<form.elements[i].title.length; c++)
		{
			if (display==1)
			{
				name=name + my_title.substring(d,(d+1));
			}
			else
			{
				type=type + my_title.substring(d,(d+1));
			}
			d++;

			if (my_title.substring((c+1),(c+2))=='|')
			{
				display=2;
				c++;
				d++;
			}
		}

		switch (type)
		{
		case 'email':

			var emailStr = form.elements[i].value
			
			var emailPat=/^(.+)@(.+)$/
			var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
			var validChars="\[^\\s" + specialChars + "\]"
			var quotedUser="(\"[^\"]*\")"
			var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
			var atom=validChars + '+'
			var word="(" + atom + "|" + quotedUser + ")"
			var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
			var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
			var matchArray=emailStr.match(emailPat)
			
			if (matchArray==null) 
			{
				message = message + name + ' is invalid\n';
				break;
			}
			
			var user=matchArray[1]
			var domain=matchArray[2]
		
			if (user.match(userPat)==null) 
			{
		    	message = message + name + ' is invalid\n';
		    	break;
			}
		
			var IPArray=domain.match(ipDomainPat)
			
			if (IPArray!=null) 
			{
				for (var i=1;i<=4;i++) 
				{
			    	if (IPArray[i]>255) 
			    	{
						message = message + name + ' is invalid\n';
						break;
			    	}
		    	}
		    	break;
			}
		
			var domainArray=domain.match(domainPat)

			if (domainArray==null) 
			{
				message = message + name + ' is invalid\n';
				break;
			}
		
			var atomPat=new RegExp(atom,"g")
			var domArr=domain.match(atomPat)
			var len=domArr.length
			
			if (domArr[domArr.length-1].length < 2 || domArr[domArr.length-1].length > 3) 
			{
				message = message + name + ' is invalid\n';
				break;
			}
		
			if (len < 2) 
			{
				message = message + name + ' is invalid\n';
				break;
			}
		break;
		
		case 'percentage':
			
			var checkStr = form.elements[i].value;
			
			if (checkStr.length == 0)
			{
				message = message + name + ' is missing\n';
				break;
			}
			
			if (isNaN(checkStr))
			{
				message = message + name + ' is not a number\n';
				break;
			}
			
			if (checkStr < 0 || checkStr > 100)
			{
				message = message + name + ' is invalid\n';
				break;
			}
			
		break;
		
		case 'integer':
			
			var checkStr = form.elements[i].value;
			
			if (checkStr.length == 0)
			{
				message = message + name + ' is missing\n';
				break;
			}
			
			if (isNaN(checkStr))
			{
				message = message + name + ' is not a number\n';
				break;
			}
			
			if (parseInt(checkStr) != checkStr)
			{
				message = message + name + ' is not a whole number\n';
				break;
			}
			
		break;

		default:

			//For radio buttons check that current and previous values were empty
			if ((form.elements[i].type=='radio')||(form.elements[i].type=='checkbox'))
			{
				var a = i;
				var m = 0;
				var is_checked = 0;
				while(form.elements[a].name==form.elements[i].name)
				{
					if (form.elements[a].checked==true) is_checked = 1;
					a++;
					m++;
				}
				//increment i to account for the array of elements.
				i = i + (m-1);

				if (is_checked==0)
				{
					message = message + name + ' is missing\n';
				}


			}
			else if ((form.elements[i].type=='text')||(form.elements[i].type=='textarea')||(form.elements[i].type=='password')||(form.elements[i].type=='file'))
			{
				if ((form.elements[i].value=='')||(form.elements[i].value==0))
				{
					message = message + name + ' is missing\n';
				}
			}
			else if (form.elements[i].type=='select-one')
			{
				//Select list.
				if (form.elements[i][form.elements[i].selectedIndex].value == '')
				{
					message = message + name + ' is missing\n';
				}
			}
		break;
		}
	}
	i++;
}
if (message!='')
{
	alert(message);
	return(false);
}

return(true);
}
<!--
var newWindow = null;
function new_window(url,width,height)
{
	newWindow = window.open(url,'','left='+((screen.width  - width)/2)+',screenX=0,top='+((screen.height  - height)/2)+',screenY=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=' + width + ',height=' + height);
}

var newWindowExt = null;
function new_window_ext(url,width,height)
{
	newWindow = window.open(url,'','left=0,screenX=0,top=0,screenY=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=' + width + ',height=' + height);
}

var newWindowExtChrome = null;
function new_window_ext_chrome(url,width,height)
{
	newWindow = window.open(url,'','left=0,screenX=0,top=0,screenY=0,toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=' + width + ',height=' + height);
}

var fullWindow = null;
function full_window(url)
{
	var width = (screen.availWidth - 10);
	var height = (screen.availHeight - 40);

	fullWindow = window.open(url + '&' + session_url,'','left=0,screenX=0,top=0,screenY=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=' + width + ',height=' + height);
}

function new_window_status(url,width,height)
{
	newWindow = window.open(url + '&' + session_url,'','left=0,screenX=0,top=0,screenY=0,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=' + width + ',height=' + height);
}
var id_element = null;
var title_element = null;
var link_element = null;
function content_manager(id,title,link)
{
	id_element.value = id;
	title_element.value = title;
	link_element.value = link;
	//alert(id_element.value);
}
function set_content_variables(id_element_value,title_element_value,link_element_value)
{
	id_element = id_element_value;
	title_element = title_element_value;
	link_element = link_element_value;
	//alert(id_element);
}
function highlight_row(my_row,last_row,my_bg)
{
//alert(my_row);
if (parent.document.getElementById(parent.document.getElementById(last_row).value))
{
	parent.document.getElementById(parent.document.getElementById(last_row).value).style.background = '#FFFFFF';
}
parent.document.getElementById(my_row).style.background = my_bg;
parent.document.getElementById(last_row).value = my_row;
}
function invert_row(my_row,last_row,my_bg,my_font,last_font,folder_open_source,folder_close_source)
{
//alert(my_row);
if (parent.document.getElementById(parent.document.getElementById(last_row).value))
{
	parent.document.getElementById(parent.document.getElementById(last_row).value).style.background = '#FFFFFF';
	parent.document.getElementById(parent.document.getElementById(last_row).value + '_icon').src = folder_close_source;
	//parent.document.getElementById(parent.document.getElementById(last_row).value + '_font').style.color = last_font;
}
parent.document.getElementById(my_row).style.background = my_bg;
parent.document.getElementById(my_row + '_icon').src = folder_open_source;
//parent.document.getElementById(my_row + '_font').style.color = my_font;
parent.document.getElementById(last_row).value = my_row;
}
function invert_row_frame(my_row,last_row,my_bg,my_font,last_font,folder_open_source,folder_close_source,my_frame)
{
if (parent.window[my_frame].document.getElementById(parent.window[my_frame].document.getElementById(last_row).value))
{
	parent.window[my_frame].document.getElementById(parent.window[my_frame].document.getElementById(last_row).value).style.background = '#FFFFFF';
	parent.window[my_frame].document.getElementById(parent.window[my_frame].document.getElementById(last_row).value + '_icon').src = folder_close_source;
}
parent.window[my_frame].document.getElementById(my_row).style.background = my_bg;
parent.window[my_frame].document.getElementById(my_row + '_icon').src = folder_open_source;
parent.window[my_frame].document.getElementById(last_row).value = my_row;
}
function insertTD(my_count){

	var newTD = document.createElement("td");
	newTD.setAttribute('id','level' + my_count);
	newTD.setAttribute('valign','top');
	var trElm = document.getElementById("outer_box");
	//alert(my_count);
	trElm.appendChild(newTD);
}
function removeTD(my_count){

	var trElm = document.getElementById("outer_box");
	var rmTD = document.getElementById("level" + my_count);
    if (rmTD)
    {
	    //alert("level" + my_count);
	    trElm.removeChild(rmTD);
	}
}
function invert_row2(my_row,last_row,my_bg,my_font,last_font,folder_open_source,folder_close_source)
{
//alert(my_row);
if (parent.browser_frame.document.getElementById(parent.browser_frame.document.getElementById(last_row).value))
{
	parent.browser_frame.document.getElementById(parent.browser_frame.document.getElementById(last_row).value).style.background = '#FFFFFF';
	parent.browser_frame.document.getElementById(parent.browser_frame.document.getElementById(last_row).value + '_icon').src = folder_close_source;
	//parent.browser_frame.document.getElementById(parent.browser_frame.document.getElementById(last_row).value + '_font').style.color = last_font;
}
parent.browser_frame.document.getElementById(my_row).style.background = my_bg;
parent.browser_frame.document.getElementById(my_row + '_icon').src = folder_open_source;
//parent.browser_frame.document.getElementById(my_row + '_font').style.color = my_font;
parent.browser_frame.document.getElementById(last_row).value = my_row;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function illegal_chars(form)
{ // form is passed as 'document.forms.myForm'
	i = 0;
	while (i<form.elements.length)
	{
	
		if ((form.elements[i].type=='text')||(form.elements[i].type=='textarea'))
		{
			form.elements[i].value = illegal_chars_replace(form.elements[i].value);
		}
	
		i++;
	}
}

// Open New Window in center of screen.
var win = null;
function OpenWindow(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)
}

// Display PNG's correctly in IE Browsers.
function correctPNG()
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
            img.outerHTML = strNewHTML
            i = i-1
          }
    }
}
if ( navigator.userAgent.indexOf("MSIE") != -1 ) {
        window.attachEvent("onload", correctPNG);
}
function timesheet_update(timesheet, date)
{
	var start=0;
	var finish=0;
	var breaktime=0;
	var totaltime=0;
	var date = date;

	var start_hour = 'start_hour' + date ;
	var start_minutes = 'start_minutes' + date;
	var finish_hour = 'finish_hour' + date;
	var finish_minutes = 'finish_minutes' + date;
	var break_minutes = 'break_minutes' + date;
	var total_time = 'total' + date;

	//start = timesheet[date + 'start_hour'].options[timesheet[date + 'start_hour'].selectedIndex].value;
	start = document.timesheet_form[start_hour][document.timesheet_form[start_hour].selectedIndex].value;

	start = start * 60;

	//start += 1 * timesheet[date + 'start_minutes'].options[timesheet[date + 'start_minutes'].selectedIndex].value;
	start = start + (1 * document.timesheet_form[start_minutes][document.timesheet_form[start_minutes].selectedIndex].value);

	//finish = timesheet[date + 'finish_hour'].options[timesheet[date + 'finish_hour'].selectedIndex].value;
	finish = document.timesheet_form[finish_hour][document.timesheet_form[finish_hour].selectedIndex].value;

	finish = finish * 60;
	//finish += 1 * timesheet[date + 'finish_minutes'].options[timesheet[date + 'finish_minutes'].selectedIndex].value;
	finish = finish + (1 * document.timesheet_form[finish_minutes][document.timesheet_form[finish_minutes].selectedIndex].value);

	//breaktime = timesheet[date + 'break_minutes'].options[timesheet[date + 'break_minutes'].selectedIndex].value;
	breaktime = document.timesheet_form[break_minutes][document.timesheet_form[break_minutes].selectedIndex].value;
	totaltime = (finish -start - breaktime)/60;

	//timesheet[date + 'total'].value = totaltime;
	document.timesheet_form[total_time].value = totaltime;
}
function update_MFL_fees(formname, InputName, StampDuty, TransferFee, MFLFees, TotalFees, PropertySellPrice, TotalPropertyPrice)
{
	if (InputName == 'p_TotalFees')
	{
		//alert ('yes');
		document[formname][StampDuty].value = '';
		document[formname][TransferFee].value = '';
		document[formname][MFLFees].value = '';
		document[formname][TotalFees].value = document[formname][TotalFees].value.replace(/\,/g,'');
	}
	else
	{
		var Stamp = document[formname][StampDuty].value.replace(/\,/g,'');
		var Transfer = document[formname][TransferFee].value.replace(/\,/g,'');
		var MFL = document[formname][MFLFees].value.replace(/\,/g,'');
		document[formname][TotalFees].value = (1*Stamp) + (1*Transfer) + (1*MFL);
	}
	var TotalFees = document[formname][TotalFees].value.replace(/\,/g,'');;
	var PropertySellingPrice = document[formname][PropertySellPrice].value.replace(/\,/g,'');;

	document[formname][TotalPropertyPrice].value = (1*TotalFees) + (1*PropertySellingPrice);
	//alert(formname[TotalFees].value);
}

function update_property_selling_price(formname, InputName, InitialPayment, InstallmentValue, InstallmentMonths, PropertySellPrice, TotalFees, TotalPropertyPrice)
{
	var InitialPayment = formname[InitialPayment].value.replace(/\,/g,'');
	var InstallmentValue = formname[InstallmentValue].value.replace(/\,/g,'');
	var InstallmentMonths = formname[InstallmentMonths].value.replace(/\,/g,'');
	var TotalFees = formname[TotalFees].value.replace(/\,/g,'');
	formname[PropertySellPrice].value = (1*InitialPayment);
	formname[TotalPropertyPrice].value = (1*TotalFees) + (1 * formname[PropertySellPrice].value);
}
function printit()
{  
	if (window.print) 
	{
   	 window.print();  
	}
}
function parseNavigation(ob) {
toBeBrokenDown = ob.options[ob.selectedIndex].value.split("|");

targetWindow = toBeBrokenDown[0];
targetURL    = toBeBrokenDown[1];

    if (targetWindow!=='') {
    // if a new Window name is specified, then it will
    // open in a new Window.
    window.open(targetURL,targetWindow,'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width=800,height=600');
    // if we open a new window, then we have to re-set
    // the select box to the first option
    // which should have no value
    ob.selectedIndex = 0;
        } else {
    // or else it will open in the current window        
    window.open(targetURL,'_top')
    }
}



