

///////show hide for trade_user3
function hide() {
var div_ref = document.getElementById("ex_ops");
div_ref.style.visibility = "hidden";
var div_ref = document.getElementById("ex_op1");
div_ref.checked = "";
}

function show() {
var div_ref = document.getElementById("ex_ops");
div_ref.style.visibility = "visible";
}


////simple clear text in box if its 'x' function used in add pages
function wnu_show() {
var div_ref = document.getElementById("full_desc");
if (div_ref.value == 'Type your description here....')
{
div_ref.value = "";
}
}

////simple clear text in box if its 'x' functionused in index
function wnu_show2() {
var div_ref = document.getElementById("wnupc");
if (div_ref.value == 'Postcode..')
{
div_ref.value = "";
} 
if (div_ref.value == 'Model..')
{
div_ref.value = "";
}
}

////simple colour setter for if box in focus for use on directory.php
function wnu_tone() {
var sez = document.getElementById("sbix");
if (sez.value != '')
{
sez.style.backgroundColor = "#01ff43";
}
if (sez.value == "")
{
sez.style.backgroundColor = "#487f37";
}
}
////simple clear text for other box
<!--
function wnu_show3() {
var div_ref = document.getElementById("full_desc");
if (div_ref.value == " You cannot send blank messages!")
{
div_ref.value = "";
} 
}
//!-->


/////hide box if 'NA' or 'OLDER' is selected
function wnu_reg() {
var div_ref = document.getElementById("year");
if (div_ref.value == 'N/A' || div_ref.value == 'Older')
{
var hider = document.getElementById("reg");
hider.style.visibility = "hidden";
hider.value = "";
} 
else
{
var hider = document.getElementById("reg");
hider.style.visibility = "visible";
}
}

/////hide opisite box if 'reg' or 'year' is selected (insurance_groups.php)
function wnu_insure(arrr) {
var div_yr = document.getElementById("year");
var div_rg = document.getElementById("reg");
var div_yy = document.getElementById("yr");
var div_yyr = document.getElementById("yyr");
var div_search = document.getElementById("srchres");
if (arrr == 'year') {
		if (div_yy.value != 'nochoose')
		{
 		 div_rg.style.visibility = "hidden";
		} 
		if (div_yy.value == 'nochoose')
		{
 		 div_rg.style.visibility = "visible";
		} 
}
if (arrr == 'reg') {
		if (div_yyr.value != 'nochoose')
		{
 		 div_yr.style.visibility = "hidden";
		} 
		if (div_yyr.value == 'nochoose')
		{
 		 div_yr.style.visibility = "visible";
		} 
}
if (arrr == 'show') { div_search.style.visibility = "visible"; }
}


/////GENERIC HIDER - USE FOR ALL NEW HIDE
function wnu_omg(zzz,x,aaa,b) {
var div_yr = document.getElementById(zzz);
		if (x == 1)
		{
 		 div_yr.style.visibility = "visible";
		} 
		if (x == 0)
		{
 		 div_yr.style.visibility = "hidden";
		} 

		
}
/////GENERIC CHANGER - USE FOR ALL NEW CHANGES
function wnu_wtf(aaa) {
var grrr = document.getElementById(aaa);		
		grrr.checked = "";
}
/////GENERIC bg COLOUR CHANGER - USE FOR ALL bg COLOUR CHANGES
function wnu_omfg(aaa,g) {
var grrr = document.getElementById(aaa);		
		grrr.style.backgroundColor = g;
}


function  validateNumeric( strValue ) {
/*****************************************************************
DESCRIPTION: Validates that a string contains only valid numbers.

PARAMETERS:
 strValue - String to be tested for validity

RETURNS:
 True if valid, otherwise false.
******************************************************************/
var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;

//check for numeric characters
return objRegExp.test(strValue);
}



///sends form on browse
function woodsend() {
document.getElementById('search_form').submit();
}

////deviation of woodsend - think out of use - kept incase need later from browse_cars.php - IS USED (distance.php
function woodsendx(a) {
var div_ref = document.getElementById("ordbym");
div_ref.value = a;
document.getElementById('search_form').submit();
}

////show hide for various pages e.g. browse
<!--
	function show_hide(tblid, show) {
		if (tbl = document.getElementById(tblid)) {
			if (null == show) show = tbl.style.display == 'none';
			tbl.style.display = (show ? '' : 'none');
		}
	}
//!-->
///for view etc - 'ask seller a question' 
/***********************************************
* Highlight Table Cells Script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Specify highlight behavior. "TD" to highlight table cells, "TR" to highlight the entire row:
var highlightbehavior="TD"

var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e,highlightcolor){
source=ie? event.srcElement : e.target
if (source.tagName=="TABLE")
return
while(source.tagName!=highlightbehavior && source.tagName!="HTML")
source=ns6? source.parentNode : source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor
}

function contains_ns6(master, slave) { //check if slave is contained by master
while (slave.parentNode)
if ((slave = slave.parentNode) == master)
return true;
return false;
}

function changeback(e,originalcolor){
if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
source.style.backgroundColor=originalcolor
}




/////IMAGE POPUPS FOR View, preview etc

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 700;
defaultHeight = 700;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){'); 
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}



function SDMenu(id) {
if (!document.getElementById || !document.getElementsByTagName)
return false;
this.menu = document.getElementById(id);
this.submenus = this.menu.getElementsByTagName("div");
this.remember = true;
this.speed = 3;
this.markCurrent = true;
this.oneSmOnly = false;
}
SDMenu.prototype.init = function() {
var mainInstance = this;
for (var i = 0; i < this.submenus.length; i++)
this.submenus[i].getElementsByTagName("span")[0].onclick = function() {
mainInstance.toggleMenu(this.parentNode);
};
if (this.markCurrent) {
var links = this.menu.getElementsByTagName("a");
for (var i = 0; i < links.length; i++)
if (links[i].href == document.location.href) {
links[i].className = "current";
break;
}
}
if (this.remember) {
var regex = new RegExp("sdmenu_" + encodeURIComponent(this.menu.id) + "=([01]+)");
		var match = regex.exec(document.cookie);
		if (match) {
			var states = match[1].split("");
			for (var i = 0; i < states.length; i++)
				this.submenus[i].className = (states[i] == 0 ? "collapsed" : "");
		}
	}
};
SDMenu.prototype.toggleMenu = function(submenu) {
	if (submenu.className == "collapsed")
		this.expandMenu(submenu);
	else
		this.collapseMenu(submenu);
};
SDMenu.prototype.expandMenu = function(submenu) {
	var fullHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var links = submenu.getElementsByTagName("a");
	for (var i = 0; i < links.length; i++)
		fullHeight += links[i].offsetHeight;
	var moveBy = Math.round(this.speed * links.length);
	
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight + moveBy;
		if (newHeight < fullHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "";
			mainInstance.memorize();
		}
	}, 30);
	this.collapseOthers(submenu);
};
SDMenu.prototype.collapseMenu = function(submenu) {
	var minHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var moveBy = Math.round(this.speed * submenu.getElementsByTagName("a").length);
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight - moveBy;
		if (newHeight > minHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "collapsed";
			mainInstance.memorize();
		}
	}, 30);
};
SDMenu.prototype.collapseOthers = function(submenu) {
	if (this.oneSmOnly) {
		for (var i = 0; i < this.submenus.length; i++)
			if (this.submenus[i] != submenu && this.submenus[i].className != "collapsed")
				this.collapseMenu(this.submenus[i]);
	}
};
SDMenu.prototype.expandAll = function() {
	var oldOneSmOnly = this.oneSmOnly;
	this.oneSmOnly = false;
	for (var i = 0; i < this.submenus.length; i++)
		if (this.submenus[i].className == "collapsed")
			this.expandMenu(this.submenus[i]);
	this.oneSmOnly = oldOneSmOnly;
};
SDMenu.prototype.collapseAll = function() {
	for (var i = 0; i < this.submenus.length; i++)
		if (this.submenus[i].className != "collapsed")
			this.collapseMenu(this.submenus[i]);
};
SDMenu.prototype.memorize = function() {
	if (this.remember) {
		var states = new Array();
		for (var i = 0; i < this.submenus.length; i++)
			states.push(this.submenus[i].className == "collapsed" ? 0 : 1);
		var d = new Date();
		d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
		document.cookie = "sdmenu_" + encodeURIComponent(this.menu.id) + "=" + states.join("") + "; expires=" + d.toGMTString() + "; path=/";
	}
};