// JavaScript Document
if (window != top) top.location = self.location

$(document).ready(function() { 
  // rearange_listing();
	 var Nwin = $('#navigation').height();
	 var Hmax = Math.max($(window).height()-10, $('#wrapper').height()); 
	 if (Hmax>Nwin) $('#navigation').height(Hmax);
	 $("#input_search").bind("focus", function(){if ($(this).val()=="Cauta laptop") $(this).val('');});
	 $("#input_search").bind("blur", function(){if ($(this).val()=="") $(this).val('Cauta laptop');});
   });

//////////////////////////////////////////////////////////////
var shown_tags = 0;
function show_tags(id, obj){
	stare = getElem(id).style.display;
	if (!shown_tags){	$('#'+id).slideDown('normal'); $(obj).addClass('selectat'); shown_tags=1;}
	else if (stare != "block") $('.tags').hide(); $('#'+id).fadeIn(300); $('.tabs li').removeClass('selectat'); $(obj).addClass('selectat');

	if (stare == "block"){ $('#'+id).slideUp('normal'); $(obj).removeClass('selectat'); shown_tags=0;}
}

/////////////////////////////////////////////////////////////////
function rearange_listing(){
	for(i=1, n=$('#anunturi li').length; i<=n; i++)
	{	ImgH = $("#anunturi li:eq(" + (i-1) + ") img").height();
		if (ImgH > 120){
			LiH = $("#anunturi li:eq(" + (i-1) + ")").height();
			$("#anunturi li:eq(" + (i-1) + ")").css({height:(LiH+ImgH-110)});
		}			
	}
	
}

/////////////////////////////////////////////////////////////////
function getElem(elemID){
	var obj;
	if (document.all){obj = document.all(elemID)}
	else if (document.getElementById){obj = document.getElementById(elemID)
	}else if (document.layers){obj = document.layers[elemID]}
	return obj;
}
///////////////////////////////////////////////////////////////
function validare_cautare(frm){
	if (frm.cauta.value==""){
		alert("Scrie ce laptop cauti!");
		frm.cauta.focus();
		return false;
	}
	return true;
}

///////////////////////////////////////////////////////////////
function refresh_titlu(frm, camp, val){
	if (camp=='marca' && frm.titlu.value==""){frm.titlu.value = val;
	}else if (camp=='model' && frm.titlu.value==frm.marca.value){frm.titlu.value += " " + val;}
}

///////////////////////////////////////////////////////////////
function hideByID(ID){
	if (getElem(ID)){getElem(ID).style.display = "none";}
	else if (ID){
		d = ID.split(",");
		for (i=0,n=d.length; i<n; i++){
			if (getElem(d[i])){getElem(d[i]).style.display = "none";}
		}
	}
}

///////////////////////////////////////////////////////////////
function showByID(ID){
	if (getElem(ID)){getElem(ID).style.display = "";}
	else if (ID){
		d = ID.split(",");
		for (i=0,n=d.length; i<n; i++){
			if (getElem(d[i])){getElem(d[i]).style.display = "";}
		}
	}
}
