var numnewitm = newitms.length-1;
var transsec = 2; // change me
transsec = transsec*100;
var outtranssec = transsec/2;
var transaddon = outtranssec*9;
var imgstay = 7*1000; // change me
transaddon = imgstay+transaddon;
var imgidtrans = 'owcontimg'; // change me
var tout,toutb,toutc;
var newitmc = 0;
var newitmnow;

//placehold 1
var mousehove = 'owcontpop';
var mousecov = 'owcontpcov';
var continuedisp = imgstay/2;
var toutd;

var newitmres0 = '', newitmres1 = '', newitmres2 = '', newitmres3 = '', newitmres4 = '';

var toute;

function newitmchng()
{
 newitmnow = newitms[newitmc];
 $(imgidtrans).src = 'imgfix.php?img='+newitmnow;
 fadeIn(imgidtrans,0); 
 //$('nwitmbtn'+newitmc).className ='nwitmbtn nwitmbtndown';
 toutc = window.setTimeout("fadeOut('"+imgidtrans+"',1);",imgstay); //$('nwitmbtn"+newitmc+"').className ='nwitmbtn nwitmbtnup';
 toutb = window.setTimeout('newitmchng()',transaddon);
 if(newitmc==numnewitm) { newitmc = 0; } else { newitmc++; }
}

function chngepg(e) 
{ 
 if(newitmc==0) { lastbghigh = numnewitm; } else { lastbghigh = newitmc-1; }
 //window.location.href = "/"+newitmcats[lastbghigh]+"-"+newitmids[lastbghigh]; 
 aval = new Array();
 aname = new Array();
 aval[0] = newitmcats[lastbghigh];
 aname[0] = 'cat';
 aval[1] = newitmids[lastbghigh]+"-0";
 aname[1] = 'id';
 chnganchor(aval,aname,4);
}

function newitmforce(num)
{
 clearTimeout(tout);clearTimeout(toutb);clearTimeout(toutc);clearTimeout(toutd);
 if(newitmc==0) { lastbghigh = numnewitm; } else { lastbghigh = newitmc-1; }
 $('nwitmbtn'+lastbghigh).className ='nwitmbtn nwitmbtnup';
 newitmc = num;
 newitmchng();
}

//placehold 1

function mouseoverout(t) {
  if(newitmc==0) { lastbghigh = numnewitm; } else { lastbghigh = newitmc-1; }
  if(t=="mouseover") { 
	clearTimeout(toutb);clearTimeout(toutc);clearTimeout(toutd);clearTimeout(toute);
	requestdata(newitmids[lastbghigh], 'newitms', 0, 0, 0, 0, 0);
	$(mousehove).show();
	slideRight('toute',mousehove,0); 
  } else { 
	toutd = window.setTimeout("newitmforce('"+newitmc+"')",continuedisp);
	slideLeft('toute',mousehove,-167);
	$(mousehove).innerHTML = '';
  }
 return true;
}

//newitmids
var parsedres;
function requestdata(id, type, cat, num, order, active) {
new Ajax.Request('/data', 
{ 
	method:'post', 
	parameters: {t: type, id: id, c: cat, n: num, o: order, a: active},
	//postBody: 'id='+id+'&c='+type+'&n='+num+'&o='+order+'&a='+active+fields+fields2,
	onSuccess: function responsetxt(transport){
      parsedres = transport.responseText || "no response text";
	parsedres = parsedres.replace('undefined', '');
	$(mousehove).innerHTML = parsedres;
	},
	onFailure: function fail(){ alert('Server is Under Maintenance. Please Try Again Later.') }
});
}


function fadeIn(objid,opacityv) {
    if (opacityv < 1) {
      opacityv += .10;
      $(objid).setStyle({opacity:opacityv});
      tout = window.setTimeout("fadeIn('"+objid+"',"+opacityv+")", transsec);
    }
}

function fadeOut(objid,opacityv) {
    if (opacityv > .10) {
      opacityv -= .10;
      $(objid).setStyle({opacity:opacityv});
      tout = window.setTimeout("fadeOut('"+objid+"',"+opacityv+")", outtranssec);
    }
}

//placehold 2

function slideRight(timval,objid,x) {
 obj = $(objid);
 currPos = obj.offsetLeft;
   if(currPos < x){
   currval = x-currPos;
   currPos += (currval>10) ? 10 : currval;

	obj.setStyle({left:(currPos+'px')});

	eval("clearTimeout("+timval+");");
    eval(timval+" = setTimeout(\"slideRight('"+timval+"','"+objid+"',"+x+")\",30);");
   }
}
function slideLeft(timval,objid,x) {
 obj = $(objid);
 currPos = obj.offsetLeft;
   if(currPos > x){
   currval = currPos-x;
   currPos -= (currval>10) ? 10 : currval;

	obj.setStyle({left:(currPos+'px')});

	eval("clearTimeout("+timval+");");
   eval(timval+" = setTimeout(\"slideLeft('"+timval+"','"+objid+"',"+x+")\",30);");
   } else {
    $(objid).hide();
   }
}