////////////////////////////////////////////////////////////////////////////
//The following javascript is used for popup inline help and error waring
//was designed by My Baoden
//
//Integrated into ASP.NET page by me
//
//Created: Eric HO  Date: 18-Jan-2003
/////////////////////////////////////////////////////////////////////////////
//
//  List all error and help messages here
//  Make sure the Menu_ApplicationInfo.aspx have the same javascript version !!!
//  VERY IMPORTANT !
var strJScript1Version = '120804.2'

var errM0 = 'Select dropdown please';
var errM1 = 'Field must not be empty';		//put your error message for the field 1 here
var errM2 = 'not valid telephone number format';		//put your error message for the field 2 here
var errM3 = 'Not a valid credit card number';
var errM4 = 'Postcode must be 4 digits';
var errM5 = 'Select at least one';
var errM6 = 'Input has to be numbers:xxx xxx xxx';
var errM7 = 'you must enter the phone number if you select the checkbox';
var errM8 = 'You must enter the home number if you select this checkbox';
var errM9 = 'you must enter the work number if you select this checkbox';
var errM10 ='you must enter the fax number if you select this checkbox';
var errM11 = 'You must enter the valid email if you select this checkbox';
var errM12 = 'Only numbers can be here and be greater than zero';
var errM13 = 'Please select suburb';
var errM14 = 'Please enter a suburb or postcode';
var errM15 = 'The suburb or postcode that you entered was invalid';
var errM16 = 'Please click go button';
var errM17 = 'Only numbers can be here and must be zero or greater';
var errM18 = 'Please select a date!';
var errM19 = 'Type at least two characters and select type of document';
var hlpasset = 'please enter the value of this asset:<br>integer values only';
var hlpM1='Use only valid Post code:<br>4 numbers format';		//put your help message for the field 1 here
var hlpM2='Use only valid Phone Number:<br>8 numbers format';		//put your help message for the field 2 here
var hlpM3='Input as: xxx xxx xxx'
var hlpM4='Do not leave as empty, digital numbers only'

//this functions will call error and help popup object; msg is message string paset to be displayed in the popup; w is width h is weight of popup element
function hlpPop (evnt,msg,w,h){
	//top.makeInfoPop(evnt,w,h,msg,'info');
	makeInfoPop(evnt,w,h,msg,'info');
}
function errPop (evnt,msg,w,h){
	//top.makeInfoPop(evnt,w,h,msg,'error');				   
	makeInfoPop(evnt,w,h,msg,'error');
}

//  functions which will trigger error image to be displayed next to the field with error
// 'obj' is id of errror image belonging to field; val = triggering value BUT CHANGE it in 'if' statement to suit it to you
function chkErrors1(val,obj){
	//put your error checking routine for field 1 here
	o=eval("document.all."+obj);
	if(val.length!=8)o.style.display='inline';
	else o.style.display='none';
}

function chkErrors2(val,obj){
	//put your error checking routine for field 2 here
	o=eval("document.all."+obj);
	if(val.length!=4)o.style.display='inline';
	else o.style.display='none';
}

// these are functions checking  completness of mandatory fields used in the form 
// and other page error related routines - of course these are only dummies feel free to write your own  :o)

var globPopup = window.createPopup();

function makeInfoPop(evnt,w,h,message,bgr) {
	scLeft=this.screenLeft; 
	scTop=this.screenTop;
	scX=evnt.screenX+10;
	scY=evnt.screenY+20;
	x=scX-scLeft;
	y=scY-scTop;
	bgrCol="#FFFFFF";

	if (bgr == 'info'){
		bgrCol="#F7EDCB";
		message="<div style='font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color: #333333; position:relative; overflow: none; width: "+w+"; height: "+h+"; scrollbar-3dlight-color:white; scrollbar-arrow-color:#003366; scrollbar-face-color:#e0edf4; scrollbar-shadow-color:#cccccc '><table width='100%' border='0' cellspacing='5' cellpadding='0' style='font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color: #333333; position:relative; overflow: none; width: 100%; height: 100%; scrollbar-3dlight-color:white; scrollbar-arrow-color:#003366; scrollbar-face-color:#e0edf4; scrollbar-shadow-color:#cccccc '><tr><td width='21' valign='top'><img src='../../global/img/helpH.gif' width='19' height='18'></td><td valign='top'>"+message+"</td></tr></table></div>";	
	}

	if (bgr=='error'){
		bgrCol="#FEDACD";
		message="<div style='font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color: #333333; position:relative; overflow: none; width: "+w+"; height: "+h+"; scrollbar-3dlight-color:white; scrollbar-arrow-color:#003366; scrollbar-face-color:#e0edf4; scrollbar-shadow-color:#cccccc '><table width='100%' border='0' cellspacing='5' cellpadding='0' style='font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color: #333333; position:relative; overflow: none; width: 100%; height: 100%; scrollbar-3dlight-color:white; scrollbar-arrow-color:#003366; scrollbar-face-color:#e0edf4; scrollbar-shadow-color:#cccccc '><tr><td width='35' valign='top'><img src='../../global/img/error.gif' width='35' height='14'></td><td valign='top'>"+message+"</td></tr></table></div>";
	}

	var globPopBody = globPopup.document.body;
	globPopBody.style.backgroundColor = bgrCol;
	globPopBody.style.borderColor = "#000000";
	globPopBody.style.borderWidth = "1";
	globPopBody.style.borderStyle = "solid";

//document.write(message);

	globPopBody.innerHTML = message;					
	globPopup.show(x, y, w, h, document.body);
}
var chk;
function delayShowToolTip(message,w,h,evtX,evtY,lvl)
{

	if (!lvl) lvl = '../../';

	scLeft=this.screenLeft;
		scTop=this.screenTop;
		scX=evtX+5;
		scY=evtY+10;
		x=scX-scLeft;
		y=scY-scTop;
		bgrCol="#F7EDCB";
		message="<div style='font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color: #333333; position:relative; overflow: none; width:" + 
				 w + ";height:" + h + ";scrollbar-3dlight-color:white; scrollbar-arrow-color:#003366; scrollbar-face-color:#e0edf4; scrollbar-shadow-color:#cccccc'>" + 
				"<table width='100%' border='0' cellspacing='5' cellpadding='0' style='font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color: #333333; " + 
				"position:relative; overflow: none; width: 100%; height: 100%; scrollbar-3dlight-color:white; scrollbar-arrow-color:#003366; scrollbar-face-color:#e0edf4; " + 
				"scrollbar-shadow-color:#cccccc '><tr><td width='21' valign='top'><img src='" + lvl + "global/img/helpH.gif' width='19' height='18'></td><td valign='top'>" +
				message + "</td></tr></table></div>";

		var globPopBody = globPopup.document.body;
		globPopBody.style.backgroundColor = bgrCol;
		globPopBody.style.borderColor = "#000000";
		globPopBody.style.borderWidth = "1";
		globPopBody.style.borderStyle = "solid";

	//document.write(message);

		globPopBody.innerHTML = message;					
		globPopup.show(x, y, w, h, document.body);
	 
} 

//* with timer as parameter
function showToolTipTimer(evnt,message,w,h, timer, lvl) {

	if (!lvl) lvl = '../../';
	var strp="delayShowToolTip('"+message+"',"+w+","+h+","+evnt.screenX+","+evnt.screenY+ ",'"+ lvl + "')"
	chk=setTimeout(strp,timer)
}

function showToolTip(evnt,message,w,h, lvl) {
	if (!lvl) lvl = '../../';


var strp="delayShowToolTip('"+message+"',"+w+","+h+","+evnt.screenX+","+evnt.screenY+ ",'"+ lvl + "')"
chk=setTimeout(strp,1500)

/*
	scLeft=this.screenLeft;
	scTop=this.screenTop;
	scX=evnt.screenX+5;
	scY=evnt.screenY+10;
	x=scX-scLeft;
	y=scY-scTop;
	bgrCol="#F7EDCB";
	message="<div style='font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color: #333333; position:relative; overflow: none; width: "+w+"; height: "+h+"; scrollbar-3dlight-color:white; scrollbar-arrow-color:#003366; scrollbar-face-color:#e0edf4; scrollbar-shadow-color:#cccccc '><table width='100%' border='0' cellspacing='5' cellpadding='0' style='font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color: #333333; position:relative; overflow: none; width: 100%; height: 100%; scrollbar-3dlight-color:white; scrollbar-arrow-color:#003366; scrollbar-face-color:#e0edf4; scrollbar-shadow-color:#cccccc '><tr><td width='21' valign='top'><img src='../../global/img/helpH.gif' width='19' height='18'></td><td valign='top'>"+message+"</td></tr></table></div>";

	var globPopBody = globPopup.document.body;
	globPopBody.style.backgroundColor = bgrCol;
	globPopBody.style.borderColor = "#000000";
	globPopBody.style.borderWidth = "1";
	globPopBody.style.borderStyle = "solid";

//document.write(message);

	globPopBody.innerHTML = message;					
	globPopup.show(x, y, w, h, document.body);*/
}

function hidePopup() {
clearTimeout(chk);
	globPopup.hide();
}		
// trim string str with spaces from the front and end. Good for validating fields, ignoring theses space characters.
function trim(str) {
    var startIndex = 0;
    var endIndex = str.length;

    while (startIndex < endIndex && str.charAt(startIndex) == ' ') {
    startIndex++;
    } 

    while (endIndex > startIndex && str.charAt(endIndex - 1) == ' ') {
    endIndex--;
    }

    return str.substring(startIndex, endIndex);
}

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num)) num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10) cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3))
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function formatDigit(oTxt, numRound) {
	var num = oTxt.value;
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))num = "0";
	sign = (num == (num = Math.abs(num)));
	if (!numRound) numRound = 0; //round up value
	if (numRound > 0) {
		num = num / numRound;
		num = (Math.ceil(num) * numRound);
	}
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10) cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3))
	oTxt.value = ((((sign)?'':'-') + num + '.' + cents));
}

function formatDigitNoCent(oTxt, numRound) {
	var num = oTxt.value;
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))num = "0";
	sign = (num == (num = Math.abs(num)));
	if (!numRound) numRound = 0; //round up value
	if (numRound > 0) {
		num = num / numRound;
		num = (Math.ceil(num) * numRound);
	}
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10) cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3))
	oTxt.value = ((((sign)?'':'-')+ num));
}

function formatRemoveDigit(oTxt) {
	var num = oTxt.value;
	num = num.toString().replace(/\$|\,/g,'');
	oTxt.value = num;
	oTxt.select();
}

function returnRemoveDigit(num) {
	//var num = oTxt.value;
	num = num.toString().replace(/\$|\,/g,'');
	return num;
	//oTxt.value = num;
	//oTxt.select();
}
						
// Check if string str agurement passed is an Integer
function isInteger(str) {
    var valid = (str == parseInt(str));

    if (!valid) {      
        var startNonZeroIndex = -1;

        for (var i = 0 ; i < str.length ; i++) {
            if (str.charAt(i) == '0') {
            startNonZeroIndex = i + 1;
            }
            else {
            break;
            }
        }

        if (startNonZeroIndex != -1) {
            str = str.substring(startNonZeroIndex, str.length);
            valid = (str == parseInt(str));
        }
    }

    return valid;
}


// Check if its a number
function isNumber(str) {
    return (str == parseFloat(str));
}


// Check if its numeric and greater than zero
function isNumeric(str) {
    var number = parseFloat(str);
    
    if (str == number) {
        return (number >= 0 ? true : false);
    }
    else {
        return false;
    }
}


function debug(elem, filter) {
    var result = "";

    for (var i in elem) {
        if (filter == null || (filter != null && i.toString().indexOf(filter) != -1)) {
        result += i + " = " + eval("elem." + i) + "   ";
        }   
    }
    
    alert(result);
		
}

/**
 * DHTML date validation script for dd/mm/yyyy. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1800;
var maxYear=3000;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function validateDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Please enter a valid date")
		return false
	}
return true
}
//*****//

function validatePrice(source, arguments) {
    var value = trim(arguments.Value);

    // Remove commas from price field
    value = value.replace(eval("/,/g"), "");          
    
    if (!isInteger(value) || value.length == 0 || value <= 0) {
        arguments.IsValid = false;
    }
    else {
        arguments.IsValid = true;
    }        
}


function validateYear(source, arguments) {        
    var value = trim(arguments.Value);

    if (value.length != 2 || !isInteger(value)) {
        arguments.IsValid = false;
    }
    else {
        arguments.IsValid = true;
    }        
}


function validateEmail(source, arguments) {  
   
    var value = trim(arguments.Value);
    //alert(arguments.Value);
   // var newString = value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.biz)|(\.org)|(\..{2,2}))$)\b/gi);
    var newString = value.match(/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i)
    var returnValue = value.indexOf("..")
    if (returnValue != -1) 
      newString = false;
    
    returnValue = value.indexOf("...")
    if (returnValue != -1) 
      newString = false;
    
    returnValue = value.indexOf(",")
    if (returnValue != -1) 
      newString = false;
      
    returnValue = value.indexOf(":")
    if (returnValue != -1) 
      newString = false;
   
    arguments.IsValid = newString;
}




function validateSuburb(source, arguments) {        
	var sControlToValidate = eval(source.id).controltovalidate;
	var controlToValidate = eval('document.all.' + sControlToValidate);
	if (controlToValidate.className != 'inputHide') {
	    arguments.IsValid = true;
	} else {
	    arguments.IsValid = false;
	}
}

function validateRadioList(source, arguments) {        
	var sControlToValidate = eval(source.id).controltovalidate;
	alert(sControlToValidate);
	var controlToValidates = eval('document.all.' + sControlToValidate);
	
	var isSelect = false;
	for (i = 0 ; i < controlToValidates.length ; i++) {
        if (controlToValidates[i].checked == true) {
		isSelect = true;
		i = controlToValidates.length + 1;
        }
    }
	if (isSelect) {
	    arguments.IsValid = true;
	} else {
	    arguments.IsValid = false;
	}
}

function validateMobileNumber(source, arguments) {        
    var value = trim(arguments.Value);
    var controlToValidate = eval(source.id).controltovalidate;
    
    if (value.length != 0) {
    
        if (controlToValidate.toLowerCase().indexOf("prefix") != -1) {
            if (value.length != 4) {
            arguments.IsValid = false;
            }
            else {
            if (value.substring(0, 2) != "04") {
                arguments.IsValid = false;
            }
            }
         }         
        if (controlToValidate.toLowerCase().indexOf("txtnumber") != -1 || controlToValidate.toLowerCase().indexOf("endnumber") != -1) {
            if (value.length != 3) {
            arguments.IsValid = false;
            }
        }         
        if (arguments.IsValid) {
            arguments.IsValid = isInteger(value); 
        }   
    }
    else {
        arguments.IsValid = false;
    }           
}
    
                    
function validateContactNumber(source, arguments) {
    var value = trim(arguments.Value);
    var controlToValidate = eval(source.id).controltovalidate;
                
    if (value.length != 0) {           
        var controlToValidateText = controlToValidate.toLowerCase();

        if (controlToValidateText.indexOf("prefix") != -1) {
            if (value.length != 2) {
            arguments.IsValid = false;
            }
        }         

        if (controlToValidateText.indexOf("start") != -1 || controlToValidateText.indexOf("end") != -1) {
            if (value.length != 4) {
            arguments.IsValid = false;
            }
        }         

        if (arguments.IsValid) {
            arguments.IsValid = isInteger(value); 
        }   
    }
    else {
        arguments.IsValid = false;
    }           
} 

function toggleField(buttonObj, validatorObjs, textFieldObjs) {                    
    var anyEnabled = false;

    for (var i = 0 ; i < textFieldObjs.length ; i++) {
        var textFieldObj = textFieldObjs[i];

        if (buttonObj.value.toLowerCase().indexOf("yes") != -1) {
            textFieldObj.className = "inputMand"  
            textFieldObj.disabled = false;
            anyEnabled = true;
        } 
        else {
            textFieldObj.className = "menuLDisabled"  
            textFieldObj.disabled = true;
            if (textFieldObj.id.indexOf('txtPrefix') == -1) {
				textFieldObj.value = "";
			}
   	  		anyEnabled = false;
        }           
	  	}

    for (var i = 0 ; i < validatorObjs.length ; i++) { 	  	     
  	    ValidatorEnable(validatorObjs[i], anyEnabled);    	
  	}  	  	     
}  		

function toggleContact(isOn, validatorObjs, textFieldObjs) {                    
    var anyEnabled = false;

    for (var i = 0 ; i < textFieldObjs.length ; i++) {
        var textFieldObj = textFieldObjs[i];
        if (isOn == true) {
            textFieldObj.className = "inputMand"  
            textFieldObj.disabled = false;
            anyEnabled = true;
        } 
        else {
            textFieldObj.className = "menuLDisabled"  
            textFieldObj.disabled = true;
            textFieldObj.value = "";
   	  		anyEnabled = false;
        }           
	  	}

    for (var i = 0 ; i < validatorObjs.length ; i++) { 	  	     
  	    ValidatorEnable(validatorObjs[i], anyEnabled);    	
  	}  	  	     
}  	

function toggleFieldCheckBox(checkObj, validatorObjs, textFieldObjs) {                    
    var anyEnabled = false;
    for (var i = 0 ; i < textFieldObjs.length ; i++) {
        var textFieldObj = textFieldObjs[i];

        if (checkObj.checked == 1) {
            textFieldObj.style.display="inline"  
            textFieldObj.disabled = false;

            if (textFieldObjs[0].type == 'text')
				{textFieldObjs[0].focus();}
            anyEnabled = true;
        } 
        else {
			if (textFieldObjs[0].type == 'text')
				{textFieldObjs[0].value = 0;}
            textFieldObj.style.display="none"  
            textFieldObj.disabled = true;
            if (textFieldObj.type == 'checkbox')
				{textFieldObj.checked = 0;}
			else
			{
				if (textFieldObj.value == "Shared: ")
					{}
				else
					{textFieldObj.value = "";}
			}
			
   	  		anyEnabled = false;
        }           
	  	}

    for (var i = 0 ; i < validatorObjs.length ; i++) { 	  	     
  	    ValidatorEnable(validatorObjs[i], false);    	
  	}  	  	     
}  

function toggleValidator(validatorObjs){
	for (var i = 0 ; i < validatorObjs.length ; i++) { 	  	     
  	    ValidatorEnable(validatorObjs[i], true);    	
  	}  	 
}

function loadFriendlyMessages(form) {
    if (form) {
        for (var i = 0 ; i < form.elements.length ; i++) {
            var onBlurFunction = form.elements[i].onblur;
            
            if (onBlurFunction != null && onBlurFunction.toString().toLowerCase().indexOf("setfriendlyfeedback") != -1) {
            var elem_value = trim(form.elements[i].value);
            
            if (elem_value.length > 0) {
                form.elements[i].onblur();
            }          
            }
        }
    }
}


function setFriendlyFeedbackNumeric(textFieldID, labelFieldID) {

//alert('textFieldID='+textFieldID);
//alert('labelFieldID='+labelFieldID);

    var objTextField = document.all(textFieldID);
    var objTextFieldValue = trim(objTextField.value);
    
    if (isNumeric(objTextFieldValue) && (parseFloat(objTextFieldValue) > 0)) {          
        document.all(labelFieldID).innerHTML = parent.frames['frHead'].pickComment();
    }   
    else {
        document.all(labelFieldID).innerHTML = "";
    }        
}


function setFriendlyFeedback(textFieldID, labelFieldID) {
    var objTextField = document.all(textFieldID);
         
    if (trim(objTextField.value).length > 0) { try {         
        document.all(labelFieldID).innerHTML = parent.frames['frHead'].pickComment();
        }
        catch(x) {}
    }   
    else {
        document.all(labelFieldID).innerHTML = "";
    }
}   


// Returns an array of parameters from the query string
// Simple use for example as:
// var args = getArgs()
// var value = args['name'] and that will get a value from a name=
// param in the query string or use as:
// var value = args.name
function getArgs() {
    var args = new Object();
    var query = location.search.substring(1);

    var pairs = query.split("&");
    
    for (var i = 0; i < pairs.length; i++) {
        var pos = pairs[i].indexOf('=');

        if (pos == -1) continue;
    
        var argname = pairs[i].substring(0,pos);
        var value = pairs[i].substring(pos+1);

        args[argname] = unescape(value);
    } 

    return args;
}


//+-+-+-+-+-+-+-+-+-+-+-+-+for highlight row+-+-+-+-+-+-+-+-+-+-+-+-+//
function HiLiteTR(cssClass){  
	var el = event.srcElement;
		el = el.parentElement.parentElement;
	try	 {
	el.className = cssClass;
	}catch(e) {;}
}

var preEl ;
var orgBColor;
var orgTColor;

function HighLightTR(backColor,textColor)
{  

	var el = event.srcElement;
		el = el.parentElement;
	try
	{
	ChangeTextColor(el,textColor);
	}
	catch(e)
	{;}
	
	preEl = el; 
}



function ChangeTextColor(a_obj,a_color)
{  		    
	for (var i=0;i<a_obj.cells.length;i++)
	{	
	a_obj.cells(i).style.background=a_color; 			
	}
}


//+-+-+-+-+-+-+-+-+-+-+-+-+End of highlight row+-+-+-+-+-+-+-+-+-+-+-+-+//        





function setImageValue(objTextField, description, objField) {
	objTextField.value = description;
	toggleImage(objField);
}


function toggleImage(objField) {
    var field = objField.id;
    var field_name = field.substring(0, field.indexOf('_'));
    var label_panel = document.all(field_name + "_label");
    var image_panel = document.all(field_name + "_image");
	
    var panel_index = 0;
    var foundObj = false;
	if (label_panel.length == undefined) {
		
		if (label_panel.assign && label_panel.assign == "true") {
			label_panel.className = "main10";
			label_panel.assign = "false";
			image_panel.border = "0"; 
		}
		if (label_panel == objField || image_panel == objField) {
			label_panel.className = "main10BoldHilite";
			label_panel.assign = "true";
			image_panel.border = "1"; 
		}
	} else {
		for (var i = 0; i < label_panel.length ; i++) {
			var elemObj = label_panel[i];
	                    
			if (elemObj.assign && elemObj.assign == "true") {
				elemObj.className = "main10";
				elemObj.assign = "false";
				image_panel[i].border = "0"; 
			}
	            
			if (!foundObj) {
				if (label_panel[panel_index] == objField || image_panel[panel_index] == objField) {
					foundObj = true;
				}
				else {
					panel_index++;
				}
			}  
		}

		if (foundObj) {
			label_panel[panel_index].className = "main10BoldHilite";
			label_panel[panel_index].assign = "true";
			image_panel[panel_index].border = "1"; 
		}   
	}
}

function toggleImageByValue(field_name, field_value) {
    var label_panel = document.all(field_name + "_label");
    var image_panel = document.all(field_name + "_image");
    var panel_index = 0;
    var foundObj = false;
	if (label_panel.length == undefined) {
		
		if (label_panel.assign && label_panel.assign == "true") {
			label_panel.className = "main10";
			label_panel.assign = "false";
			image_panel.border = "0"; 
		}
		if (label_panel.text == field_value) {
			label_panel.className = "main10BoldHilite";
			label_panel.assign = "true";
			image_panel.border = "1"; 
		}
	} else {
		for (var i = 0; i < label_panel.length ; i++) {
			var elemObj = label_panel[i];
	                    
			if (elemObj.assign && elemObj.assign == "true") {
				elemObj.className = "main10";
				elemObj.assign = "false";
				image_panel[i].border = "0"; 
			}
	            
			if (!foundObj) {
				if (label_panel[panel_index].text == field_value) {
					foundObj = true;
				}
				else {
					panel_index++;
				}
			}  
		}

		if (foundObj) {
			label_panel[panel_index].className = "main10BoldHilite";
			label_panel[panel_index].assign = "true";
			image_panel[panel_index].border = "1"; 
		}   
	}
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len,e) {
	try{
		var keyCode = (isNN) ? e.which : e.keyCode; 
		var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
		if(input.value.length >= len && !containsElement(filter,keyCode)) {
			//input.value = input.value.slice(0, len);
			var id = (getIndex(input)+1) % input.form.length;
			input.form[id].select();
			input.form[id].focus();
		}
	}catch(x){
	}

	return true;
}

function autoSubmit(e, sBtn) { // to automatically initiate the form submission
	var keyCode = (isNN) ? e.which : e.keyCode; 
	if (keyCode == 13) {
		var oBtn = eval('document.forms[0].' + sBtn);
		oBtn.click();
	}
}

function containsElement(arr, ele) {
	var found = false, index = 0;
	while(!found && index < arr.length) {
		if(arr[index] == ele)
			found = true;
		else
			index++;
	}
	return found;
}

function getIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
		if (input.form[i] == input)
			index = i;
		else 
			i++;
	return index;
}

function placeFocus() {
	if (document.forms.length > 0) {
		var fields = document.forms[0];
		for(var i=0;i < fields.length; i++) {
			if ((fields.elements[i].type == 'text') || (fields.elements[i].type == 'textarea') || 
				(fields.elements[i].type.toString().substring(0, 6) == 'select') || 
				(fields.elements[i].type == 'checkbox') || (fields.elements[i].type == 'radio')) {
				try { fields.elements[i].focus(); } catch (ex) {}
				break;
			}
		}
		
	}
}

function setSelectIndex(oSelect, val)  {
	for (var i=0;i < oSelect.length; i++) {
		if (oSelect.options[i].value == val) {
			oSelect.selectedIndex = i;
			return true;
		}
	}
	oSelect.selectedIndex = 0;
}

function initCheckBoxLogic(checkObj, txtObj, spanObj, strBoolProvider) {
	//var checkProviderObj=document.all.<%=ClientID%>_providerCheckBox;
	//var txtProviderObj=document.all.<%=getProviderIDvalue()%>;
	if (checkObj.checked == 1 && strBoolProvider ) {
		txtObj.disabled = false;txtObj.style.display="Inline";spanObj.style.display="Inline";
		} 
	else { 
	txtObj.disabled = true;txtObj.style.display="none";spanObj.style.display="none";
	}     
}

function convertSize(sizeValue, typeValue){
	sizeValue = parseFloat(sizeValue);
	returnValue = sizeValue;


	if (typeValue == "m2") {
		returnValue = sizeValue;
	}
	else if (typeValue == "Ha") {
		returnValue = (sizeValue*1000);
	}
	else if (typeValue == "acre") {
		returnValue = (sizeValue*4046.85642);
	}
	else if (typeValue == "Square") {
		returnValue = (sizeValue*9.29022);
	}
	else{
		return "something bad happen";
	}
	
	returnValue = (returnValue * 100);
	returnValue = Math.round(returnValue);
	return (returnValue/100);

}

function initValueCheckBoxLogic (checkSharedObj, lblObj, sharedHelpObj, txt1Obj, spanObj, checkObj ,proceedTR ,providerTR, strBool, strBoolDeposit, strBoolProvider ) {
	//var checkSharedObj=document.all.<%=ClientID%>_sharedCheckBox;
	//var lblObj=document.all.<%=getLabelIDvalue()%>;
	//var txt1Obj=document.all.<%=getIDValue()%>;
	//var checkObj=document.all.<%=ClientID%>_valueCheckBox; 
	//var proceedTR=document.all.<%=ClientID%>_proceedTR; 
	//var providerTR=document.all.<%=ClientID%>_providerTR;
	if (checkObj.checked == 1 ) {
		if (strBool){
			checkSharedObj.style.display="Inline";
			lblObj.style.display="Inline";
			sharedHelpObj.style.display="Inline";
		}
		else{
			checkSharedObj.style.display="none";
			lblObj.style.display="none";
			sharedHelpObj.style.display="none";
		};
		
		if (strBoolDeposit){
			proceedTR.style.display="Inline";
		}
		else{
			proceedTR.style.display="none";
		};
		
		if (strBoolProvider){
			providerTR.style.display="Inline";
		}
		else{
			providerTR.style.display="none";
		}
		txt1Obj.style.display="Inline";txt1Obj.disabled = false;spanObj.style.display="Inline"
	} 
	
	else {
		checkSharedObj.style.display="none";
		lblObj.style.display="none";
		sharedHelpObj.style.display="none";
		txt1Obj.style.display="none";spanObj.style.display="none"
		txt1Obj.disabled = true;
		txt1Obj.value = "";
		proceedTR.style.display="none"; 
		providerTR.style.display="none";}   
}
		
function printIt()
{			
	document.getElementById('button0').style.visibility = "hidden";
	document.getElementById('info').style.overflow = "visible";	
	window.print();
    document.getElementById('button0').style.visibility = "visible";
    document.getElementById('info').style.overflow = "auto";		                		
}

function disableThis(e)
{

  if (e.disabled != null)
	e.disabled=true;            
}

//===========================================
// tick or untick all check boxes in the page
//===========================================
function tickUntickAllPageCheckBoxes(obj,strNamingString){
  
  var blnChecked = document.getElementById(obj.id).checked;
  for (var i=0; i<document.all.length; i++){
     if (document.all.item(i).id.indexOf(strNamingString)!=-1){
         document.all.item(i).checked=blnChecked;
     }
  }
}



//==============================================
//tick or untick summary checkbox in the page
//==============================================

function tickUntickSummaryCheckbox(strSummaryCBID,strNamingString){

 var objSummaryCheckBox = document.getElementById(strSummaryCBID)
 var blnAllCBChecked = true;
 
 for (var i=0; i<document.all.length; i++){
     if (document.all.item(i).id.indexOf(strNamingString)!=-1){
       if ((document.all.item(i).checked==false)&&(document.all.item(i).id!=strSummaryCBID))
        blnAllCBChecked=false;
     }
  }
  
  objSummaryCheckBox.checked=blnAllCBChecked;
 
}

		