function writeFlash(moviePath, w, h, transp) {
	if (transp == null){
		transp = false;
	}
	var transp_ns = "";
	var transp_ie = "";
	if (transp) {
		transp_ns = 'wmode="transparent"';
		transp_ie = '<param name="wmode" value="transparent" />';
	}
	var str = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
			+ 'codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" '
			+ 'width="' + w + '" height="' + h + '" align="middle">'
			+ '<param name="allowScriptAccess" value="sameDomain" />'
			+ '<param name="movie" value="' + moviePath + '" />'
			+ '<param name="quality" value="high" />'
			+ transp_ie
			+ '<embed src="' + moviePath + '" quality="high" '
			+ 'width="' + w + '" height="' + h + '" align="middle" ' + transp_ns + ' allowScriptAccess="sameDomain" ' 
			+ 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
			+ '</object>';
	document.write(str);
}
function writeFlash2(moviePath, w, h, transp) {
	if (transp == null){
		transp = false;
	}
	var transp_ns = "";
	var transp_ie = "";
	if (transp) {
		transp_ns = 'wmode="transparent"';
		transp_ie = '<param name="wmode" value="transparent" />';
	}
	var str = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
			+ 'codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" '
			+ 'width="' + w + '" height="' + h + '" align="middle">'
			+ '<param name="allowScriptAccess" value="sameDomain" />'
			+ '<param name="movie" value="' + moviePath + '" />'
			+ '<param name="quality" value="high" />'
			+ transp_ie
			+ '<embed src="' + moviePath + '" quality="high" '
			+ 'width="' + w + '" height="' + h + '" align="middle" ' + transp_ns + ' allowScriptAccess="sameDomain" ' 
			+ 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
			+ '</object>';
	return (str);
}
function checkCompletare (obj)
{
	if (obj.value=='')
	{
		return false;
	}
	else
	{
		return true;
	}
}

function checkMail(mail)
{
    var emailPat = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    var matchArray = mail.match(emailPat);
    if (matchArray == null)
    {
      return false;
    }
    else
    {
        return true;
    }
}


function checkFormularRecomandare()
{
	var str="Va rugam completati urmatoarele campuri:";
	var vb=true;
	
	if (!checkCompletare(document.formular.nume))
	{
		str=str+"\n Nume"; vb=false;
	}
	
	if (!checkCompletare(document.formular.expeditor))
	{
		str=str+"\n Expeditor"; vb=false;
	}
	
	if (!checkCompletare(document.formular.destinatar))
	{
		str=str+"\n Destinatar"; vb=false;
	}
	
	if (!vb)
	{
		alert(str);
	}
	
	return vb;	
}

function checkComentariu()
{
	var str="Va rugam completati urmatoarele campuri:";
	var vb=true;
	
	if (!checkCompletare(document.formular.comentariu))
	{
		str=str+"\n Comentariu"; vb=false;
	}
	else
	{
		if (document.formular.comentariu.value.length<50)
		{
			str=str+"\n Comentariul trebuie sa contina cel putin 50 de caractere!"; vb=false;
		}
	}
	
	if (!checkCompletare(document.formular.nume))
	{
		str=str+"\n Numele tau"; vb=false;
	}
	
	if (!vb)
	{
		alert(str);
	}
	
	return vb;	
}


function confirmareStergereOferta(id,pid)
{
	if (confirm('Sunteti sigur(a) ca doriti stergerea?'))
	{
		window.location.href='oferte.php?did='+pid+'&id='+id;
	}
}

function confirmareStergereCont(pid)
{
	if (confirm('Sunteti sigur(a) ca doriti stergerea?'))
	{
		window.location.href='conturi.php?did='+pid;
	}
}

function confirmareStergere()
{
	return confirm('Sunteti sigur(a) ca doriti stergerea?');
}

function previewNewsletter(id,back)
{
	window.open('preview_newsletter.php?id='+id+'&back='+back,'preview');
}

function resetFiltre()
{
	formular=document.filtrare; 
	for (i=0;i<formular.elements.length;i++)
	{
		
		if (formular.elements[i].name=='opt[]')
		{
//			alert(formular.elements[i].name);
			formular.elements[i].selectedIndex=0;
			formular.elements[i].value=formular.elements[i].options[0].value;
		}
		document.getElementById("resetfiltre").value=1;
		formular.submit();
	}
}

function redirect(dest){
	window.location.href=dest;
}

function rd(){
		if (document.getElementById("categorie").value != '') 
		{
			window.location.href='oferte.php?id='+document.getElementById("categorie").value;
		}
}
function rdreg(){
		if (document.getElementById("categorie").value != '')
		{
			window.location.href='reguli.php?id='+document.getElementById("categorie").value;
		}
}
function rdclas(){
		if (document.getElementById("tip").value != 0)
		{
			window.location.href='clasificari.php?id='+document.getElementById("tip").value;
		}
}
function rdchest(){
		if (document.getElementById("chestionar").value != 0)
		{
			window.location.href='chestionare.php?id='+document.getElementById("chestionar").value;
		}
}

function rdcos(id,pid,cant){
	document.getElementById('adauga_produs').href='coscump.php?apid='+pid+'&id='+id+'&cant='+cant;
    //window.location.href='coscump.php?apid='+pid+'&id='+id+'&cant='+cant;
}

function rdpro(){
//    alert('debug');
	window.location.href='promotii.php?zona='+document.getElementById('zona').value;
}

function checkAll(name,vb)
{
		var inp=document.getElementsByName(name);
		for (i=0;i<inp.length;i++)
		{
			inp[i].checked=vb; 
		}
}
function verifyOrder() 
{
	msg = "";
	res = true;
	if ( document.order.cnp.value == '' )
	{
		msg += "\n CNP este obligatoriu";
		res = false;
	}
//	if ( document.order.prenume.value == '' )
//	{
//		msg += "\n Prenumele este obligatoriu";
//		res = false;
//	}
//	if ( document.order.telefon.value == '' )
//	{
//		msg += "\n Nr de telefon este obligatoriu";
//		res = false;
//	}
	if ( !res )
	{
		alert(msg);
		return false;
	}
	else 
	{
		return true;
	}
	
}

function setHiddenSubmit(obj,val,form)
{
	obj.value=val;
	form.submit();
}


function checkAbonare()
{
    if (checkCompletare(document.getElementById("email")) && checkMail(document.getElementById("email").value))
    {
      alert("Multumim pentru inscriere!"); return true;
    }
    else
    {
      alert("Va rugam completati e-mailul!"); return false;
    }
}

function checkInscriere()
{

//	if (!checkCompletare(document.inscriere.username))
//	{
//		alert ('Username este obligatoriu!'); return false;
//	}
	if (!checkCompletare(document.inscriere.parola))
	{
		alert ('Parola este obligatorie!'); return false;
	}
//	if (!checkCompletare(document.inscriere.firma))
//	{
//		alert ('Denumirea firmei este obligatorie!'); return false;
//	}
//	if (!checkCompletare(document.inscriere.cui))
//	{
//		alert ('CUI este obligatoriu!'); return false;
//	}
//	if (!checkCompletare(document.inscriere.regcom))
//	{
//		alert ('Registrul Comertului este obligatoriu!'); return false;
//	}
//	if (document.inscriere.regcom.value.length<10)
//	{
//		alert ('Lungimea minima a Registrului Comertului este de 10 caractere !'); return false;
//	}
//	if (!checkCompletare(document.inscriere.cont))
//	{
//		alert ('Contul bancar este obligatoriu!'); return false;
//	}
//	if (document.inscriere.cont.value.length<24)
//	{
//		alert ('Lungimea minima a contului este de 24 caractere !'); return false;
//	}
	if (document.inscriere.telefon.value=='')
	    {
		alert ('Telefonul este obligatoriu!'); return false;
	    }
	else
	    {
		vbt=true;
		var numere = "0123456789";
		if (document.inscriere.telefon.value.toString().length!=10)
		    {
			vbt=false;
		    }
		for (i=0;i<document.inscriere.telefon.value.toString().length;i++)
		    {
			if (numere.indexOf(document.inscriere.telefon.value.toString().charAt(i))==-1)
			    {
//				alert(document.inscriere.telefon.value.toString().charAt(i));
				vbt=false; break;
			    }
		    }
		if (!vbt)
		    {
			alert('Telefonul trebuie sa contina exact 10 cifre (ex:0720123456)!'); return false;
		    }
	    }

	 if (document.inscriere.nume.value=='')
	    {
		alert ('Numele este obligatoriu!'); return false;
	    }
	else
	    {
		vbt=true;
		var numere = "0123456789";
		for (i=0;i<document.inscriere.nume.value.toString().length;i++)
		    {
			if (numere.indexOf(document.inscriere.nume.value.toString().charAt(i))!=-1)
			    {
				vbt=false; break;
			    }
		    }
		if (!vbt)
		    {
			alert('Numele nu trebuie sa contina cifre!'); return false;
		    }
	    }
	    
	    if (document.inscriere.email.value=='')
		{
		    alert ('Email-ul este obligatoriu!'); return false;
		}
	    else
		{
		    if (document.inscriere.email.value.toString().search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
			{
			    alert ('Email-ul nu este in format corect!'); return false;
			}
		}
	    alert("Multumim!");
}

function adaosnou()
{
    adaos=document.getElementById("adaos").value; alert(adaos);
}
function switch_style(val)
{
//	sus = "document.getElementById('sus_" + val + "').className = 'caseta_md_sus_selected'";
//	eval(sus);
//	mijloc = "document.getElementById('mijloc_" + val + "').className = 'caseta_md_mijloc_selected'" ;
//	eval(mijloc);
//	jos = "document.getElementById('jos_" + val + "').className = 'caseta_md_jos_selected'";
//	eval(jos);
//	promo = "document.getElementById('promo_" + val + "').className = 'home_promo_selected'";
//	eval(promo);
}
function switch_back(val)
{
//	sus = "document.getElementById('sus_" + val + "').className = 'caseta_md_sus'";
//	eval(sus);
//	mijloc = "document.getElementById('mijloc_" + val + "').className = 'caseta_md_mijloc'" ;
//	eval(mijloc);
//	jos = "document.getElementById('jos_" + val + "').className = 'caseta_md_jos'";
//	eval(jos);
//	promo = "document.getElementById('promo_" + val + "').className = 'home_promo'";
//	eval(promo);
}
function getHeight(idcount)
{
	maxHeight = 0;
	if ( idcount == "") 
	{
		idcount = -1;
	}
	for (i=1; i<=idcount; i++)
	{
		valoare = document.getElementById("mijloc_"+ i);
		if ( valoare != "" )
		{
			if ( maxHeight < valoare.offsetHeight )
			{
				maxHeight = valoare.offsetHeight;
			}
			//alert(valoare.offsetHeight);
			//if ( i % 3 == 0 )
			//{
			//	valoare = document.getElementById("table_" + (i - 2) );
			//	valoare.style.height = maxHeight;
			//	valoare = document.getElementById("table_" + (i - 1) );
			//	valoare.style.height = maxHeight;
			//	valoare = document.getElementById("table_" + i );
			//	valoare.style.height = maxHeight;
			//	maxHeight = 0;
			//}
		}
		if ( i == idcount )
		{
			for (i=1; i<=idcount; i++)
				{
					valoare = document.getElementById("mijloc_"+ i);
					valoare.style.height = maxHeight;
					//alert(maxHeight);
				}
		}
	}
}

function checkContact()
{
	var str="Va rugam completati urmatoarele campuri:";
	var vb=true;

	if (!checkCompletare(document.contact.nume))
	{
		str=str+"\n Nume"; vb=false;
	}

	if (!checkCompletare(document.contact.telefon))
	{
		str=str+"\n Telefon"; vb=false;
	}

	if (!checkCompletare(document.contact.email))
	{
		str=str+"\n Email"; vb=false;
	}

	if (!checkCompletare(document.contact.mesaj))
	{
		str=str+"\n Mesaj"; vb=false;
	}

	if (!checkCompletare(document.contact.antispam))
	{
		str=str+"\n Filtru anti-spam"; vb=false;
	}
    else
        {
            if (parseInt(document.contact.antispam.value)!=(parseInt(document.contact.spam1.value)+parseInt(document.contact.spam2.value)))
                {
                    //alert(parseInt(document.contact.spam1.value)+parseInt(document.contact.spam2.value));
                    str=str+"\n Filtrul anti-spam nu este corect"; vb=false;
                }
        }
    
	if (!vb)
	{
		alert(str);
	}

	return vb;
}

function checkCerere()
{
	var str="Va rugam completati urmatoarele campuri:";
	var vb=true;

	if (!checkCompletare(document.contact.nume))
	{
		str=str+"\n Nume"; vb=false;
	}

	if (!checkCompletare(document.contact.telefon))
	{
		str=str+"\n Telefon"; vb=false;
	}

	if (!checkCompletare(document.contact.email))
	{
		str=str+"\n Email"; vb=false;
	}

	if (!checkCompletare(document.contact.cerere))
	{
		str=str+"\n Cerere"; vb=false;
	}

	if (!checkCompletare(document.contact.antispam))
	{
		str=str+"\n Filtru anti-spam"; vb=false;
	}
    else
        {
            if (parseInt(document.contact.antispam.value)!=(parseInt(document.contact.spam1.value)+parseInt(document.contact.spam2.value)))
                {
                    //alert(parseInt(document.contact.spam1.value)+parseInt(document.contact.spam2.value));
                    str=str+"\n Filtrul anti-spam nu este corect"; vb=false;
                }
        }

	if (!vb)
	{
		alert(str);
	}

	return vb;
}
function switchdet(val1,val2)
{
	v1 = val1 + "1";
	v2 = val2 + "1";
	document.getElementById(v1).className='detalii_tab_sel';
	// document.getElementById(v1).className = 'visible';
	document.getElementById(v2).className='detalii_tab';
	document.getElementById(val1).className="size_12 visible";
	document.getElementById(val2).className="hidden";
}