function menu(seccion) {
	if (document.getElementById('publicar')) {
			switch(seccion)	{
					case 'vender':
						document.getElementById('publicar').className = 'menu_seleccionado';
						document.getElementById('publicar_menu').style.display = 'block';
				break;
					case 'buscar':
						document.getElementById('buscar').className = 'menu_seleccionado';
						document.getElementById('buscar_menu').style.display = 'block';
				break;
					case 'productos':
						document.getElementById('productos').className = 'menu_seleccionado';
						document.getElementById('productos_menu').style.display = 'block';
				break;
					case 'repuestos':
						document.getElementById('repuestos').className = 'menu_seleccionado';
						document.getElementById('repuestos_menu').style.display = 'block';
				break;
					case 'informacion':
						document.getElementById('informacion').className = 'menu_seleccionado';
						document.getElementById('informacion_menu').style.display = 'block';
				break;
					case 'servicios':
						document.all.servicios.background = '/images/v2_menu_servicios02.gif';
				break;
					case 'faq':
						document.all.faq.background = '/images/v2_menu_preguntas02.gif';
				break;
					default:
						document.getElementById('publicar').className = 'menu_seleccionado';
						document.getElementById('publicar_menu').style.display = 'block';
				break;
			}
		}
}

function redirect(id, page) {
		Window.open ('/includes/redirect.asp?id='+ id +'&page='+ page)
	}

function car_del(id) {
	if ( confirm("¿Está seguro que dese eliminar el auto definitivamente?") )
	document.location.href='/contenidos/center_post.asp?md=del&id='+id;
}

function car_ven(id) {
	if ( confirm("El auto pasará a verse como vendido. No podrá realizarle más cambios... ¿Está seguro?") )
	document.location.href='/contenidos/center_post.asp?md=vendido&id='+id;
}

function encuesta_del(id) {
	if ( confirm("¿Está seguro que dese eliminar la encuesta por completo definitivamente?") )
	document.location.href='?operation=delete&id='+id;
}

function encuesta_validar(form) {
	var f = form;
	var i;
	for(i=0;i<f.votes.length;i++) {
		if (f.votes[i].checked == true)
			return true;
	}
	alert('Debe seleccionar alguna opción!');
	return false;
}

function js_scroll(texto, w, h) {

	var stopped=0;
	var marqueewidth=w;
	var marqueeheight=h;
	var speed=1;
	var marqueecontents = '';

	marqueecontents = texto;

	originalspeed=speed;
	if (document.all)
	document.write('<marquee scrollAmount='+speed+' style="width:'+marqueewidth+'; height='+marqueeheight+'" direction=up id="marquesina">'+marqueecontents+'</marquee>')
	function regenerate(){
	window.location.reload()
	}
	function regenerate2(){
	if (document.layers){
		setTimeout("window.onresize=regenerate",400)
		intializemarquee()
	}
	}
	function intializemarquee(){
	document.cmarquee01.document.cmarquee02.document.write(marqueecontents)
	document.cmarquee01.document.cmarquee02.document.close()
	thelength=document.cmarquee01.document.cmarquee02.document.height
	scrollit()
	}
	function scrollit(){
	if ((document.cmarquee01.document.cmarquee02.top>=thelength*(-1)) && (document.cmarquee01.document.cmarquee02.top<=thelength)) {
	document.cmarquee01.document.cmarquee02.top-=speed
	setTimeout("scrollit()",100)
	}
	else if (document.cmarquee01.document.cmarquee02.top>thelength){
	document.cmarquee01.document.cmarquee02.top=thelength*(-1)
	scrollit()
	}
	else {
	document.cmarquee01.document.cmarquee02.top=thelength
	scrollit()
	}
	}
}

function js_scroll_parar() {
	document.all.marquesina.stop();
	stopped=1;
}

function js_scroll_seguir() {
	document.all.marquesina.start();
	stopped=0;
}

function up(file,id) {
	ow('/includes/uimage.asp?file='+file+'&id='+id,'upload','300','280')
}

function cargar_combo(file, sql, name, value, cid, cnm, rq, sel, nuevo){
	var scriptTag = document.getElementById('loadScript');
	var head = document.getElementsByTagName('head').item(0);
	script		= document.createElement('script');
	script.src	= file+'?cid='+cid+'&cnm='+cnm+'&sql='+sql+'&sel='+sel+'&vl='+value+'&rq='+rq+'&name='+name+'&nuevo='+nuevo;
	script.type = 'text/javascript';
	script.id	= 'loadScript';
	head.appendChild(script);
}

function ow(page, name, w, h) {
  window.open(page,name,"resizable=0,width="+w+",height="+h+",left=50,top=50,scrollbars=no");
}

function ows(page, name, w, h) {
  window.open(page,name,"resizable=0,width="+w+",height="+h+",left=50,top=50,scrollbars=yes");
}

function href(url) {
  document.location.href = url;
}

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_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_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 hrf(url) {
	document.location.href = url;
}

function o(td) {
	td.style.backgroundColor='';
}
function h(td) {
	td.style.backgroundColor='F0F0F0'; td.style.cursor="hand";
}

function flash(movie, w, h, flashvars) {
	document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ w +'" height="'+ h +'">');
	document.write ('	<param name="movie" value="'+ movie +'">');
	document.write ('	<param name="quality" value="high">');
	document.write ('	<param name="flashvars" value="'+ flashvars +'">');
	document.write ('	<param name="menu" value="0">');
	document.write ('	<embed src="'+ movie +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ w +'" height="'+ h +'"></embed>');
	document.write ('</object>');
}

function foco(obj) {
	if (obj) { obj.focus(); }
}

function charge_img(id,file) {
	MM_swapImage ('file1','','/dbimages/'+id+'_'+file+'.jpg',1);
}

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
	else
		countfield.value = maxlimit - field.value.length;
}
