$(document).ready(function()
{ 
	llenarformularios()
	
	$(".loginHeaderClose").click(function()
	{
		$(".loginHeader").slideUp();
		ajax("registerCLoseHeaderFB","inDivBlack","");
	});
	
	$(".fbloginurl").click(function()
	{
		//alert(this.href)
		//window.open(this.href,"facebookconet");
		signinWin = window.open(this.href, "SignIn", "width=780,height=600,toolbar=0,scrollbars=0,status=0,resizable=0,location=0,menuBar=0,left=20,top=20");
		return false;
		
	});

 	$(".btngarvendido").click(function()
	{
		var anuncioIDValSplitter = (this.id).split("-");
		var anuncioIDVal = anuncioIDValSplitter[1];
		
		$.colorbox(
		{
			width:"400px", 
			height:"500px", 
			iframe:true, 
			overlayClose:false,
			scrolling:false,
			href:SERVER_NAME+"inc/soldout_seller.php?a="+anuncioIDVal,
			onComplete:function()
			{
				
			}		
		});
		
	});
	
	$(".actfollownmark").click(function()
	{
		var cagoriaIDValSplitter = (this.id).split("-");
		var categoriaIDVal = cagoriaIDValSplitter[1];
		if(!$(this).attr("disable"))
		{
			if($(this).hasClass("current"))
			{
				$( "#dialog:ui-dialog" ).dialog( "destroy" );
				$("#inDiv_html_delete").html('<span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>¿Estás seguro de dejar de seguir esta marca?');
				$( "#dialog-confirm-delete" ).dialog({
					resizable: false,
					modal: true,
					buttons: {
						"Dejar de seguir": function()
						{
							ajax("follow_marck","inDivBlack","m="+categoriaIDVal,categoriaIDVal);
							$( this ).dialog( "close" );
						},
						"Cancelar": function()
						{
							$( this ).dialog( "close" );
						}
					}
				});
			}else
			{
				ajax("follow_marck","inDivBlack","m="+categoriaIDVal,categoriaIDVal);
			}		
		}else
		{
			//alertUI("Esta procesando")
		}
	});
	
	$(".actfollowncat").click(function()
	{
		var cagoriaIDValSplitter = (this.id).split("-");
		var categoriaIDVal = cagoriaIDValSplitter[1];
		
		if(!$(this).attr("disable"))
		{
			if($(this).hasClass("current"))
			{
				$( "#dialog:ui-dialog" ).dialog( "destroy" );
				$("#inDiv_html_delete").html('<span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>¿Estás seguro de dejar de seguir esta categoría?');
				$( "#dialog-confirm-delete" ).dialog({
					resizable: false,
					//height:140,
					modal: true,
					buttons: {
						"Dejar de seguir": function()
						{
							ajax("follow_cat","inDivBlack","c="+categoriaIDVal,categoriaIDVal);
							$( this ).dialog( "close" );
						},
						"Cancelar": function()
						{
							$( this ).dialog( "close" );
						}
					}
				});
			}else
			{
				ajax("follow_cat","inDivBlack","c="+categoriaIDVal,categoriaIDVal);
			}
		
		}else
		{
			//alertUI("Esta procesando")
		}
		
	});
		
		
	$("#inusFollowingAn").click(function()
	{		
		$.colorbox(
		{
			width:"400px", 
			height:"500px", 
			iframe:false, 
			overlayClose:false,
			scrolling:false,
			href:SERVER_NAME+"inc/following.php",
			onComplete:function()
			{
				reloadCufon();
			}		
		});
	});
	
	$(".seguir-anuncio_n").click(function()
	{
		var anuncioIDValSplitter = (this.id).split("-");
		var anuncioIDVal = anuncioIDValSplitter[1];	
		$.colorbox(
		{
			width:"350px", 
			height:"500px", 
			iframe:false, 
			overlayClose:false,
			scrolling:true,
			href:SERVER_NAME+"inc/followers.php?tipo=A&id="+anuncioIDVal,
			onComplete:function()
			{
				reloadCufon();
			}		
		});
	});
		  
	$(".seguir-noticia_n").click(function()
	{
		$.colorbox(
		{
			width:"350px", 
			height:"500px", 
			iframe:false, 
			overlayClose:false,
			scrolling:true,
			href:SERVER_NAME+"inc/followers.php?tipo=N&id=0",
			onComplete:function()
			{
				reloadCufon();
			}		
		});
	});
				  
	// *** Tabs Buscador
    $(".tabs li a.tab").click(function () {  
        $("ul.tabs li a.active").removeClass("active");  
        $(this).addClass("active");  
        $(".tabContent").slideUp();  
        var content_show = $(this).attr("rel");  
        $("#"+content_show).slideDown();  
    });  
  
  	//*** Hover Boton
	$('button.ui-button').hover(
		function() {
			var self = $(this);
			if ((self.attr('disabled') != 'disabled') || (self.attr('disabled') != false))
				self.addClass('hover');
		},
		function() {
			$(this).removeClass('hover');
		}
	);
	
	//** slideUp SideBar
	
	

	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	$(".modToggle .modTogglehead").click(function()
	{
		if($("h2",this).hasClass("active"))
		{
			closeAllmenu("");
			
			$(this).next().hide();
			
			objetasdfad = $(this).next().toggle('slow');
			
			// $("div:hidden").show("fast");
			//alert($(this).next().css("display"))
			if($(this).next().css("display") == "block")
			{
				$("span",this).hide();
				
			}else
			{
				$("span",this).show();
			}
		}
		
		
		return false;
		
		
	});
	
	$(".modToggle").click(function()
	{
		
		$(this).removeClass("frmerror");
		
		//return false;
		
		
	});
	
	$(".modToggle").keyup(function()
	{
		
		$(this).removeClass("frmerror");
	
	});	
	
}); 

var v_lastvalue =  new Array();

function closeAllmenu(numopen,textcurrentopen,txtnextopen)
	{
		var contador = 1;
		$('.modToggle .modTogglehead').each(function()
		{
			
			$(this).next().hide("fast");
			//alert($(this).next().css("display"))
			if($(this).next().css("display") == "block")
			{
				$("span",this).show();
			}
			
			if(numopen>0)
			{
				if(numopen-1 == contador)
				{
					//textcurrentopen = $("input",this).val() ;
					v_lastvalue[contador] = textcurrentopen;
					$("span",this).html(textcurrentopen);
					$("span",this).addClass("active");
					$("span",this).show();
				}				
			}
			
			if( numopen != "" )
			{
				if(numopen == contador)
				{
					$(this).next().show("fast");
					//$.scrollTo(".modToggle",800);
					$("h2",this).addClass("active");
					reloadCufon();
					consil = true;	
					if(txtnextopen != "")
					{
						//txtnextopen = $("input",this).val() ;
						$("span",this).html(txtnextopen);						
						$("span",this).show();
					}else
					{
						$("span",this).hide();
					}
					
					$(this).next("input").focus();
				}
			}
			contador++;
			
	    });
		
		
	}
	
	var consil = true;
			function setKmm(ob)
			{
				if(consil)
				{
					closeAllmenu(5,number_format(ob.value)+' Km','');
				}
				consil = false;
			}
			
			function verificarKeyKm(e,ob)
			{
				consil = true;
				//alert(e.keyCode)
				if(e.keyCode == 13)
				{
					consil = true;	
					setKmm(ob)				
					$("#a_precio").focus();
				}else
				{
					return false
				}
				
			}
			
			function verificarKeyKmEdit(e,ob)
			{
				consil = true;
				//alert(e.keyCode)
				if(e.keyCode == 13)
				{
					consil = true;	
					setKmm(ob)			
					
				}else
				{
					return false
				}
				
			}
			
			function verificarKeyPrice(e,ob)
			{
				//alert(e.keyCode)
				if(e.keyCode == 13)
				{
					setPricVent(ob)
				}else
				{
					return false
				}
				
			}
			
			function isEnter(e)
			{
				if(e.keyCode == 13)
				{
					return false;
				}else
				{
					return true;
				}
			}
	
	function openAllmenu(numopen)
	{
		var contador = 1;
		$('.modToggle .modTogglehead').each(function()
		{			
			if( numopen != "" )
			{
				if(numopen == contador)
				{
					$(this).next().show("fast");
					$("span",this).hide();
					
				}
			}
			contador++;
			
	    });
		
		
	}
	
	function markBoxEmpty()
	{
		
		$('.modToggle').each(function()
		{
			//$(".colMarcaL label input",this).addClass("noseeeeeee");
			//alert($(".toggleContainer .colMarcaL label input",this).attr('class').match("frmerror"))
			//alert($("input",this).attr("class"));
			if($("input",this).hasClass("frmerror"))
			{
				$(this).addClass("frmerror");
			}else
			{
				//alert("false")
				//$(this).removeClass("frmerror");
			}			
			
	    });
		
		
	}

function basename (path, suffix) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ash Searle (http://hexmen.com/blog/)
    // +   improved by: Lincoln Ramsay
    // +   improved by: djmix
    // *     example 1: basename('/www/site/home.htm', '.htm');
    // *     returns 1: 'home'
    // *     example 2: basename('ecra.php?p=1');
    // *     returns 2: 'ecra.php?p=1'
    var b = path.replace(/^.*[\/\\]/g, '');

    if (typeof(suffix) == 'string' && b.substr(b.length - suffix.length) == suffix) {
        b = b.substr(0, b.length - suffix.length);
    }

    return b;
}


function urlencode (str) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Lars Fischer
    // +      input by: Ratheous
    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Joris
    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
    // %          note 1: This reflects PHP 5.3/6.0+ behavior
    // %        note 2: Please be aware that this function expects to encode into UTF-8 encoded strings, as found on
    // %        note 2: pages served as UTF-8
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
    // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
    str = (str + '').toString();

    // Tilde should be allowed unescaped in future versions of PHP (as reflected below), but if you want to reflect current
    // PHP behavior, you would need to add ".replace(/~/g, '%7E');" to the following.
    return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
    replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}

function strip_tags (input, allowed) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Luke Godfrey
    // +      input by: Pul
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +      input by: Alex
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Marc Palau
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Eric Nagel
    // +      input by: Bobby Drake
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Tomasz Wesolowski
    // +      input by: Evertjan Garretsen
    // +    revised by: RafaÅ‚ Kukawski (http://blog.kukawski.pl/)
    // *     example 1: strip_tags('<p>Kevin</p> <br /><b>van</b> <i>Zonneveld</i>', '<i><b>');
    // *     returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>'
    // *     example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>');
    // *     returns 2: '<p>Kevin van Zonneveld</p>'
    // *     example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>");
    // *     returns 3: '<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>'
    // *     example 4: strip_tags('1 < 5 5 > 1');
    // *     returns 4: '1 < 5 5 > 1'
    // *     example 5: strip_tags('1 <br/> 1');
    // *     returns 5: '1  1'
    // *     example 6: strip_tags('1 <br/> 1', '<br>');
    // *     returns 6: '1  1'
    // *     example 7: strip_tags('1 <br/> 1', '<br><br/>');
    // *     returns 7: '1 <br/> 1'
    allowed = (((allowed || "") + "").toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join(''); // making sure the allowed arg is a string containing only tags in lowercase (<a><b><c>)
    var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,
        commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;
    return input.replace(commentsAndPhpTags, '').replace(tags, function ($0, $1) {
        return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '';
    });
}

function roundjs ( val, precision ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +    revised by: Onno Marsman
    // *     example 1: round(1241757, -3);
    // *     returns 1: 1242000
    // *     example 2: round(3.6);
    // *     returns 2: 4
 
    return parseFloat(parseFloat(val).toFixed(precision));
}

function number_format (number, decimals, dec_point, thousands_sep) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://getsprink.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +     bugfix by: Howard Yeend
    // +    revised by: Luke Smith (http://lucassmith.name)
    // +     bugfix by: Diogo Resende
    // +     bugfix by: Rival
    // +      input by: Kheang Hok Chin (http://www.distantia.ca/)
    // +   improved by: davook
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Jay Klehr
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Amir Habibi (http://www.residence-mixte.com/)
    // +     bugfix by: Brett Zamir (http://brett-zamir.me)
    // +   improved by: Theriault
    // +      input by: Amirouche
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: number_format(1234.56);
    // *     returns 1: '1,235'
    // *     example 2: number_format(1234.56, 2, ',', ' ');
    // *     returns 2: '1 234,56'
    // *     example 3: number_format(1234.5678, 2, '.', '');
    // *     returns 3: '1234.57'
    // *     example 4: number_format(67, 2, ',', '.');
    // *     returns 4: '67,00'
    // *     example 5: number_format(1000);
    // *     returns 5: '1,000'
    // *     example 6: number_format(67.311, 2);
    // *     returns 6: '67.31'
    // *     example 7: number_format(1000.55, 1);
    // *     returns 7: '1,000.6'
    // *     example 8: number_format(67000, 5, ',', '.');
    // *     returns 8: '67.000,00000'
    // *     example 9: number_format(0.9, 0);
    // *     returns 9: '1'
    // *    example 10: number_format('1.20', 2);
    // *    returns 10: '1.20'
    // *    example 11: number_format('1.20', 4);
    // *    returns 11: '1.2000'
    // *    example 12: number_format('1.2000', 3);
    // *    returns 12: '1.200'
    // *    example 13: number_format('1 000,50', 2, '.', ' ');
    // *    returns 13: '100 050.00'
    // Strip all characters but numerical ones.
    number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
    var n = !isFinite(+number) ? 0 : +number,
        prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
        sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
        dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
        s = '',
        toFixedFix = function (n, prec) {
            var k = Math.pow(10, prec);
            return '' + Math.round(n * k) / k;
        };
    // Fix for IE parseFloat(0.55).toFixed(0) = 0;
    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
    if (s[0].length > 3) {
        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
    }
    if ((s[1] || '').length < prec) {
        s[1] = s[1] || '';
        s[1] += new Array(prec - s[1].length + 1).join('0');
    }
    return s.join(dec);
}

function explode (delimiter, string, limit) {
    // http://kevin.vanzonneveld.net
    // +     original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: kenneth
    // +     improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: d3x
    // +     bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: explode(' ', 'Kevin van Zonneveld');
    // *     returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
    // *     example 2: explode('=', 'a=bc=d', 2);
    // *     returns 2: ['a', 'bc=d']
    var emptyArray = {
        0: ''
    };

    // third argument is not required
    if (arguments.length < 2 || typeof arguments[0] == 'undefined' || typeof arguments[1] == 'undefined') {
        return null;
    }

    if (delimiter === '' || delimiter === false || delimiter === null) {
        return false;
    }

    if (typeof delimiter == 'function' || typeof delimiter == 'object' || typeof string == 'function' || typeof string == 'object') {
        return emptyArray;
    }

    if (delimiter === true) {
        delimiter = '1';
    }

    if (!limit) {
        return string.toString().split(delimiter.toString());
    } else {
        // support for limit argument
        var splitted = string.toString().split(delimiter.toString());
        var partA = splitted.splice(0, limit - 1);
        var partB = splitted.join(delimiter.toString());
        partA.push(partB);
        return partA;
    }
}

function implode (glue, pieces) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Waldo Malqui Silva
    // +   improved by: Itsacon (http://www.itsacon.net/)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: implode(' ', ['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: 'Kevin van Zonneveld'
    // *     example 2: implode(' ', {first:'Kevin', last: 'van Zonneveld'});
    // *     returns 2: 'Kevin van Zonneveld'
    var i = '',
        retVal = '',
        tGlue = '';
    if (arguments.length === 1) {
        pieces = glue;
        glue = '';
    }
    if (typeof(pieces) === 'object') {
        if (Object.prototype.toString.call(pieces) === '[object Array]') {
            return pieces.join(glue);
        } else {
            for (i in pieces) {
                retVal += tGlue + pieces[i];
                tGlue = glue;
            }
            return retVal;
        }
    } else {
        return pieces;
    }
}


function confirmUI(txt,url)
	{
		$( "#dialog:ui-dialog" ).dialog( "destroy" );
		$("#inDiv_html_delete").html('<span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>'+txt);
		$( "#dialog-confirm-delete" ).dialog({
			resizable: false,
			//height:140,
			modal: true,
			buttons: {
				"Continuar": function()
				{					
					$( this ).dialog( "close" );
					document.location = url;
					
				},
				"Cancelar": function() {
					$( this ).dialog( "close" );
					return false;
				}
			}
		});
		return false;
	}
	
	function setCategoria(idactive)
	{
		val_current_cat = $("#a_categoria").val();
		
		if(val_current_cat != "")
		{
			$("#inDiv_categoria_"+val_current_cat).removeClass("active");
		}
		
		$("#inDiv_categoria_"+idactive).addClass("active");
		$("#a_categoria").val(idactive);
		//$(".sCategoria_content").removeClass("frmerror");
		$(".sCategoria").removeClass("frmerror");
	}
	
function alertUI(html,isscrollto,url)
	{
		$( "#dialog:ui-dialog" ).dialog( "destroy" );
			$("#inDiv_html_delete").html('<span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>'+html);
			$( "#dialog-confirm-delete" ).dialog({
				resizable: false,
				//height:140,
				title:"Alerta",
				modal: true,
				position:"center",
				dialogClass:"uialertfrm", 
				buttons: {
					"Cerrar": function()
					{
						$( this ).dialog( "close" );
						if(isscrollto == true)
						{
							$.scrollTo(".wrapMain",800);
						}
						
					}
					
				}
			});
	}
	
	function alertUIConf(html,isscrollto,url)
	{
		$( "#dialog:ui-dialog" ).dialog( "destroy" );
			$("#inDiv_html_delete").html('<span class="ui-icon ui-icon-check" style="float:left; margin:0 7px 20px 0;"></span>'+html);
			$( "#dialog-confirm-delete" ).dialog({
				resizable: false,
				//height:140,
				title:"Confirmación",
				modal: true,
				position:"center",
				dialogClass:"uialertfrm", 
				buttons: {
					"Cerrar": function()
					{
						$( this ).dialog( "close" );
						if(isscrollto == true)
						{
							$.scrollTo(".wrapMain",800);
						}
						
					}
					
				}
			});
	}

	
	function alertUIAction(html,url)
	{
		$( "#dialog:ui-dialog" ).dialog( "destroy" );
			$("#inDiv_html_delete").html('<span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>'+html);
			$( "#dialog-confirm-delete" ).dialog({
				resizable: false,
				//height:140,
				title:"Alerta",
				modal: true,
				position:"center",
				dialogClass:"uialertfrm", 
				buttons: {
					"Aceptar": function()
					{
						document.location = url;
						
					}
					
				}
			});
	}

function cargarModelosEdit(marca,name)
{
	is_verif = 1;
	ajax("loadmodelsedit","inDiv_ajModelos","marca="+marca);
	closeAllmenu(2,name,"");
}

function cargarModelos(marca,name)
	{
		is_verif = 1;
		ajax("loadmodels","inDiv_ajModelos","marca="+marca);
		closeAllmenu(2,name,"Selecciona un modelo...");
		
		
		/*activando el boton send*/
		
		
	}
	
	function modeloSelccionado(modelo)
	{
		closeAllmenu(3,modelo,"Selecciona el año de fabricación de tu carro.");
		$(".colyear").show();
	}
	
	function modeloSelccionado2(modelo)
	{
		closeAllmenu(3,modelo,'');
		$(".colyear").show();
	}
	
	function setPricVent(txtnumer)
	{
		closeAllmenu(6,'US$ '+number_format(txtnumer.value),'')
		if(txtnumer.value != "")
		{
			$("#inDiv_is_fac_neg").show();
			$("#inDiv_is_fac_cont").show();
			
			$("#inDiv_is_fac_neg_span").html("Siempre es bueno indicar que estas dispuesto a negociar.");
			$("#inDiv_is_fac_cont_span").html("Si entregas factura puedes ampliar tu oportunidad de venta.");
			$("#isneg_0").focus();
			
		}
		
	}
	
	function registrarSession(name,value)
	{
		ajax("registrarSession","inDiv_hidde","name="+name+"&value="+value);
	}
	
	function reloadCufon()
	{
		Cufon.replace('h2', { fontFamily: 'Myriad Pro', fontWeight: 'regular'});
		Cufon.replace('h3', { fontFamily: 'Myriad Pro', fontWeight: 'bold', hover: true});
	}
	
	function str_replace (search, replace, subject, count) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   input by: Oleg Eremeev
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Oleg Eremeev
    // %          note 1: The count parameter must be passed as a string in order
    // %          note 1:  to find a global variable in which the result will be given
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
    var i = 0,
        j = 0,
        temp = '',
        repl = '',
        sl = 0,
        fl = 0,
        f = [].concat(search),
        r = [].concat(replace),
        s = subject,
        ra = Object.prototype.toString.call(r) === '[object Array]',
        sa = Object.prototype.toString.call(s) === '[object Array]';
    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }

    for (i = 0, sl = s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j = 0, fl = f.length; j < fl; j++) {
            temp = s[i] + '';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length - s[i].length) / f[j].length;
            }
        }
    }
    return sa ? s : s[0];
}


	
	function llenarformularios()
	{
		$('.textdefault').each(function(){
			var defaultVal = $(this).attr('textdefault');
			$(this).focus(function(){
			  if ($(this).val() == defaultVal){
				$(this).removeClass('current').val('');
			  }
			})
			.blur(function(){
			  if ($(this).val() == ''){
				$(this).addClass('current').val(defaultVal);
			  }
			})
			.blur().addClass('current');
		  });
		  $('form').submit(function(){
			 limpiarformularios();
		 });
	}
	
	function limpiarformularios()
	{
		 
		$('.textdefault').each(function()
		{
		  var defaultVal = $(this).attr('textdefault');
		  if ($(this).val() == defaultVal){
			$(this).val('');
		  }
		});
	  
	}


