function change_button(obj,txt){
// onsubmit="return change_button('submit')"
document.getElementById(obj).value = txt;
document.getElementById(obj).disabled = true;

return true;

}

function show_div(div_id){
	if (document.getElementById(div_id).style.display=="none"){
		document.getElementById(div_id).style.display = "";
	}else{
		document.getElementById(div_id).style.display = "none";
	}	
}

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		alert(" you have reached the Max Character lenght ");
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		//document.getElementById(limitCount).value = limitNum - limitField.value.length;
		document.getElementById(limitCount).innerHTML = "max characters "+ limitNum +": You have "+ (limitNum - limitField.value.length) +" left";
	}
}

function clean_txt(txt){
var str = txt
		while(str.indexOf("'")!=-1){
			str = str.replace("'","&quot;"); 
		}
		while(str.indexOf("&")!=-1){
			str = str.replace("#",""); 
		}
		return str;
		
}

function newWindow(url,mywidth,myheight) {
	var iMyWidth;
	var iMyHeight;
	//gets top and left positions based on user's resolution so hint window is centered.
	iMyWidth = (window.screen.width/2) - ((mywidth/2) + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
	iMyHeight = (window.screen.height/2) - ((myheight/2) + 50); //half the screen height minus half the new window height (plus title and status bars).
	var win2 = window.open(url,"Window3","status=0,height=" + myheight + ",width=" + mywidth + ",resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");
	win2.focus();
}
// Centred Window, Scrolling and Resizeable


function scrollWindow(url,mywidth,myheight) {
	var iMyWidth;
	var iMyHeight;
	//gets top and left positions based on user's resolution so hint window is centered.
	iMyWidth = (window.screen.width/2) - ((mywidth/2) + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
	iMyHeight = (window.screen.height/2) - ((myheight/2) + 50); //half the screen height minus half the new window height (plus title and status bars).
	var win2 = window.open(url,"Window3","status=0,height=" + myheight + ",width=" + mywidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");
	win2.focus();
}
// Centred Window, Scrolling and Not Resizeable



function deadWindow(url,mywidth,myheight) {
	var iMyWidth;
	var iMyHeight;
	//gets top and left positions based on user's resolution so hint window is centered.
	iMyWidth = (window.screen.width/2) - ((mywidth/2) + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
	iMyHeight = (window.screen.height/2) - ((myheight/2) + 50); //half the screen height minus half the new window height (plus title and status bars).
	var win2 = window.open(url,"Window3","status=0,height=" + myheight + ",width=" + mywidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no,titlebar=no");
	win2.focus();
}
//Centred Window, No Scrolling and Not Resizeable


// The next script opens up a new window in full screen mode in EI
function fullWindow(url) 
{

 	var resize = '';							// Set the defaults
  	var titlebar = '';
	var wvalue = screen.width - 7;
  	var hvalue = screen.height - 75;
   
  	if (navigator.appName == 'Netscape') 
  	{	           
		if (screen.height >= 600) // 800 x 600 or greater
		{			           
			wvalue = 798;
			hvalue = 572;
		} 
			
		else // 640 x 480
		{							               
			hvalue = hvalue - 2;
		}		
		  
		titlebar = ',titlebar=0';
		resize = ',resizable';
	} 
		
	else 
	{								               
		resize = ',resizable';
	}

		window.open(url,'websearch','top=0,toolbar=yes,left=0,scrollbars=yes,status=yes,width=' + wvalue + ',height=' + hvalue + resize + titlebar + ',hotkeys=0');
  
	
	 																							//set variables and open logon window and splash page for red sheriff survey
	if (navigator.appName == 'Netscape') // Netscape
	{	           
		if (screen.height >= 600) // 800 x 600 or greater
		{			           
			wvalue = 798;
			hvalue = 572;
		} 
			
		else 
		{
			hvalue = hvalue - 2;
		}		
		  
		titlebar = ',titlebar=0';
		resize = ',resizable';
	 } 
	
	  
	 else // MS Internet Explorer.
	  	{								               
	  		resize = ',resizable';
	  	}                 
}

/// check this out ///
if (!document.layers&&!document.all)
event="test"
function showtip2(current,e,text){

	if (document.all){
	//alert(event.clientX);
	//alert(document.body.scrollLeft);
	//document.all.tooltip2.innerHTML='<marquee style="border:1px solid black">'+text+'</marquee>'
	document.all.tooltip2.innerHTML='<div style="border:1px solid black">'+text+'</div>';
	document.all.tooltip2.style.pixelLeft=event.clientX+document.body.scrollLeft+10;
	document.all.tooltip2.style.pixelTop=event.clientY+document.body.scrollTop+10;
	document.all.tooltip2.style.visibility="visible";
	}

	else if (document.layers){
	document.tooltip2.document.nstip.document.write('<b>'+text+'</B>')
	document.tooltip2.document.nstip.document.close()
	document.tooltip2.document.nstip.left=0
	currentscroll=setInterval("scrolltip()",100)
	document.tooltip2.left=e.pageX+10
	document.tooltip2.top=e.pageY+10
	document.tooltip2.visibility="show"
	}
}

function hidetip2(){
	if (document.all)
	document.all.tooltip2.style.visibility="hidden"
	else if (document.layers){
	clearInterval(currentscroll)
	document.tooltip2.visibility="hidden"
	}
}

function scrolltip(){
if (document.tooltip2.document.nstip.left>=-document.tooltip2.document.nstip.document.width)
document.tooltip2.document.nstip.left-=5
else
document.tooltip2.document.nstip.left=150
}


function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function


function activate(){
document.form1.suburb.disabled= false;
document.form1.region6.disabled=false;
}
function deActivate(){
document.form1.suburb.disabled= true;
document.form1.region6.disabled=true;
}
function workonIt(){
if (document.form1.region1.checked==true || document.form1.region2.checked==true || document.form1.region3.checked==true || document.form1.region4.checked==true || document.form1.region5.checked==true ){deActivate(); }else{activate();}
}

// -------------------- scrolling right and left ---------------------------------
var sRepeat=null;
var cur_place=0;
function doScrollerIE(dir, src, amount) {
//alert(amount +" - "+ src + "-" +dir);
	if (amount==null) { amount=10; }
	if (dir=="left") { document.all[src].scrollLeft -=amount }
	else { document.all[src].scrollLeft +=amount } 
	    cur_place = document.all[src].scrollLeft;
	return false
}

//---------------------------------------------------------------------------------------------------------
var sRepeat_f=null;
var cur_place_f=0;
function doScrollerIE_f(dir, src, amount) {
	if (amount==null) { amount=10; }
	if (dir=="left"){ document.all[src].scrollLeft-=amount }else{ document.all[src].scrollLeft+=amount }
		cur_place_f = document.all[src].scrollLeft;
	return false
}

// --------------- srcolling div top and bottom ---------------------------
var ourInterval;
var origColor = "#F3F9F1";
var overColor = "#36FF00";
var scrollSpeed = 60;
var scrollHeight = 5;

function scrollStart(direction, divID, elementID){
//CHANGE THE BACKGROUND COLOR OF THE TD THE MOUSE IS OVER
//document.getElementById(elementID).style.backgroundColor = overColor;
// REPEATED CALL EITHER scrollUp OR scrollDown
ourInterval = setInterval("scroll"+direction+"('"+divID+"')", scrollSpeed);
}
function scrollEnd(which){
// OUR MOUSE IS OUT, SO RETURN TD TO ORIGINAL COLOR
//document.getElementById(which).style.backgroundColor = origColor;
// STOP CALLING THE SCROLL FUNCTION
clearInterval(ourInterval);
}


function scrollUp(which){
// SET THE SCROLL TOP
document.getElementById(which).scrollTop = document.getElementById(which).scrollTop - scrollHeight;
}
function scrollDown(which){
// SET THE SCROLL TOP
document.getElementById(which).scrollTop = document.getElementById(which).scrollTop + scrollHeight;
}
