function arataIcons(v,d) {
	document.getElementById(d).innerHTML='';
	if (v<0) {
		var img='<img src="'+window.siteurl+'tpl/default/images/0.gif" width="18" height="18" alt=":( " style="vertical-align:middle" />';
		for (var i=0;i>v;i--) {
			document.getElementById(d).innerHTML+=img;
		}
	} else {
		var img='<img src="'+window.siteurl+'tpl/default/images/1.gif" width="18" height="18" alt=":) " style="vertical-align:middle" />';
		for (var i=0;i<v;i++) {
			document.getElementById(d).innerHTML+=img;
		}
	}
}
//---------
// Eroare daca nu exista elementul
function ErrorNoId(cine) {
	alert(' Reporniti browserul /n/r elementul '+cine+' nu exista ! ');
	return false;
}
// Get By Id
function ById(id){
	try{
		return document.getElementById(id);
	}
	catch(e){
		ErrorNoId(id);
	}
}
// Get By Name
function ByName(name){
	try{
		return document.getElementsByName(name);
	}
	catch(e){
		ErrorNoId(name);
	}
}
// Insert HTML
function InHtml(id,code){
	try{
		document.getElementById(id).innerHTML=code;
		return true;
	}
	catch(e){
		ErrorNoId(id);
	}
}
// EXTRACT HTML
function OutHtml(id){
	try{
		var code=document.getElementById(id).innerHTML;
		return code;
	}
	catch(e){
		ErrorNoId(id);
	}
}
// Insert Value By Name
function ValByName(name,val){
	try{
		ByName(name).value=val;
	}
	catch(e){
		ErrorNoId(name);
	}
}
// Insert Value By Id
function ValById(id,val){
	try{
		ById(id).value=val;
	}
	catch(e){
		ErrorNoId(id);
	}
}
var nr_ferestre=0;

function Swindow(continut_f,titlu,latime,inaltime) {
	nr_ferestre++;

	var div_nou = document.createElement('div');
	div_nou.id='div_over_window_nr_'+nr_ferestre;
	div_nou.className='s_fereastra_bg';
	div_nou.style.zIndex=nr_ferestre;

	div_nou.onclick=function () { SwindowClose(nr_ferestre); }

	ById('contine_window').appendChild(div_nou);
	div_nou = document.createElement('div');
	div_nou.id='fereastra_nr_'+nr_ferestre;
	div_nou.className='s_fereastra';
	div_nou.style.zIndex=nr_ferestre+1;
	ById('contine_window').appendChild(div_nou);
	var continut='';
	continut+='<div class="s_fereastra_top" id="top_fereastra_nr_'+nr_ferestre+'">';
	continut+='<div class="s_fereastra_titlu">'+titlu+'</div>';
	continut+='<div class="s_fereastra_close" onclick="SwindowClose('+nr_ferestre+');">&nbsp;</div></div>';
	continut+='<div style="padding :10px">'+continut_f+'</div>';
	div_nou.innerHTML=continut;



	var docH=document.body.scrollHeight;
	var docW=document.body.scrollWidth;
	ById('div_over_window_nr_'+nr_ferestre).style.height=docH+'px';
	ById('div_over_window_nr_'+nr_ferestre).style.width=docW+'px';


	var de = document.documentElement;
	var b = document.body;
	var cat_scrool = (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
	var cat_sus = cat_scrool + 100;;
	var cat_am=(docW-latime)/2;
	ById('fereastra_nr_'+nr_ferestre).style.top=cat_sus+'px';
	ById('fereastra_nr_'+nr_ferestre).style.left=cat_am+'px';
	ById('fereastra_nr_'+nr_ferestre).style.width=latime+'px';
	ById('fereastra_nr_'+nr_ferestre).style.height=inaltime+'px';

	Drag.init(ById('top_fereastra_nr_'+nr_ferestre), ById('fereastra_nr_'+nr_ferestre),4,docW-latime-10,4,docH-inaltime-10);
}
function SwindowClose(nr_fer_cl) {
	ById('div_over_window_nr_'+nr_fer_cl).style.height='0px';
	ById('div_over_window_nr_'+nr_fer_cl).style.width='0px';
	ById('fereastra_nr_'+nr_fer_cl).style.display='none';
	InHtml('fereastra_nr_'+nr_fer_cl,'');
}

function afImagesProd(nume_prod) {
	Swindow(OutHtml('divImagini'),nume_prod,550,450);
	
}
function afProdDiv(div) {
	if (document.getElementById(div).style.display=='none') {
		document.getElementById(div).style.display='block';
	} else {
		document.getElementById(div).style.display='none';
	}
}
function init() {
	if (document.all) {
		document.onmousemove = getXY_IE;
	}
	else {
		if (window.Event) {
			document.captureEvents(Event.MOUSEMOVE);
		}
		document.onmousemove = getXY;
	}
}
var x_cursor;
var y_cursor;
function getXY(e) {
	x_cursor = (window.Event) ? e.pageX : event.clientX;
	y_cursor = (window.Event) ? e.pageY : event.clientY;
}
function getXY_IE(){
	var de = document.documentElement;
	var b = document.body;
	x_cursor = event.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
	y_cursor = event.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
}
var zIndexuri=100;
function ShowTip(displayDiv){
	init();
	zIndexuri++;
	document.getElementById("mouse_over_"+displayDiv).style.display='block';
	document.getElementById("mouse_over_"+displayDiv).style.zIndex=zIndexuri;

	document.getElementById("mouse_over_"+displayDiv).style.top=y_cursor+14+'px';
	document.getElementById("mouse_over_"+displayDiv).style.left=x_cursor+14+'px';
}
function ShowTip2(displayDiv){
	init();
	zIndexuri++;
	document.getElementById("mouse_over2_"+displayDiv).style.display='block';
	document.getElementById("mouse_over2_"+displayDiv).style.zIndex=zIndexuri;

	document.getElementById("mouse_over2_"+displayDiv).style.top=y_cursor+14+'px';
	document.getElementById("mouse_over2_"+displayDiv).style.left=x_cursor+14+'px';
}
function HiddeTip(displayDiv){
	document.getElementById("mouse_over_"+displayDiv).style.display='none';
}
function HiddeTip2(displayDiv){
	document.getElementById("mouse_over2_"+displayDiv).style.display='none';
}
