function UpdateCursorPosition(e){
	cX = e.pageX;
	cY = e.pageY;
}
function UpdateCursorPositionDocAll(e){
	cX = event.clientX;
	cY = event.clientY;
}
if (document.all)
	document.onmousemove = UpdateCursorPositionDocAll;
else
	document.onmousemove = UpdateCursorPosition;
var cX = 0; var cY = 0; var rX = 0; var rY = 0;
function AssignPosition(d, first){
	if(document.documentElement && document.documentElement.scrollTop)
	{
		rX = document.documentElement.scrollLeft;
		rY = document.documentElement.scrollTop;
		wX = document.documentElement.clientWidth;
		wY = document.documentElement.clientHeight;
	}
	else if(document.body)
	{
		rX = document.body.scrollLeft;
		rY = document.body.scrollTop;
		if (document.body.clientWidth)
		{
			wX = document.body.clientWidth;
			wY = document.body.clientHeight;
		}
		else
		{
			wX = document.documentElement.clientWidth;
			wY = document.documentElement.clientHeight;
		}
	}
	else if(self.pageYOffset)
	{
		rX = self.pageXOffset;
		rY = self.pageYOffset;
		wX = self.innerwidth;
		wY = self.innerheight;
	}
	if(document.all)
	{
		cX += rX;
		cY += rY;
	}

	if (first)
		FitWindow(d, cX, cY, rX, rY, wX, wY);
	else
		FitWindow2(d, cX, cY, rX, rY, wX, wY);
}
function FitWindow(d, cX, cY, rX, rY, wX, wY){

	if ((cX + 10 + d.offsetWidth - rX) > wX)
	{
		if ((cX + d.offsetWidth - 10) > rX)
			the_left = (cX - d.offsetWidth - 10) + "px";
		else
			the_left = (cX + 10) + "px";
	}
	else
		the_left = (cX + 10) + "px";
	if ((cY - d.offsetHeight - 5) > rY)
		the_top = (cY - d.offsetHeight - 5) + "px";
	else if ((cY + 5 + d.offsetHeight) < wY + rY)
		the_top = (cY + 5) + "px";
	else
		// d.style.top = (cY - d.offsetHeight - 5) + "px";
		the_top = rY + "px";
	// alert(the_left);
	// the_left = '700px';
	d.style.left = the_left;
	d.style.top = the_top;
	// document.getElementById("test_js").innerHTML = cX + " | " + cY + " | " +
	// rX + " | " + rY + " | " + wX + " | " + wY + " | " + the_left + " | " +
	// the_top;
}
function FitWindow2(d, cX, cY, rX, rY, wX, wY){
	var the_div = document.getElementById("big_img_zoom");
	if(!the_div)
		return;
	the_div.style.display = "block";
	var the_img = the_div.getElementsByTagName("img")[0];
	var the_pos = findPos(the_div);
	var mouse_x = the_pos[0];
	var mouse_y = the_pos[1];
	var the_top = parseInt((cY - mouse_y) / the_div.clientHeight * (the_img.clientHeight - the_div.clientHeight));
	var the_left = parseInt((cX - mouse_x) / the_div.clientWidth * (the_img.clientWidth - the_div.clientWidth));
	// document.getElementById("test_js").innerHTML = cX + " | " + cY + " | " +
	// rX + " | " + rY + " | " + wX + " | " + wY + " | " + the_top + " | " +
	// the_left + " | " + mouse_x + " | " + mouse_y + " | ";
	try
	{
		the_img.style.top = -the_top;
		the_img.style.left = -the_left;
	}
	catch (e)
	{
	}
}
function findPos(obj){
	var curleft = curtop = 0;
	while(obj.offsetParent){
		curleft += obj.offsetLeft;
		curtop += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return [curleft, curtop];
}

function hide_tooltip(d){
	if(d.length < 1)
		return;
	document.getElementById(d).style.display = "none";
}
function show_tooltip(d){
	if(d.length < 1)
		return;
	var dd = document.getElementById(d);
	dd.style.display = "block";
	AssignPosition(dd, true);
}
function hide_zoom_img(){
	document.getElementById("big_img_zoom").style.display = "none";
}
var the_width = 0;
function zoom_img(){
	var the_img = document.getElementById("big_img_zoom").getElementsByTagName("img")[0];
	if ((the_img.src.indexOf("i/b.gif") < 0) && (the_width > 440))
	{
		AssignPosition(document.getElementById("big_img_zoom"), false);
		document.getElementById("big_img_zoom").style.display = "block";
	}
}
function show_spune_parere(){
	document.getElementById("parerea_ta").style.display = "block";
}
function sel_pr(pr_id, pref){
	var pr_in = document.getElementById(pref + "in_" + pr_id);
	if (pr_in != null)
		if (pr_in.value == "false")
		{
			pr_in.value = "true";
			// document.getElementById(pref + "div_" + pr_id).style.border =
			// "2px solid green";
			document.getElementById(pref + pref + "_" + pr_id).src = "img/checkboxchecked.gif";
			eval ("x" + pref + "++;");
		}
		else
		{
			pr_in.value = "false";
			// document.getElementById(pref + "div_" + pr_id).style.border =
			// "2px solid white";
			document.getElementById(pref + pref + "_" + pr_id).src = "img/checkbox.gif";
			eval ("x" + pref + "--;");
		}
}
function change_cul(el_id, cul, sex, t_id){
	// alert(el_id + " | " + cul + " | " + sex + " | " + t_id);
	if (el_id != "do_not_change")
	{
		var el = document.getElementById(el_id);
		if (el != null)
		{
			var hr = el.href;
			var hr_in = hr.indexOf("_culoare-");
			if (hr_in > -1)
				// el.href = hr.substr(0, hr_in + 9) + cul + hr.substr(hr_in +
				// 10);
				el.href = hr.replace(/_culoare-[0-9]+/g, "_culoare-" + cul)
			else
				el.href += "_culoare-" + cul;
		}
		get_tshirt_price(t_id, sex, "all", cul, "price_" + el_id);
	}
}
function get_tshirt_price(id, sex, marime, culoare, el){
	var xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4)
		{
			var pars = xmlHttp.responseText.split("|");
			var the_el = document.getElementById(el);
			var the_el_disc = document.getElementById(el + "_discount");
			if (the_el)
				the_el.innerHTML = pars[0];
			if (the_el_disc)
			{
				the_el_disc.getElementsByTagName("strong")[0].innerHTML = pars[1];
				try
				{
					if (parseInt(pars[1]) > parseInt(pars[0]))
					{
						the_el_disc.style.display = "block";
					}
					else
					{
						the_el_disc.style.display = "none";
					}
				}
				catch (e)
				{
				}
			}
		}
	}
	var params = 'id=' + id + '&sex=' + sex + '&culoare=' + culoare + '&marime=' + marime;
	xmlHttp.open ("GET", "__get_thist_price.php?" + params, true);
	xmlHttp.send (null);
}

function get_potriviri(sex, marime, fara_div){
	var xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4)
		{
			document.getElementById('potriviri').innerHTML = xmlHttp.responseText;
		}
	}
	var params = 'sex=' + sex + '&marime=' + marime + '&model=' + sel_model + '&culoare=' + sel_culoare + ((fara_div) ? "&b=" + bravados + "&fara_div=true" : "");
	xmlHttp.open ("GET", "_get_potriviri_new.php?" + params, true);
	xmlHttp.send (null);
}

function ucfirst( str ){
    // http://kevin.vanzonneveld.net
    // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // + bugfixed by: Onno Marsman
    // + improved by: Brett Zamir
    // * example 1: ucfirst('kevin van zonneveld');
    // * returns 1: 'Kevin van zonneveld'
    str += '';
    var f = str.charAt(0).toUpperCase();
    return f + str.substr(1);
}
function ID(id){
	return document.getElementById(id);
}
function show_calendar(box){
	var leftPos = (screen.availWidth-200) / 2
	var topPos = (screen.availHeight-280) / 2
	showCalWin = window.open(base_href+'date_popup.php?text='+box,'','width=200,height=280,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
}
function arata_tricou(id, sex){
	window.location=unde+"#top";
	document.index_tu.SetVariable("_level0.tricou", id);
	document.index_tu.SetVariable("_level0.sex_site", sex);
	document.index_tu.SetVariable("_level0.dinpromo", 0);
	document.index_tu.GotoFrame(0);
	document.index_tu.Play();
}
function p(adresa){
	windowW=780;
	windowH=500;
	windowX = screen.width/2-windowW/2;
	windowY = screen.height/2-windowH/2;
        var EB = window.open(base_href+'zoom.html?pic='+adresa,"lp","width="+windowW+", height="+windowH+", fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0", true)
	EB.resizeTo(windowW, windowH);
	EB.moveTo(windowX,windowY)
	EB.focus()
}
function pop_up(adresa, windowW, windowH, scrollbar){
	windowX = screen.width/2-windowW/2;
	windowY = screen.height/2-windowH/2;
        var EB = window.open(base_href+adresa,"lp", "width="+windowW+", height="+windowH+", fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + ((scrollbar) ? "yes" : "no") + ",resizable=0", true)
	EB.resizeTo(windowW, windowH);
	EB.moveTo(windowX,windowY)
	EB.focus()
}
function GetXmlHttpObject(){
	var xmlHttp = null;
	try{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e){
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function ajax_get_prods(id, filters){
	var xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4)
		{
			document.getElementById(id).innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open ("GET", "__get_number_of_prods.php?" + filters, true);
	xmlHttp.send (null);
}
var response;
function ajax_settings_submit(div, value){
	var xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4)
		{
			return;
		}
	}
	var params = 'nume='+div+'&value='+value;
	xmlHttp.open ("GET", "collapse_settings.php?" + params, true);
	xmlHttp.send (null);
}
function ajax_settings_get(div, value){
	var xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4)
		{
			var pars = xmlHttp.responseText.split("=");
			setView(pars[0],pars[1]);
		}
	}
	var params = 'nume='+div;
	xmlHttp.open ("GET", "collapse_settings.php?" + params, true);
	xmlHttp.send (null);
}
function setView(id, value){
	if (value==0)
	{
		if (id == 'filters'){
			hideDiv('filters');
		}
		if (id == 'parerea_ta'){
			hideDiv('parerea_ta');
		}
	}
}
function setupCollapsables(){
	var divs = new Array('filters', 'parerea_ta');
	for (var i=0; i<divs.length; i++ ){
		ajax_settings_get(divs[i], '');
	}
}
function urlencode( str ){
    // http://kevin.vanzonneveld.net
    // + original by: Philip Peterson
    // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // * example 1: urlencode('Kevin van Zonneveld!');
    // * returns 1: 'Kevin+van+Zonneveld%21'
    var ret = str;
    ret = ret.toString();
    ret = encodeURIComponent(ret);
    ret = ret.replace(/%20/g, '+');
    return ret;
}

/*
 * Array.prototype.inArray = function (value){ var i; for (i=0; i <
 * this.length; i++){ if (this[i] === value){ return i; } } return null; };
 */
function postalCodeLink(a, oras, judet, p1, p2){
	// http://www.coduripostale.com/cgi-bin/coduri_postale.cgi?mod=cs&jud=BH&loc=Adoni
	var i = p1.inArray(judet.toLowerCase());
	if (i != null)
		a.href = 'http://www.coduripostale.com/cgi-bin/coduri_postale.cgi?mod=cs&jud='+p2[i]+'&loc='+oras;
	else
	{
		i = p2.inArray(judet.toUpperCase());
		if (i != null)
			a.href = 'http://www.coduripostale.com/cgi-bin/coduri_postale.cgi?mod=cs&jud='+p2[i]+'&loc='+oras;
		else
			a.href = 'http://www.coduripostale.com/cgi-bin/coduri_postale.cgi?mod=cs&loc='+oras;
	}
}
function filterClear(){
	for(var i=0;i<ID('filtru_form').elements.length;i++)
		if(ID('filtru_form').elements[i].type.toLowerCase()=='checkbox')
		{
			ID('filtru_form').elements[i].checked=false;
			uncheckCheckbox(ID('filtru_form').elements[i].id);
		}
}
function cycleCheckbox(id){
	var ckb = ID(id);
	if (ckb.checked)
		ID(id+'_img').src = 'img/checkbox.gif';
	else ID(id+'_img').src = 'img/checkboxchecked.gif';
	ckb.checked = !ckb.checked;
}
function uncheckCheckbox(id){
	var ckb = ID(id);
	ID(id+'_img').src = 'img/checkbox.gif';
}
var interval;
var initHeight = 500;
var up = 0;
var dist;
function animateDiv(div){
	div = document.getElementById(div);
	initHeight = div.getElementsByTagName("table")[0].offsetHeight;
	var display = div.style.display;
	var footer = ID('footer');
	dist = dist * 1.2;
	if (up)
	{
		if (parseInt(div.style.height) < dist){
			clearInterval(interval);
			div.style.height = 0;
			div.style.display = 'none';
			if (!footer.style.height)
				footer_style_height = 0;
			else
				footer_style_height = parseInt(footer.style.height);
			footer.style.height = Math.max(0, footer_style_height - initHeight);
		}
		else
		{
			div.style.height = parseInt(div.style.height) - dist;
		}
	}
	else
	{
		div.style.display = 'block';
		if (parseInt(div.style.height) > initHeight){
			clearInterval(interval);
			div.style.height = initHeight;
			if (!footer.style.height)
				footer_style_height = 0;
			else
				footer_style_height = parseInt(footer.style.height);
			footer.style.height = Math.max(0, footer_style_height - initHeight);
		}
		else
		{
			div.style.height = parseInt(div.style.height) + dist;
		}
	}
}
function cycleDiv(id){
	var div = ID(id);
	div.style.overflow = 'hidden';
	if (div.style.display != "none")
	{
		initHeight = div.getElementsByTagName("table")[0].offsetHeight;
	}
	if (id != 'page_text')
	{
		ajax_settings_submit(id, up);
	}
	div.style.height = div.offsetHeight;
	dist = 10;
	if (id == 'filters')
	{
		interval = setInterval("animateDiv('filters')", 1);
	}
	if (id == 'page_text')
	{
		interval = setInterval("animateDiv('page_text')", 1);
	}
	if (id == 'parerea_ta')
	{
		ID('footer').style.height = ID('footer').offsetHeight;
		if (!up) ID('footer').style.height = parseInt(ID('footer').style.height) + initHeight;
		interval = setInterval("animateDiv('parerea_ta')", 1);
	}
	up = (up+1)%2;
	if (id == 'page_text'){
		ID('text-arrow_'+up).style.display = 'inline';
		ID('text-arrow_'+(up+1)%2).style.display = 'none';
	} else {
		ID('arrow_'+up).style.display = 'inline';
		ID('arrow_'+(up+1)%2).style.display = 'none';
	}
}
function hideDiv(id){
	var div = ID(id);
	if (div)
	{
		div.style.overflow = 'hidden';
		if (div.style.display == "none")
		{
			div.style.display = 'block';
			initHeight = div.offsetHeight;
			div.style.display = 'none';
		}
		ajax_settings_submit(id, up);
		div.style.height = div.offsetHeight;
		dist = 10;
		if (id == 'filters')
		{
			div.style.height = 0; div.style.display = 'none';
		}
		if (id == 'parerea_ta')
		{
			ID('footer').style.height = ID('footer').offsetHeight;
			div.style.height = 0; div.style.display = 'none';
		}
		up = 1;
		ID('arrow_'+up).style.display = 'inline';
		ID('arrow_'+(up+1)%2).style.display = 'none';
	}
}

function togglediv(id){
	var div = ID(id);
	var is_up = 0
	if(div.style.display == "none"){
		is_up = 0;
		div.style.display = 'block';
	} else {
		is_up = 1
		div.style.display = 'none';
	}



	ID('text-arrow_'+is_up).style.display = 'inline';
	ID('text-arrow_'+(is_up+1)%2).style.display = 'none';
}

function change_rate(rate){
	document.fc.rate.value = rate;
	for (var i = 1; i <= rate; i++)
		document.getElementById("rate_" + i).src = 'img/star_on.jpg';
	for (var i = rate + 1; i <= 5; i++)
		document.getElementById("rate_" + i).src = 'img/star_off.jpg';
}
function highlight_rate(rate){
	for (var i = 1; i <= rate; i++)
		document.getElementById("rate_" + i).src = 'img/star_on.jpg';
	for (var i = rate + 1; i <= 5; i++)
		document.getElementById("rate_" + i).src = 'img/star_off.jpg';
}
function out_highlight_rate(rate){
	for (var i = 1; i <= document.fc.rate.value; i++)
		document.getElementById("rate_" + i).src = 'img/star_on.jpg';
	for (var i = parseInt(document.fc.rate.value) + 1; i <= 5; i++)
		document.getElementById("rate_" + i).src = 'img/star_off.jpg';
}
var ppSelected=0;
function ppPic(thumb, full, orig, wid){
	var idx=thumb*2;
	the_width = wid;
	document.getElementById('pp_thumb').rows[0].cells[ppSelected].className='';
	document.getElementById('pp_thumb').rows[0].cells[idx].className='selected';
	// document.getElementById('pp_image').src=full;
	document.getElementById('pp_image').style.backgroundImage="url('"+full+"')";
	document.getElementById('big_img_zoom').getElementsByTagName("img")[0].src=orig;
	ppSelected=idx;
}
function show3D(b,id,w,h){
	var scr1=null;
	var params='scrollbars=no,status=yes,innerWidth='+w+',width='+w+',height='+h;
	var scr1=window.open('3dview.html?id='+id,'trideewin'+id,params);
	scr1.moveTo(0,0);
	if(scr1.innerHeight)
	{
		scr1.resizeTo(w+(scr1.outerWidth-scr1.innerWidth),h+(scr1.outerHeight-scr1.innerHeight));
	}
	scr1.focus();
}
function link_from_inputs(form){
	var inps = form.getElementsByTagName('input');
	var ret = '';
	for (var i = 0; i < inps.length; i++)
	{
		if (inps[i].type == 'checkbox' && inps[i].checked)
			ret += inps[i].name + "=" + inps[i].value + "&";
		if (inps[i].type != 'checkbox' && inps[i].type != 'submit' && inps[i].type != 'button')
			ret += inps[i].name + "=" + inps[i].value + "&";
	}
	ret = ret.substr(0, ret.length-1);
	return ret;
}
/*
 * function show_bigimg(id){ document.getElementById('flash').style.display =
 * 'none'; document.getElementById('big_img_holder').style.display = 'block';
 * document.getElementById(id).style.display = 'block'; } function hide_bigimg(){
 * var imgs =
 * document.getElementById('big_img_holder').getElementsByTagName('img'); for
 * (var i = 0; i < imgs.length; i++){ imgs[i].style.display = 'none'; }
 * document.getElementById('big_img_holder').style.display = "none";
 * document.getElementById('flash').style.display = 'block'; }
 */
function show_bigimg(id){
	if (shown_id.length)
	{
		document.getElementById(shown_id).style.display = 'none';
	}
	shown_id = id;
	clearTimeout(the_timer);
	/* document.getElementById('flash').style.display = 'none'; */
	document.getElementById('big_img_holder').style.display = 'block';
	document.getElementById(id).style.display = '';
	if(document.getElementById('txt_'+id)){
		document.getElementById('txt_'+id).style.display = '';
	}
}
var the_timer;
var shown_id = "";
function hide_bigimg(){
	the_timer = setTimeout("hide_bigimg2()", 100);
}
function hide_bigimg2(){
	var imgs = document.getElementById('big_img_holder').getElementsByTagName('div');
	for (var i = 0; i < imgs.length; i++)
	{
		imgs[i].style.display = 'none';
	}
	document.getElementById('big_img_holder').style.display = "none";
	/* document.getElementById('flash').style.display = 'block'; */
}
function getFile(url, callback, post_keys, post_values, xml){
	try{ var xmlHttp=new XMLHttpRequest(); }   // Firefox, Opera 8.0+, Safari
	catch (e){
		// Internet Explorer
		try{ var xmlHttp=new ActiveXObject('MSXML2.XMLHTTP.3.0'); }
		catch(e){
			try{ var xmlHttp=new ActiveXObject('MSXML3.XMLHTTP'); }
			catch(e){
				try{ var xmlHttp=new ActiveXObject('Msxml2.XMLHTTP'); }
				catch(e){
					try{ var xmlHttp=new ActiveXObject('Microsoft.XMLHTTP'); }
					catch(e){
						throw new Error("Could not find an XMLHttpRequest alternative.");
					}
				}
			}
		}
	}
	var post_string='';
	if(post_keys){
		if(!post_values){
			for(var i in post_keys)
				post_string+=escape(i)+'='+post_keys[i]+'&';
		}
		else
			for(var i=0;i<post_keys.length;i++)
				post_string+=escape(post_keys[i])+'='+escape(post_values[i])+'&';
		post_string=post_string.substring(0, post_string.length-1);
	}
	xmlHttp.open(post_string?'POST':'GET', url, callback?true:false);
	if(post_string){
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", post_string.length);
		xmlHttp.setRequestHeader("Connection", "close");
		var method='POST';
	}
	if(callback){
		xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState==4){
				if(xmlHttp.status==200)
					callback(xml?xmlHttp.responseXML.documentElement:xmlHttp.responseText);
				else
					throw new Error('Page returned error '+xmlHttp.status+' '+xmlHttp.statusText);
			}
		}
	}
	xmlHttp.send(post_string);
	if(!callback)
		return xml?xmlHttp.responseXML.documentElement:xmlHttp.responseText;
	else
		return 'Wait for async';
}
function tabArray(txt, sep, eol){
	if(!txt.length)
		return new Array();
	if(!eol)
		eol='\r\n';
	if(!sep)
		sep='\t';
	var arr=new Array();
	var lines=txt.split(eol)
	for(var i=0;i<lines.length;i++){
		var tmp=lines[i].split(sep);
		arr[tmp[0]]=tmp[1];
	}
	return arr;
}
function fillSelect(elm, keys, values, first_key, first_value, select){
	if(!values){ // keys is an associative array
		values=new Array();
		var k=new Array();
		for(var i in keys){
			k[k.length]=i;
			values[values.length]=keys[i];
		}
		keys=k;
	}
	elm.options.length=0;
	if(first_key || first_value)
		elm.options[elm.options.length]=new Option(first_value, first_key);
	if(!select)
		select=null;
	for(var i=0;i<keys.length;i++){
		elm.options[elm.options.length]=new Option(values[i], keys[i]);
		if(select==keys[i])
			elm.options[elm.options.length-1].selected=true;
	}
}
function fillSearchForm(type){
	if(type==0)
    	getFile('_serveme.php?tip='+document.forms['frmSearch'].elements['tip'].value,
        function(txt){
        	fillSelect(document.frmSearch.marca, tabArray(txt), false, false, false, 'toate tipurile');
            fillSearchForm(1);
        }
    );
    else if(type==1)
        getFile('_serveme.php?tip='+document.forms['frmSearch'].elements['tip'].value+'&marca='+document.forms['frmSearch'].elements['marca'].value,
        function(txt){
            fillSelect(document.frmSearch.model, tabArray(txt), false, false, false, 'toate marcile');
            fillSearchForm(2);
        }
    );
}
function show_popup(d){
	document.getElementsByTagName("body")[0].style.overflowY = "hidden";
	if(document.documentElement && document.documentElement.scrollTop)
		var height = document.documentElement.scrollTop;
	else if(document.body)
		var height = document.body.scrollTop;
	else if(window.pageYOffset)
		var height = window.pageXOffset;
	else
		var height = 0;

	document.getElementById("popup_opac_" + d).style.display = "block";
	document.getElementById("popup_tran_" + d).style.display = "block";
	document.getElementById("popup_tran_" + d).style.position = "absolute";
	document.getElementById("popup_opac_" + d).style.position = "absolute";
	document.getElementById("popup_tran_" + d).style.marginTop = height;
	document.getElementById("popup_opac_" + d).style.marginTop = height;

	document.getElementById("popup_tran_" + d).style.backgroundColor = eval ("bgcol_" + d);
}
function hide_popup(d){
	document.getElementsByTagName("body")[0].style.overflowY = "scroll";
	document.getElementById("popup_opac_" + d).style.display = "none";
	document.getElementById("popup_tran_" + d).style.display = "none";
}
function show_answer(q){
	var ans = document.getElementById('a'+q.id.substr(1));
	if (ans.style.display != 'block'){
		document.getElementById(q.id).setAttribute("class", "q_on");
		document.getElementById(q.id).setAttribute("className", "q_on");
		ans.style.display = 'block';
	}
	else{
		document.getElementById(q.id).setAttribute("class", "q");
		document.getElementById(q.id).setAttribute("className", "q");
		ans.style.display = 'none';
        }
}
function for_ticketing(form, action){
	var inp = form.for_ticket;
	if (inp.checked)
	{
		var newAttr = document.createAttribute("action");
	    newAttr.nodeValue = "ticketing/open.php";
	    form.setAttributeNode(newAttr);
	}
	else
	{
		var newAttr = document.createAttribute("action");
	    newAttr.nodeValue = action;
	    form.setAttributeNode(newAttr);
	}
}

// LIVESEARCH.js
	/*
	 * //
	 * +----------------------------------------------------------------------+ // |
	 * Copyright (c) 2004 Bitflux GmbH | //
	 * +----------------------------------------------------------------------+ // |
	 * Licensed under the Apache License, Version 2.0 (the "License"); | // |
	 * you may not use this file except in compliance with the License. | // |
	 * You may obtain a copy of the License at | // |
	 * http://www.apache.org/licenses/LICENSE-2.0 | // | Unless required by
	 * applicable law or agreed to in writing, software | // | distributed under
	 * the License is distributed on an "AS IS" BASIS, | // | WITHOUT WARRANTIES
	 * OR CONDITIONS OF ANY KIND, either express or | // | implied. See the
	 * License for the specific language governing | // | permissions and
	 * limitations under the License. | //
	 * +----------------------------------------------------------------------+ // |
	 * Author: Bitflux GmbH <devel@bitflux.ch> | //
	 * +----------------------------------------------------------------------+
	 */
var LShref=false;
var liveSearchReq = false;
var t = null;
var liveSearchLast = "";
var LSMinimumCharacters=3;
var isIE = false;
// on !IE we only have to initialize it once
if(window.XMLHttpRequest){
	liveSearchReq = new XMLHttpRequest();
}
function liveSearchInit(){
	if(!ID('livesearch'))
		return;
	if(navigator.userAgent.indexOf("Safari") > 0){
		ID('livesearch').addEventListener("keydown",liveSearchKeyPress,false);
// ID('livesearch').addEventListener("blur",liveSearchHide,false);
	} else if(navigator.product == "Gecko"){
		ID('livesearch').addEventListener("keypress",liveSearchKeyPress,false);
		ID('livesearch').addEventListener("blur",liveSearchHideDelayed,false);
	} else {
		ID('livesearch').attachEvent('onkeydown',liveSearchKeyPress);
		ID('livesearch').attachEvent("onblur",liveSearchHide,false);
		isIE = true;
	}
	ID('livesearch').setAttribute("autocomplete","off");
}
function liveSearchHideDelayed(){
	window.setTimeout("liveSearchHide()",400);
}
function liveSearchHide(){
	ID("LSResult").style.display = "none";
	var highlight = ID("LSHighlight");
	if(highlight){
		highlight.removeAttribute("id");
	}
}
function liveSearchKeyPress(event){
	if(event.keyCode == 40 )
	// KEY DOWN
	{
		highlight = ID("LSHighlight");
		if(!highlight){
			highlight = ID("LSShadow").firstChild.firstChild;
		} else {
			highlight.removeAttribute("id");
			highlight = highlight.nextSibling;
		}
		if(highlight){
			highlight.setAttribute("id","LSHighlight");
		}
		if(!isIE){ event.preventDefault(); }
	}
	// KEY UP
	else if(event.keyCode == 38 ){
		highlight = ID("LSHighlight");
		if(!highlight){
			highlight = ID("LSResult").firstChild.firstChild.lastChild;
		}
		else {
			highlight.removeAttribute("id");
			highlight = highlight.previousSibling;
		}
		if(highlight){
				highlight.setAttribute("id","LSHighlight");
		}
		if(!isIE){ event.preventDefault(); }
	}
	// ESC
	else if(event.keyCode == 27){
		highlight = ID("LSHighlight");
		if(highlight){
			highlight.removeAttribute("id");
		}
		ID("LSResult").style.display = "none";
	}
	// BACKSPACE - required for IE
	else if(event.keyCode == 8 && isIE){
		liveSearchStart();
	}
	// RETURN
	else if(event.keyCode == 13 ){
		return liveSearchSubmit();
	}

}
function liveSearchStart(){
	if(t){
		window.clearTimeout(t);
	}
	if(document.forms.searchform.q.value.length >= LSMinimumCharacters-1)
		ID('LSLoading').className='LSLoadingOn';
	t = window.setTimeout("liveSearchDoSearch()",400);
}
function liveSearchDoSearch(){
	if(typeof liveSearchRoot == "undefined"){
		liveSearchRoot = "";
	}
	if(typeof liveSearchRootSubDir == "undefined"){
		liveSearchRootSubDir = "";
	}
	if(typeof liveSearchParams == "undefined"){
		liveSearchParams2 = "";
	} else {
		liveSearchParams2 = "&" + liveSearchParams;
	}
	if((liveSearchLast != document.forms.searchform.q.value) && (document.forms.searchform.q.value.length >= LSMinimumCharacters)){
		if(liveSearchReq && liveSearchReq.readyState < 4){
			liveSearchReq.abort();
		}
		if( document.forms.searchform.q.value == ""){
			liveSearchHide();
			liveSearchLast = "";
			return false;
		}
		if(window.XMLHttpRequest){ // branch for IE/Windows ActiveX version
		}
		else if(window.ActiveXObject){
			liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		liveSearchReq.onreadystatechange= liveSearchProcessReqChange;
		liveSearchReq.open("GET", base_href + "livesearch.php?q=" + escape(document.forms.searchform.q.value) + liveSearchParams2);
		liveSearchLast = document.forms.searchform.q.value;
		liveSearchReq.send(null);
	}
	else{
		ID('LSLoading').className='LSLoadingOff';
	}
}
function liveSearchProcessReqChange(){
	if(liveSearchReq.readyState == 4){
		var  res = ID("LSResult");
		res.style.display = "block";
		if(document.getElementById('call_me').style.display != 'none'){
			res.style.top = '103'; // mutam rezultatele de la search daca apare
									// bara cu sunati-ma
		}
		var  sh = ID("LSShadow");
		sh.innerHTML = liveSearchReq.responseText;
	}
	ID('LSLoading').className='LSLoadingOff';
}
function liveSearchSubmit(){
	var highlight = ID("LSHighlight");
	if(highlight && highlight.firstChild){
		window.location =highlight.firstChild.nextSibling.getAttribute("href");
		return false;
	}
	else {
		return true;
	}
}
document.onmousedown=function(){
	if(LShref!=false && LShref!=null){
		document.location=base_href+LShref;
	}
}
// END LIVE SEARCH
function sterge_wishlist(id_user, id_div, id_wish, id_prieten){
	var xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4)
		{
			document.getElementById(id_div).innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open ("GET", "_sterge_wishlist.php?user="+id_user+"&wish="+id_wish+"&friend="+id_prieten, true);
	xmlHttp.send (null);
}

function select_sterge(id){
	var div = document.getElementById('sterge_'+id);
	var holder = div.parentNode;

	var width = holder.offsetWidth;
	var height = holder.offsetHeight;

	div.style.width = width+'px';
	div.style.height = height+'px';
	div.getElementsByTagName('p')[0].style.height = height+'px';
	div.style.display = 'block';

	document.getElementById('sterge['+id+']').value = 'true';
}

function undelete(id){
	var div = document.getElementById('sterge_'+id);
	div.style.display = 'none';

	var input = document.getElementById('sterge['+id+']');
	input.value = 'false';
}
function show_wishlist_button(txt){
	var div = document.getElementById('wish_btns');
	if (txt.substr(0, 23) == 'Produsul a fost adaugat' && div.getElementsByTagName('a').length == 0)
	{
		div.innerHTML += "<a href='"+ base_href +"useri/wishlist.html'><img src='img/vezi_wishlist.gif' alt='vezi wishlist' style='border: 0; padding-bottom: 1px;' /></a>";
	}
}

function AssignPosition_Shirts(d){
	if(document.documentElement && document.documentElement.scrollTop)
		rX = document.documentElement.scrollLeft;
	else if(document.body)
		rX = document.body.scrollLeft;
	else if(self.pageYOffset)
		rX = self.pageXOffset;
	if(document.all)
		cX += rX;
	var poz = findPos(d);
	poz = cX - poz[0];
	poz = Math.max(1, Math.min(5, Math.floor(poz * 5 / d.offsetWidth) + 1));
	var cul_lim = d.getAttribute("culori");
	if (!((cul_lim.length > 0) && (cul_lim.indexOf(poz) == -1)))
	{
		var t_src = d.src.replace(/(.*?)\-([a-z]+)\.jpg/, "$1-" + shirts_colors[poz] + ".jpg");
		if (d.src != t_src)
		{
			d.src = t_src;
			change_cul("my_t_" + d.getAttribute("id"), poz, d.getAttribute("sex"), d.getAttribute("t_id"));
		}
	}
}
var images_to_preload = Array();
var tshirts_prices = {};
function hide_livesearch(){
	var div = document.getElementById('LSResult');
	if (div.style.display == 'block')
		div.style.display = 'none';
}


function change_png_image(img){
	var imgID = (img.id) ? "id='" + img.id + "' " : "";
	var imgClass = (img.className) ? "class='" + img.className + "' " : "";
	var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
	var imgStyle = "display:inline-block; background-image: none; " + img.style.cssText ;
	if (img.align == "left") imgStyle = "float:left;" + imgStyle;
	if (img.align == "right") imgStyle = "float:right;" + imgStyle;
	if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
	var strNewHTML = "<img src='i/b.gif' " + imgID + imgClass + imgTitle
		+ " style=\"" + "width:" + 431 + "px; height:" + 430 + "px;" + imgStyle + ";"
		+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		+ "(src=\'" + img.src + "\', sizingMethod='crop');\" />";
	img.outerHTML = strNewHTML;
}
function get_img_src(img){
	if (ie_version)
	{
		if (img.style["filter"])
		{
			var the_src = img.style["filter"].match(/src=\'([^\']*)/i);
			if (the_src)
				return the_src[1];
			return "";
		}
		return "";
	}
	return img.src;
}
function set_img_src(img, src, da){
	if (ie_version && da)
	{
		var imgID = (img.id) ? "id='" + img.id + "' " : "";
		var imgClass = (img.className) ? "class='" + img.className + "' " : "";
		var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
		if (img.style["filter"] && img.style["filter"].length)
			img.style["filter"] = "progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + src + "\', sizingMethod='crop')";
		var imgStyle = "display:inline-block; background-image: none; " + img.style.cssText;
		if (img.align == "left") imgStyle = "float:left;" + imgStyle;
		if (img.align == "right") imgStyle = "float:right;" + imgStyle;
		if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
		var strNewHTML = "<img src='i/b.gif' " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + 431 + "px; height:" + 430 + "px;" + imgStyle + ";"
			+ "\" />";
		img.outerHTML = strNewHTML;
	}
	else
		img.src = src;
}

	/* START MOFO */

function potriviri_balon(etapa){

	var theelement = document.getElementById("potriviri");
	if(!theelement)
		return;

// alert(sel_model);
	if(etapa == 'ini_s' && sel_model == false){
		theelement.style.display = 'block';
	} else if(etapa == 'ini_h' && sel_model == false){
		theelement.style.display = 'none';
	} else if(etapa == 'model'){
		theelement.style.display = 'block';
		theelement.innerHTML = '<p class="potriviri_title"> Alege marimea.</p><div class="potriviri_content"><p>Model ales: ' + sel_model + '.</p></div>';
	} else if(etapa == 'marime'){
		theelement.className = '';
		get_potriviri(trans_sex[sel_model], sel_marime, true);
	} else if(etapa == 'culoare'){
				theelement.className = '';
				get_potriviri(trans_sex[sel_model], sel_marime, sel_culoare, true);
	}

// else {
// theelement.style.display = 'block';
// theelement.innerHTML = 'Alege tipul de tricou si marimea din iconurile de mai
// sus pentru a comanda si pentru a vedea detalii de tricou.';
// }
}

	if(location.pathname.match(/tricouri-personalizate.html/))
		var customDesign=true;
	else
		var customDesign=false;

	function alege_marime(marime, cont){
		if ((typeof (x = in_stoc[sel_model]) != "undefined") && (typeof (y = x[marime]) != "undefined") && (typeof (z = y["in_stoc"]) != "undefined"))
		{
			if (z > 0)
			{
				the_end = false;
				alg_fata();
				if (sel_marime)
					document.getElementById(sel_marime + "_checked").style.display = "none";
				if ((sel_model) && (sel_model == "hanorac"))
				{
					document.getElementById("hanorac_over").style.display = "none";
					if (are_spate)
						document.getElementById("hanorac_over_spate").style.display = "none";
				}
				var old_culoare = def_culoare;
				if (sel_culoare && (sel_culoare != "unselected"))
				{
					if (document.getElementById("culoare_" + sel_model + "_" + sel_culoare).className == "seld")
						document.getElementById("culoare_" + sel_model + "_" + sel_culoare).className = "";
					old_culoare = sel_culoare;
				}
				sel_culoare = def_culoare;
				setTimeout( function(){
						var the_imgs = document.getElementById(customDesign?"designer-sizes":"marimea").getElementsByTagName("img");
						for (var i = 0; i < the_imgs.length; i++)
							if (the_imgs[i].alt != "checked")
								the_imgs[i].src = the_imgs[i].src.replace(old_culoare, sel_culoare);
					}, 1);
				setTimeout( function(){
						var the_imgs = document.getElementById(customDesign?"designer-models":"modelul").getElementsByTagName("img");
						for (var i = 0; i < the_imgs.length; i++)
							if (the_imgs[i].alt != "checked")
								the_imgs[i].src = the_imgs[i].src.replace(old_culoare, sel_culoare);
					}, 1);
				setTimeout( function(){
						set_img_src(document.getElementById("tricou_fata"), base_href + def_tricou_fata, true);
						if (are_spate)
							set_img_src(document.getElementById("tricou_spate"), base_href + def_tricou_spate, true);
						set_img_src(document.getElementById("tricoul_bg"), base_href + "i/js/trikos/" + sel_model + "-disabled.png", true);
						if(!customDesign){
							document.getElementById("text_marimea").src = "i/js/text_marimea.gif";
							document.getElementById("text_culoarea").src = "i/js/text_alege_culoarea.gif";
							document.getElementById("text_modelul").src = "i/js/text_modelul.gif";
						}
					}, 1);
				sel_marime = marime;
				document.getElementById(sel_marime + "_checked").style.display = "block";
// document.getElementById("seld_marime").innerHTML = ", " +
// marime.toUpperCase();
				get_tshirt_price_2(id_tricou, sel_model, sel_marime, "all", "price_big");
// document.getElementById("seld_culoare").innerHTML = "";
// document.getElementById("seld_logo").innerHTML = "";
				document.getElementById("logo_fata").style.display = "none";
				if (are_spate)
					document.getElementById("logo_spate").style.display = "none";
				texts[1] = "i/js/text_alege_culoarea.gif";
				the_text_ind = 0;
				if(!customDesign){
					stop_fifo("text_marimea");
					fade_in_fade_out("text_culoarea", -1);
				}
				document.getElementById(customDesign?"designer-colors":"culoarea").style.display = "block";
				document.getElementById("logo").style.display = "none";
				document.getElementById("vreau_logo").checked = false;
				if(document.getElementById('wishlist_form'))
					document.getElementById('wishlist_form').style.display='none';
				if(document.getElementById('wishlist_link'))
					document.getElementById('wishlist_link').style.display='none';

// get_potriviri(trans_sex[sel_model], sel_marime, true);
				potriviri_balon("marime");
				if(customDesign){
				//	document.getElementById("designer-adauga").className = "unseld";
				}
				else{
					document.getElementById("adauga").className = "unseld";
					document.getElementById("audaga_cos").src = document.getElementById("audaga_cos").src.replace("_on", "_off");
				}
				location.hash = "#model-" + sel_model + "_marime-" + marime;
				if(!customDesign){
					var the_loc = location.href;
					var the_ym_link = document.getElementById("send_ym");
					var the_tf_link = document.getElementById("send_tf");
					var to_change = the_ym_link.href.match(/\+http[^\+]*\+/i);
					the_ym_link.href = the_ym_link.href.replace(to_change, "+" + the_loc + "+");
				}
				aplica_bravados(); // aplicam bigprev pt bravados
				if ((typeof (z = y["got_stocs"]) != "undefined") && (z > 0))
					afiseaza_culori(cont);
				else
					get_culori_stocs(cont);
			}
			else
				return;
		}
	}
	function get_marimi_stocs(cont){
		getFile("__get_stocinfo.php?tricou=" + nume_tricou + "&action=marimi&model=" + sel_model, function(txt){
			eval(txt);
			in_stoc[sel_model]["got_stocs"] = 1;
			afiseaza_marimi(cont);
		});
	}

	function aplica_bravados(){
		if(bravados == 1){
			if(!customDesign)
				document.getElementById('bigprev_zoom').style.display = 'none';
			document.getElementById('logo_fata').style.display = 'none';
			document.getElementById('tricou_fata').style.display = 'none';
			// if(!customDesign)
				// document.getElementById('tricou_spate').style.display = 'none';
			document.getElementById('tricoul_bg').style.display = 'none';
			document.getElementById('tricou_bigprev').style.display = 'block';
		}
	}

	function afiseaza_marimi(cont){
		var the_div = document.getElementById(customDesign?"designer-sizes":"marimea");
		var the_imgs = the_div.getElementsByTagName("img");
		var stoc_num = 0; // numaram cate sunt in stoc
		var recenta_stoc = ''; // ultima din loop care e in stoc

		// Afisam "balonul" cu potriviri
		potriviri_balon("model", cont);

		setTimeout(  function(){
				for (var i = 1; i < the_imgs.length; i++){
					if (the_imgs[i].alt != "checked")
					{
						var pos_en = the_imgs[i].src.lastIndexOf("-");
						var the_marime = the_imgs[i].alt;
						if (in_stoc[sel_model][the_marime]["in_stoc"] == 0)
						{
							document.getElementById("marime_" + the_marime).style.display = "none";
							the_imgs[i].style.cursor = "default";
							the_imgs[i].src = the_imgs[i].src.substr(0, pos_en + 1) + "disabled.gif";
						}
						else
						{
							document.getElementById("marime_" + the_marime).style.display = "block";
							the_imgs[i].style.cursor = "pointer";
							the_imgs[i].src = the_imgs[i].src.substr(0, pos_en + 1) + sel_culoare + ".gif";
							recenta_stoc = the_marime;
							stoc_num++;
						}
					}

				}

				if(stoc_num == 1){
					alege_marime(recenta_stoc, true);
				}

			}, 1);
		the_div.style.display = "block";
		if (cont && (typeof (x = the_dets["marime"]) != "undefined")){
			alege_marime(x, true);
		} else {
			if(stoc_num == 1){
				alert(the_marime);
			}
			if (only_spate){
				alg_spate();
			}
		}
	}
	function alege_modelul(model, cont){
/*
 * if(model=='polo'){ sel_parte = 'fata'; are_spate = true; only_spate = true;
 * alg_spate(); } else{ are_spate = false; alg_fata(); }
 */
		if ((typeof (x = in_stoc[model]) != "undefined") && (typeof (y = x["in_stoc"]) != "undefined"))
		{
			if (y > 0)
			{
				the_end = false;
				alg_fata();
				var old_model = "mascul";
				if (sel_model)
				{
					/*
					 * AICI TREBE VAZUT DACA SUNT SI ALTE ELEMENTE SPECIALE SAU
					 * CEVA DACA FACEM DIFERIT DEOCAMDATA RAMANE ASA
					 */
					if (sel_model == "hanorac")
					{
						document.getElementById("hanorac_over").style.display = "none";
						if (are_spate)
							document.getElementById("hanorac_over_spate").style.display = "none";
					}
					if(customDesign){
						document.getElementById("designer-model_" + sel_model + "_checked").style.display = "none";
						document.getElementById("designer-model_" + sel_model).style.display = "block";
					}
					else
						document.getElementById("model_" + sel_model + "_checked").style.display = "none";
					old_model = sel_model;
				}
				var old_culoare = def_culoare;
				if (sel_culoare && (sel_culoare != "unselected"))
				{
					if (document.getElementById("culoare_" + sel_model + '_' + sel_culoare).className == "seld")
						document.getElementById("culoare_" + sel_model + '_' + sel_culoare).className = "";
					old_culoare = sel_culoare;
				}
				if (sel_marime && (sel_marime != "unselected"))
					document.getElementById(sel_marime + "_checked").style.display = "none";
				sel_culoare = def_culoare;
				setTimeout( function(){
						var the_imgs = document.getElementById(customDesign?"designer-sizes":"marimea").getElementsByTagName("img");
						for (var i = 0; i < the_imgs.length; i++)
							if (the_imgs[i].alt != "checked")
								the_imgs[i].src = the_imgs[i].src.replace(old_culoare, sel_culoare);
					}, 1);
				if(!customDesign)
					setTimeout( function(){
						var the_imgs = document.getElementById("modelul").getElementsByTagName("img");
						for (var i = 0; i < the_imgs.length; i++)
							if (the_imgs[i].alt != "checked")
								the_imgs[i].src = the_imgs[i].src.replace(old_culoare, sel_culoare);
					}, 1);

				sel_model = model;
				setTimeout( function(){
					var the_imgs = document.getElementById(customDesign?"designer-sizes":"marimea").getElementsByTagName("img");
					for (var i = 0; i < the_imgs.length; i++)
						if (the_imgs[i].alt != "checked")
							the_imgs[i].src = the_imgs[i].src.replace(old_model, sel_model);
				}, 1);

				// Ascundem toate culorile acum

				var the_div = document.getElementById(customDesign?"designer-colors":"culoarea");
				var the_imgs = the_div.getElementsByTagName("img");
				setTimeout( function(){
						for (var i = 1; i < the_imgs.length; i++)
						{

							var opts = the_imgs[i].alt.split("_"); // spargem
																	// modelul
																	// si
																	// culoarea
							var the_model = opts[0];
							var the_culoare = opts[1];

								the_imgs[i].parentNode.className = "dis";
								// the_imgs[i].src = "i/b.gif";
								the_imgs[i].parentNode.style.display = "none";

						}
					}, 1);

				setTimeout( function(){
						/* AQUI */
						set_img_src(document.getElementById("tricou_fata"), base_href + def_tricou_fata, true);
						// document.getElementById("tricou_fata").src =
						// base_href + def_tricou_fata;
						if (are_spate)
							set_img_src(document.getElementById("tricou_spate"), base_href + def_tricou_spate, true);
							// document.getElementById("tricou_spate").src =
							// def_tricou_spate;
						set_img_src(document.getElementById("tricoul_bg"), base_href + "i/js/trikos/" + sel_model + "-disabled.png", true);
						// document.getElementById("tricoul_bg").src =
						// "i/b.gif";
						if(!customDesign){
							document.getElementById("text_culoarea").src = "i/js/text_alege_culoarea.gif";
							document.getElementById("text_modelul").src = "i/js/text_modelul.gif";
						}
					}, 1);

				document.getElementById((customDesign?"designer-model_":"model_") + sel_model + "_checked").style.display = "block";

				var ucf_str_model = sel_model;
			    var f = ucf_str_model.charAt(0).toUpperCase();
			    ucf_str_model = f + ucf_str_model.substr(1);
				document.getElementById("logo_fata").style.display = "none";
				if (are_spate)
					document.getElementById("logo_spate").style.display = "none";
// document.getElementById("seld_marime").innerHTML = "";
// document.getElementById("seld_model").innerHTML = ", " + ucf_str_model;
				get_tshirt_price_2(id_tricou, sel_model, "all", "all", "price_big");
// document.getElementById("seld_culoare").innerHTML = "";
// document.getElementById("seld_logo").innerHTML = "";
				if(!customDesign)
					stop_fifo("text_modelul");
				texts[1] = "i/js/text_alege_marimea.gif";
				the_text_ind = 0;
				if(!customDesign){
					fade_in_fade_out("text_marimea", -1);
					document.getElementById("bigprev_zoom").style.display = "block"; // afisam botonul de bigprev
					document.getElementById("culoarea").style.display = "none";
					document.getElementById("marimea").style.display = "none";
					document.getElementById("potriviri").innerHTML = '';
					document.getElementById("adauga").className = "unseld";
					document.getElementById("audaga_cos").src = document.getElementById("audaga_cos").src.replace("_on", "_off");
				}
				else{
					document.getElementById("designer-colors").style.display = "none";
					document.getElementById("designer-sizes").style.display = "none";
					//document.getElementById("designer-adauga").className = "unseld";
				}
				document.getElementById("logo").style.display = "none";
				document.getElementById("vreau_logo").checked = false;
				if(document.getElementById('wishlist_link'))
					document.getElementById('wishlist_link').style.display='none';
				if(document.getElementById('wishlist_form'))
					document.getElementById('wishlist_form').style.display='none';
				if(model == "polo"){
					document.getElementById("polo_warning").style.display = "block";
					if(!customDesign)
						document.getElementById("adauga").style.top = "422px";
					//else
						//document.getElementById("designer-adauga").style.top = "422px";
				}
				else{
					document.getElementById("polo_warning").style.display = "none";
					if(!customDesign)
						document.getElementById("adauga").style.top = "402px";
					//else
						//document.getElementById("designer-adauga").style.top = "402px";
				}
				location.hash = "#model-" + sel_model;
				if(!customDesign){
					var the_loc = location.href;
					var the_ym_link = document.getElementById("send_ym");
					var the_tf_link = document.getElementById("send_tf");
					var to_change = the_ym_link.href.match(/\+http[^\+]*\+/i);
					the_ym_link.href = the_ym_link.href.replace(to_change, "+" + the_loc + "+");
				}
				if ((typeof (z = x["got_stocs"]) != "undefined") && (z > 0)){
					afiseaza_marimi(cont);
				} else {
					get_marimi_stocs(cont);
				}

				aplica_bravados();

			}
			else
				return;
		}
	}
	function get_culori_stocs(cont){
		getFile("__get_stocinfo.php?tricou=" + nume_tricou + "&action=culori&marime=" + sel_marime + "&model=" + sel_model, function(txt){
			eval(txt);
			in_stoc[sel_model][sel_marime]["got_stocs"] = 1;
			afiseaza_culori(cont);
		});
	}
	function afiseaza_culori(cont){
		var the_div = document.getElementById(customDesign?"designer-colors":"culoarea");
		var the_imgs = the_div.getElementsByTagName("img");
		var stoc_num = 0; // numaram cate sunt in stoc
		var recenta_stoc = ''; // ultima din loop care e in stoc


		setTimeout( function(){
				for (var i = 0; i < the_imgs.length; i++) // i = 0 ca nu afiseaza mascul alb
				{

					var opts = the_imgs[i].alt.split("_"); // spargem modelul
															// si culoarea
					var the_model = opts[0];
					var the_culoare = opts[1];
					if(the_culoare){
						if (in_stoc[sel_model][sel_marime][the_culoare] && in_stoc[sel_model][sel_marime][the_culoare]["in_stoc"] > 0 && sel_model == the_model)
					{
						if (the_imgs[i].parentNode.className != "seld")
							the_imgs[i].parentNode.className = "";
						// the_imgs[i].src = "i/js/_icons_culori/"+ sel_model +
						// '/' + the_culoare + ".gif";
						the_imgs[i].parentNode.style.display = "block";
						recenta_stoc = the_culoare;
						stoc_num++;

					}
					else
					{
						the_imgs[i].parentNode.className = "dis";
						// the_imgs[i].src = "i/b.gif";
						the_imgs[i].parentNode.style.display = "none";
					}
				}
				}
				if(stoc_num == 1){
					alege_culoarea(recenta_stoc, true);
				}

			}, 1);
		the_div.style.display = "block";
		if (cont && (typeof (x = the_dets["culoare"]) != "undefined"))
			alege_culoarea(x, true);
		else
			if (only_spate)
				alg_spate();
	}
	function alege_culoarea(culoare, cont){
		if ((typeof (x = in_stoc[sel_model]) != "undefined") && (typeof (xx = x[sel_marime]) != "undefined") && (typeof (y = xx[culoare]) != "undefined") && (typeof (z = y["in_stoc"]) != "undefined"))
		{
			if (z > 0)
			{
				var old_culoare = def_culoare;
				alg_fata();
				if (sel_culoare && (sel_culoare != "unselected"))
				{
					if (document.getElementById("culoare_" + sel_model + '_' + sel_culoare).className == "seld")
						document.getElementById("culoare_" + sel_model + '_' + sel_culoare).className = "";
					old_culoare = sel_culoare;
				}
				sel_culoare = culoare;
// setTimeout( function()
// {
// var the_imgs =
// document.getElementById("marimea").getElementsByTagName("img");
// for (var i = 0; i < the_imgs.length; i++)
// if (the_imgs[i].alt != "checked")
// the_imgs[i].src = the_imgs[i].src.replace(old_culoare, sel_culoare);
// }, 1);
// setTimeout( function()
// {
// var the_imgs =
// document.getElementById("modelul").getElementsByTagName("img");
// for (var i = 0; i < the_imgs.length; i++)
// if (the_imgs[i].alt != "checked")
// the_imgs[i].src = the_imgs[i].src.replace(old_culoare, sel_culoare);
// }, 1);
				setTimeout( function(){
						/* AQUI */
						set_img_src(document.getElementById("tricou_fata"), base_href + "i/tricouri/t/" + nume_tricou + "-" + sel_culoare + ".png");
						// document.getElementById("tricou_fata").src =
						// "i/tricouri/t/" + nume_tricou + "-" + sel_culoare +
						// ".png";
						if (are_spate)
							set_img_src(document.getElementById("tricou_spate"), base_href + "i/tricouri/t/" + nume_tricou + "-" + sel_culoare + "-sp.png");
							// set_img_src(document.getElementById("hanorac_over_spate"),
							// base_href + "i/js/trikos/hanorac-" + sel_culoare
							// + "-over-sp.png");
							// document.getElementById("tricou_spate").src =
							// "i/tricouri/t/" + nume_tricou + "-" + sel_culoare
							// + "-sp.png";
						if(sel_model == 'polo'){
						  set_img_src(document.getElementById("tricoul_bg"), base_href + "i/js/trikos/" + sel_model + "-" + sel_culoare + "-sp.png");
						} else {
						  set_img_src(document.getElementById("tricoul_bg"), base_href + "i/js/trikos/" + sel_model + "-" + sel_culoare + ".png");
						}

						if (sel_model == "hanorac")
						{
							set_img_src(document.getElementById("hanorac_over"), base_href + "i/js/trikos/hanorac-" + sel_culoare + "-over.png");
							if (are_spate){
								set_img_src(document.getElementById("hanorac_over_spate"), base_href + "i/js/trikos/hanorac-" + sel_culoare + "-over-sp.png");
							}
						}

						// document.getElementById("tricoul_bg").src =
						// "i/js/trikos/" + sel_model + "-" + sel_culoare +
						// ".png";
						if (ie_version)
						{
							var img = document.getElementById("tricou_fata");
							change_png_image(img);
							if (are_spate)
							{
								var img = document.getElementById("tricou_spate");
								change_png_image(img);
							}
							var img = document.getElementById("tricoul_bg");
							change_png_image(img);

							if (sel_model == "hanorac"){
								var img = document.getElementById("hanorac_over");
								change_png_image(img);
								if (are_spate)
								{
									var img = document.getElementById("hanorac_over_spate");
									change_png_image(img);
								}
							}
						}
						if(!customDesign)
							document.getElementById("text_culoarea").src = "i/js/text_culoarea.gif";
					}, 1);
				document.getElementById("culoare_" + sel_model + '_' + sel_culoare).className = "seld";
				var ucf_str_model = sel_culoare;
			    var f = ucf_str_model.charAt(0).toUpperCase();
			    ucf_str_model = f + ucf_str_model.substr(1);
// document.getElementById("seld_culoare").innerHTML = ", " + ucf_str_model;
				get_tshirt_price_2(id_tricou, sel_model, sel_marime, sel_culoare, "price_big");
				potriviri_balon("culoare");
				if(!customDesign){
					stop_fifo("text_culoarea");
					document.getElementById("adauga").className = "seld";
					document.getElementById("audaga_cos").src = document.getElementById("audaga_cos").src.replace("_off", "_on");
				}
				//else
					//document.getElementById("designer-adauga").className = "seld";
				if(document.getElementById('wishlist_link'))
					document.getElementById('wishlist_link').style.display='';
				if(document.getElementById('wishlist_form'))
					document.getElementById('wishlist_form').style.display='';
				/*
				 * AICI TREBE VAZUT DACA SUNT SI ALTE ELEMENTE SPECIALE SAU CEVA
				 * DACA FACEM DIFERIT DEOCAMDATA RAMANE ASA
				 */
				if (sel_model == "hanorac")
				{
					document.getElementById("hanorac_over").style.display = "block";
					if (are_spate)
						document.getElementById("hanorac_over_spate").style.display = "block";
				}
				if((sel_model == "mascul" || sel_model == "femela" || sel_model == "extra") && id_tricou!=328)
				{
					if(!customDesign)
						document.getElementById("logo").style.display = "block";
// document.getElementById("seld_logo").innerHTML = "";
					document.getElementById("vreau_logo").checked = false;
					document.getElementById("logo_fata").style.display = "block";
					setTimeout( function(){
						/* AQUI */
							set_img_src(document.getElementById("logo_fata"), base_href + "i/js/logo-" + sel_model + "-" + sel_culoare + ".png");
							// document.getElementById("logo_fata").src =
							// "i/js/logo-" + sel_model + "-" + sel_culoare +
							// ".png";
							if (are_spate)
								set_img_src(document.getElementById("logo_spate"), base_href + "i/js/logo-" + sel_model + "-" + sel_culoare + "-sp.png");
								// document.getElementById("logo_spate").src =
								// "i/js/logo-" + sel_model + "-" + sel_culoare
								// + "-sp.png";
							if (ie_version)
							{
								var img = document.getElementById("logo_fata");
								change_png_image(img);
								if (are_spate)
								{
									var img = document.getElementById("logo_spate");
									change_png_image(img);
								}
							}
						}, 1);
				}
				else
				{
					document.getElementById("logo_fata").style.display = "none";
					if (are_spate)
						document.getElementById("logo_spate").style.display = "none";
				}
				the_end = true;
				location.hash = "#model-" + sel_model + "_marime-" + sel_marime + "_culoare-" + sel_culoare;
				if(!customDesign){
					var the_loc = location.href;
					var the_ym_link = document.getElementById("send_ym");
					var the_tf_link = document.getElementById("send_tf");
					var to_change = the_ym_link.href.match(/\+http[^\+]*\+/i);
					the_ym_link.href = the_ym_link.href.replace(to_change, "+" + the_loc + "+");
					aplica_bravados(); // aplicam bigprev pt bravados
				}
				else if(!cont){
					//Flash stuff here
					setTimeout(function(){
						var fm=getFlashMovieObject("Main");
						var obj = new Object();
							obj.tshirtFront = base_href + "i/js/trikos/" + sel_model + "-" + sel_culoare + ".png";
							obj.tshirtModel = sel_model;
							obj.tshirtBack = are_spate;
							obj.tshirtSize = sel_marime;
							obj.tshirtColor = sel_culoare;

						fm.addTShirt(obj);
					}, 100);
				}

				if (only_spate)
					alg_spate();
				/*
				 * if (cont && (typeof (x = the_dets["logo"]) != "undefined"))
				 * vreau_logo_changed(true);
				 */
			}
			else
				return;
		}
	}

	/** functii pentru Designeru' de tricouri **/
	function getFlashMovieObject(movieName){
		if (window.document[movieName]){
			return window.document[movieName];
		}
		if (navigator.appName.indexOf("Microsoft Internet")==-1){
			if (document.embeds && document.embeds[movieName])
				return document.embeds[movieName];
		}
		else{
			return document.getElementById(movieName);
		}
	}

	function save_design(){
		var fm=getFlashMovieObject("Main");
		fm.saveDesign();
	}

	var designSavedAction='';
	function designSaved(id){
		if(designSavedAction=='addToCart')
			location.href=base_href+'useri/adauga_in_cos.html?custom=' + id;
		else if(designSavedAction=='autoSave')
			location.href=base_href+'useri/adauga_in_cos.html?custom=' + id;
		else
			enable_share(base_href+'designer.html?d=' + id);
	}

	function print_design(){
		var fm=getFlashMovieObject("Main");
		fm.printDesign();
	}

	function addToCart(){

		if(!sel_model || !sel_marime || !sel_culoare || sel_culoare=='unselected'){
			alert('Trebuie sa alegeti un model, o marime si o culoare');
			return false;
		}

		ID('designer-adauga-img').src=ID('designer-adauga-img').src.replace(/\.png/, '.gif');

		designSavedAction='addToCart';
		save_design();
	}

	function autoSaveDesign(){


	}

	function enable_share(preview_url){
		document.getElementById('designer-preview').style.display = "block";
		document.getElementById('preview_real_url').value = preview_url;
		ID('preview-tabnou').href=preview_url;

		ID('preview-twitter').href='https://twitter.com/share?original_referer='+escape(location.href)+'&source=tweetbutton&text=Design+personalizat+la+tu.ro&url='+escape(preview_url)+'&via=tu_ro';
		ID('preview-twitter').onclick=function(){
			return !window.open(this.href, 'twitter', 'width=626,height=436,scrollbars=no,resizable=no,titlebar=0');
		}

		ID('preview-fb').href='http://www.facebook.com/sharer.php?u='+escape(preview_url)+'&src=sp';
		ID('preview-fb').onclick=function(){
			return !window.open(this.href, 'facebook', 'width=626,height=436,scrollbars=no,resizable=no,titlebar=0');
		}

//		ID('').fbs_click
	}

	function disable_share(){
		document.getElementById('designer-preview').style.display = "none";
	}
	/** am terminat functiile pentru Designeru' de tricouri **/

	function vreau_logo_changed(chk){
		// var the_loc = location.protocol + '//' + location.host +
		// location.pathname + location.search + "#marime-" + sel_marime +
		// "_model-" + sel_model + "_culoare-" + sel_culoare;
		if (chk)
		{
			document.getElementById("vreau_logo").checked = true;
			document.getElementById("logo_fata").style.display = "none";
			if (are_spate)
				document.getElementById("logo_spate").style.display = "none";
			// the_loc += "_logo-fara"
// document.getElementById("seld_logo").innerHTML = ", fara logo pe maneca (+5
// roni)";
			document.getElementById("price_big").innerHTML = parseInt(document.getElementById("price_big").innerHTML) + 5;
		}
		else
		{
			document.getElementById("vreau_logo").checked = false;
			if (are_spate && (sel_parte == "spate"))
				document.getElementById("logo_spate").style.display = "block";
			else
				document.getElementById("logo_fata").style.display = "block";
// document.getElementById("seld_logo").innerHTML = "";
			document.getElementById("price_big").innerHTML = parseInt(document.getElementById("price_big").innerHTML) - 5;
		}
		/*
		 * addthis_url = the_loc; if(navigator.appVersion.search(/MSIE
		 * 6.0/)==-1) document.location.href = the_loc; var the_ym_link =
		 * document.getElementById("send_ym"); var the_tf_link =
		 * document.getElementById("send_tf"); var to_change =
		 * the_ym_link.href.match(/\+http[^\+]*\+/i); the_ym_link.href =
		 * the_ym_link.href.replace(to_change, "+" + the_loc + "+");
		 */
	}

	function get_tshirt_price_2(id, sex, marime, culoare, el){
		if (culoare != "all")
		{
			culoare = trans_culoare[culoare];
		}
		if (sex != "all")
			sex = trans_sex[sex];
		if (marime != "all")
			marime = trans_marime[marime];
		get_tshirt_price(id, sex, marime, culoare, el);
	}
	function add_to_cart(){
		if (the_end)
			document.location.href = base_href + "useri/adauga_in_cos.html?model=" + nume_tricou + "&sex=" + trans_sex[sel_model] + "&culoare=" + trans_culoare[sel_culoare] + "&marime=" + sel_marime + ((document.getElementById("vreau_logo").checked) ? "&fara_logo=true" : "") + ((cu_reducere) ? "&din_oferta=true" : "");
	}
	function add_to_wishlist(){
		if(the_end)
			document.forms['wishlist'].elements['produs'].value="model=" + nume_tricou + "&sex=" + trans_sex[sel_model] + "&culoare=" + trans_culoare[sel_culoare] + "&marime=" + sel_marime + ((document.getElementById("vreau_logo").checked) ? "&fara_logo=true" : "") + ((cu_reducere) ? "&din_oferta=true" : "");
	}
	function setOpacity(el, value){
    	element = document.getElementById(el);
    	var set_value = (value === '') ? '0' : (value < 0.00001) ? 0 : value;
    	element.style.opacity = set_value;
    	element.style.filter  = "alpha(opacity=" + parseInt(set_value * 100) + ")";
    	element.opac = set_value;
	}
	function getOpacity(el){
		var val = document.getElementById(el).opac;
		if (typeof val != 'undefined')
			return parseFloat(val);
		else
	    	return 1.0;
	}
	var fade_timer = 0;
	function fade_in_fade_out(el, way){
		var the_op = Math.min(getOpacity(el) + (0.03 * way), 1);
		setOpacity(el, the_op);
		if (way == 1)
		{
			if (the_op < 1)
				fade_timer = setTimeout("fade_in_fade_out('" + el + "', 1)", 50);
			else
				fade_timer = setTimeout("fade_in_fade_out('" + el + "', -1)", 150);
		}
		else
		{
			if (the_op > 0)
				fade_timer = setTimeout("fade_in_fade_out('" + el + "', -1)", 50);
			else
			{
				change_text(el);
				fade_timer = setTimeout("fade_in_fade_out('" + el + "', 1)", 150);
			}
		}
	}
	function stop_fifo(el){
		clearTimeout(fade_timer);
		setOpacity(el, 1);
		fade_timer = 0;
	}
	function change_text(el){
		element = document.getElementById(el);
		element.src = texts[(the_text_ind++) % 2];
	}
	function alg_fata(){
		if (are_spate && (sel_parte != "fata"))
		{
			sel_parte = "fata";
			if (!document.getElementById("vreau_logo").checked && (sel_culoare != "unselected") && ((sel_model == "mascul") || (sel_model == "femela") || (sel_model == "extra")))
				document.getElementById("logo_fata").style.display = "block";
			document.getElementById("logo_spate").style.display = "none";
			document.getElementById("fata").style.display = "block";
			document.getElementById("spate").style.display = "none";
			setTimeout( function(){
						/* AQUI */
					var the_src = get_img_src(document.getElementById("tricoul_bg"));
					var the_ext = the_src.substring(the_src.length - 3, the_src.length);
					set_img_src(document.getElementById("tricoul_bg"), the_src.replace("-sp." + the_ext, "." + the_ext));
					// document.getElementById("tricoul_bg").src =
					// document.getElementById("tricoul_bg").src.replace("-sp.png",
					// ".png");
					if (ie_version)
					{
						var img = document.getElementById("tricoul_bg");
						change_png_image(img);
					}
					var fata = document.getElementById("alege_fata");
					var spate = document.getElementById("alege_spate");
					fata.src = fata.src.replace("_off", "_on");
					spate.src = spate.src.replace("_on", "_off");
				}, 1);
		}
	}
	function alg_spate(){
		if (are_spate && (sel_parte != "spate"))
		{
			sel_parte = "spate";
			document.getElementById("logo_fata").style.display = "none";
			if (!document.getElementById("vreau_logo").checked && (sel_culoare != "unselected") && ((sel_model == "mascul") || (sel_model == "femela") || (sel_model == "extra")))
				document.getElementById("logo_spate").style.display = "block";
			document.getElementById("fata").style.display = "none";
			document.getElementById("spate").style.display = "block";
			setTimeout( function(){
						/* AQUI */
					var the_src = get_img_src(document.getElementById("tricoul_bg"));
					var the_ext = the_src.substring(the_src.length - 3, the_src.length);
					set_img_src(document.getElementById("tricoul_bg"), the_src.replace("." + the_ext, "-sp." + the_ext));
					// document.getElementById("tricoul_bg").src =
					// document.getElementById("tricoul_bg").src.replace(".png",
					// "-sp.png");
					if (ie_version)
					{
						var img = document.getElementById("tricoul_bg");
						change_png_image(img);
					}
					var fata = document.getElementById("alege_fata");
					var spate = document.getElementById("alege_spate");
					fata.src = fata.src.replace("_on", "_off");
					spate.src = spate.src.replace("_off", "_on");
				}, 1);
		}
	}

function submit_call_me(x){
	var get='action='+x;
	if(x=="trimite"){
		if(document.call_me.telefon.value.length<9){
			alert('Nu ati introdus numarul de telefon!');
			return false;
		}
		else{
			var validWorldPhoneChars="0123456789()- .+";
			z=0;
			for(j=0; j<=validWorldPhoneChars.length-1; j++)
				if(validWorldPhoneChars.indexOf(document.call_me.telefon.value.substring(j,j+1))==-1){
					z=1;
				}
			if(z==1){
				alert('Numarul de telefon nu este introdus corect!');
				return false;
			}
		}
		get+='&t='+document.call_me.telefon.value;
		get+='&c='+document.call_me.cerinta.value;
	}

	getFile('_call_me.php?'+get, function(data){
		var fs_class='';
		if(data=='trimite'){
			document.getElementById('call_me').style.display='';
			document.getElementById('show_call_me').style.display='none';
			document.getElementById('show_call_me_msg').style.display='';
		}
		else if(data=='close'){
			document.getElementById('call_me').style.display='none';
			document.getElementById('LSResult').style.top = '63'; // resetam boxu' de search sa apara unde tre'
		}
		else{
			document.getElementById('call_me').innerHTML=data;
			document.getElementById('call_me').style.display='';
			fs_class='call_me';
		}
		if(document.getElementById('free_shipping'))
			document.getElementById('free_shipping').className=fs_class;
	});
}
function togglevis(x) {
	if (document.getElementById(x).style.display == 'none') {
		document.getElementById(x).style.display = '';
	} else {
		document.getElementById(x).style.display = 'none';
	}
}
