var imgcount=1;

function changeimagesStart() {
	s = setTimeout('changeimages()',3000);
}

function moveImageCount() {
	if (imgcount==5) 
		{
		imgcount=1;
		}
	else	
		{
		imgcount+=1;
		}

	if (counter==maxImage) 
		{
		counter=1;
		}
	else	
		{
		counter+=1;
		}
}

function changeimages() {

var imgObj = (document.getElementById) ? document.getElementById('img' + imgcount) : eval("document.all['img" + imgcount + "']");
var saf = /Safari/.test(navigator.userAgent);
window.onerror=movePicError;

	if (saf) {
		movePicError();
	}
	else
	{
		if (imgObj.filters.blendTrans)
			{
			Blendimg(imgObj,sLoadRootFolder+"images/topimages/topimages"+counter+".jpg");
			}
		else
			{
			imgObj.src=sLoadRootFolder+"images/topimages/topimages"+counter+".jpg";
			}	

		moveImageCount();
	 	s = setTimeout('changeimages()',3000);
	}
}

function movePicError() {
	var imgObj = (document.getElementById) ? document.getElementById('img' + imgcount) : eval("document.all['img" + imgcount + "']");
	imgObj.src=sLoadRootFolder+"images/topimages/topimages"+counter+".jpg";
	moveImageCount();
	s = setTimeout('movePicOLD()',3000);
	return true;
}

function movePicOLD() {
	var imgObj = (document.getElementById) ? document.getElementById('img' + imgcount) : eval("document.all['img" + imgcount + "']");
	imgObj.src=sLoadRootFolder+"images/topimages/topimages"+counter+".jpg";
	moveImageCount();
	s = setTimeout('movePicOLD()',3000);
}
function Blendimg(i, newsrc)
{	
	i.filters.blendTrans.Apply();
	i.src = newsrc;
	i.filters.blendTrans.Play();
}

function hoverPage(page) {

var mainObj = (document.getElementById) ? document.getElementById('pg' + page) : eval("document.all['pg" + page + "']");
var leftObj = (document.getElementById) ? document.getElementById('led' + page) : eval("document.all['led" + page + "']");
var rightObj = (document.getElementById) ? document.getElementById('red' + page) : eval("document.all['red" + page + "']");

if (mainObj.className=='pageTab')
	{
	mainObj.className='pageTabHover';
	leftObj.className='pageTabLeftHover';
	rightObj.className='pageTabRightHover';
	}
else
	{
	mainObj.className='pageTab';		
	leftObj.className='pageTabLeft';
	rightObj.className='pageTabRight';
	}
}

function resizeTopBar() {

var winW = 630, winH = 460;

if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth-16;
  winH = window.innerHeight-16;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth-20;
  winH = document.body.offsetHeight-20;
 }
}

if (winW > 980)
	{
	pageTable.style.width=winW-17;
	}
else
	{
	pageTable.style.width=965;
	}
}

function displayEvents(theMouseX,theMouseY,theEventList) {
			
	//If (theMouseX < 220)
	//{
	//theEventList.style.left = (theMouseX - 15);
	//}
	//Else
	//{
	//theEventList.style.left = (theMouseX - (theEventList / 2)-97);
	//}
	theEventList.style.left = (theMouseX - 15);
	theEventList.style.top = (theMouseY - 15);
	theEventList.style.display = "block";

}


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_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_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_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 validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos< 
   
2) {alert(alerttxt);return false}
else
{return
true} }
}
function validate_required(field,alerttxt)
{
with (field){if(value==null||value=="")
  {alert(alerttxt);return false}
else {return true}
}
}

function validate_form(thisform)

{
with (thisform)
{
   
if (validate_required(cboAdType,"You must select the advert type!")==false)
  {cboAdType.focus();return false}

if (validate_required(txtTitle,"You must input the item title!")==false)
  {txtTitle.focus();return false}

if (validate_required(cboCategory,"You must select the Category for the item!")==false)
  {cboCategory.focus();return false}

if (divSimpleBox.style.display=="")
{	
if (validate_required(txtDetails,"You must input a description for the item!")==false)
  {txtDetails.focus();return false}
}

//if (divAdvancedBox.style.display=="")
//{	
//if (validate_required(txtDetailsAdv,"You must input a description for the item!")==false)
//  {freeRTE.focus();return false}
//}

if (validate_required(cboCondition,"You must select a condition for the item!")==false)
  {cboCondition.focus();return false}

if (validate_required(txtPrice,"You must input the price for the item!")==false)
  {txtPrice.focus();return false}
  
if (validate_required(cboContact,"You must select how you would like to be contacted!")==false)
  {cboContact.focus();return false}

if (validate_required(txtName,"You must input your name!")==false)
  {txtName.focus();return false}
  
if (validate_required(txtNumber,"You must input your phone number!")==false)
  {txtNumber.focus();return false}

if (validate_required(txtEmail,"You must input your email address!")==false)
  {txtEmail.focus();return false}  

 
if (validate_email(txtEmail,"Not a valid e-mail address!")==false)
  {txtEmail.focus();return false}

}
}

