/*
var cp = new cpaint();
cp.set_response_type('text');
cp.set_debug(0);
*/


function response(result) {
		document.getElementById('response').innerHTML = result;
}

function check_recomanda(r_link)
{

		if (document.recomanda.name_exp.value=="" || document.recomanda.name_exp.value=="Nume expeditor") {
			alert("Va rugam adaugati numele dvs pentru a continua.");
			document.recomanda.name_exp.focus();
			return false;
		}
		if (document.recomanda.email_exp.value=="" || document.recomanda.email_exp.value=="E-mail expeditor") {
			alert("Va rugam adaugati e-mailul dvs pentru a continua.");
			document.recomanda.email_exp.focus();
			return false;
		}
		if (document.recomanda.name_dest.value=="" || document.recomanda.name_dest.value=="Nume destinatar") {
			alert("Va rugam adaugati numele destinatarului pentru a continua.");
			document.recomanda.name_dest.focus();
			return false;
		}
		if (document.recomanda.email_dest.value=="" || document.recomanda.email_dest.value=="E-mail destinatar") {
			alert("Va rugam adaugati e-mailul destinatarului pentru a continua.");
			document.recomanda.email_dest.focus();
			return false;
		}

		
		cp.call('cgi.php',"&r_link="+r_link+"&name_exp="+document.recomanda.name_exp.value+"&name_dest="+document.recomanda.name_dest.value+"&email_dest="+document.recomanda.email_dest.value+"&email_exp="+document.recomanda.email_exp.value, response);

		return false;
}

/*
var cp2 = new cpaint();
cp2.set_response_type('text');
cp2.set_debug(0);
*/


function response2(result) {
		document.getElementById('response2').innerHTML = result;
}


function check_request()
{

		if (document.detalii.p_name.value=="" || document.detalii.p_name.value=="Numele dvs") {
			alert("Va rugam adaugati numele dvs pentru a continua.");
			document.detalii.p_name.focus();
			return false;
		}
		if (document.detalii.p_email.value=="" || document.detalii.p_email.value=="Adresa email") {
			alert("Va rugam adaugati e-mailul dvs pentru a continua.");
			document.detalii.p_email.focus();
			return false;
		}
		if (document.detalii.msg.value=="" || document.detalii.msg.value=="Intrebare ...") {
			alert("Va rugam adaugati intrebarea pentru a continua.");
			document.detalii.msg.focus();
			return false;
		}

		
		cp2.call('cgi2.php',"&p_produs="+document.detalii.p_produs.value+"&p_name="+document.detalii.p_name.value+"&p_email="+document.detalii.p_email.value+"&msg="+document.detalii.msg.value, response2);

		return false;
}

function viewimg(nr,id){
	var we=724;
	var hi=600;
	var top=100;
	var left=100;

	var features = "width="+we+", height="+hi+", top="+top+", left="+left+", scrollbars=yes";
	w=window.open('/viewimg/'+nr+'/'+id,"details",features);
	w.focus();
}

function check_register()
{


	if (document.register.email.value=="" || document.register.email.value=="adresa@email") {
		alert("Va rugam adaugati adresa de e-mail pentru a continua.");
		document.register.email.value="";
		document.register.email.focus();
		return false;
	} else {
		ast=document.register.email.value.indexOf("@");
		dot=document.register.email.value.lastIndexOf(".");
		if(!(ast>0 && dot>0 && dot>ast)){
			alert("Va rugam adaugati o adresa de e-mail valida pentru a continua.");
			document.register.email.focus();
			return false;
	}}

	if (document.register.email_again.value!=document.register.email.value) {
		alert("Atentie adresa de email este gresita la rescriere.");
		document.register.email_again.focus();
		return false;
	}
	
	if (document.register.password.value=="") {
		alert("Va rugam adaugati parola pentru a continua.");
		document.register.password.focus();
		return false;
	}

	if (document.register.password_again.value!=document.register.password.value) {
		alert("Atentie parola este gresita la rescriere.");
		document.register.password_again.focus();
		return false;
	}

	if (document.register.code.value=="") {
		alert("Va rugam adaugati codul de siguranta din imaginea de mai sus pentru a continua.");
		document.register.code.focus();
		return false;
	}
	
	
	return true;
}


function focusField(field) {
	field.style.background = '#fdf2c6';
}

function update_register()
{


	if (document.update_security.password.value=="") {
		alert("Va rugam adaugati parola pentru a continua.");
		document.update_security.password.focus();
		return false;
	}

	if (document.update_security.password_again.value!=document.update_security.password.value) {
		alert("Atentie parola este gresita la rescriere.");
		document.update_security.password_again.value="";
		document.update_security.password_again.focus();
		return false;
	}

	return true;
}

function check_active_form()
{
	if (document.active_form.active.value=="") {
		alert("Va rugam adaugati codul de activare a contului, primit in adresa dumneavoastra de email pentru a continua.");
		document.active_form.active.focus();
		return false;
	}
	return true;
}

function check_fpassword_form()
{

	if (document.f_password.fpass_email.value=="" || document.f_password.fpass_email.value=="-") {
		alert("Va rugam adaugati adresa de e-mail pentru a continua.");
		
		document.f_password.fpass_email.focus();
		return false;
	} else {
		ast=document.f_password.fpass_email.value.indexOf("@");
		dot=document.f_password.fpass_email.value.lastIndexOf(".");
		if(!(ast>0 && dot>0 && dot>ast)){
			alert("Va rugam adaugati o adresa de e-mail valida pentru a continua.");
			document.f_password.fpass_email.value="";
			document.f_password.fpass_email.focus();
			return false;
	}}

	return true;
}


function check_login()
{
	if (document.login.email.value=="" || document.login.email.value=="adresa@email") {
		alert("Va rugam adaugati adresa de email pentru a continua.");
		document.login.email.focus();
		return false;
	}
	
	if (document.login.password.value=="" || document.login.password.value=="password") {
		alert("Va rugam adaugati parola pentru a continua.");
		document.login.password.focus();
		return false;
	}
	return true;
}

	function check_form()
	{
	
		if (document.contact_form.name.value=="" || document.contact_form.name.value=="-") {
			alert("Va rugam adaugati numele dumneavoastra pentru a continua.");
			document.contact_form.name.focus();
			return false;
		}
		if (document.contact_form.company.value=="" || document.contact_form.company.value=="-") {
			alert("Va rugam adaugati firma pentru a continua.");
			document.contact_form.company.focus();
			return false;
		}
		if (document.contact_form.email.value=="" || document.contact_form.email.value=="-") {
			alert("Va rugam adaugati email-ul pentru a continua.");
			document.contact_form.email.focus();
			return false;
		}
	
		if (document.contact_form.message.value=="" || document.contact_form.message.value=="-") {
			alert("Va rugam adaugati mesajul dumneavoastra pentru a continua.");
			document.contact_form.message.focus();
			return false;
		}
	
		return true;
	}



		function newsletter_(){
		if (document.newsletter.email.value=="" || document.newsletter.email.value=="adresa@email") {
			alert("Va rugam adaugati adresa de e-mail pentru a continua.");
			document.newsletter.email.value="";
			document.newsletter.email.focus();
			return false;
		} else {
			ast=document.newsletter.email.value.indexOf("@");
			dot=document.newsletter.email.value.lastIndexOf(".");
			if(!(ast>0 && dot>0 && dot>ast)){
				alert("Va rugam adaugati o adresa de e-mail valida pentru a continua.");
				document.newsletter.email.focus();
				return false;
		}}
		
		closebar();
	}
	
	function clear_newsletter(){
		
		if (document.newsletter.email.value=="adresa@email") {
			document.newsletter.email.value="";
			document.newsletter.email.focus();

			return false;
		}

	}

/*
	var cp = new cpaint();
	cp.set_response_type('text');
	cp.set_debug(0);
*/


	function response(result) {
		document.getElementById('response').innerHTML = result;
	}

	function check_recomanda(r_link)
	{

		if (document.recomanda.name_exp.value=="" || document.recomanda.name_exp.value=="Nume expeditor") {
			alert("Va rugam adaugati numele dvs pentru a continua.");
			document.recomanda.name_exp.focus();
			return false;
		}
		if (document.recomanda.email_exp.value=="" || document.recomanda.email_exp.value=="E-mail expeditor") {
			alert("Va rugam adaugati e-mailul dvs pentru a continua.");
			document.recomanda.email_exp.focus();
			return false;
		}
		if (document.recomanda.name_dest.value=="" || document.recomanda.name_dest.value=="Nume destinatar") {
			alert("Va rugam adaugati numele destinatarului pentru a continua.");
			document.recomanda.name_dest.focus();
			return false;
		}
		if (document.recomanda.email_dest.value=="" || document.recomanda.email_dest.value=="E-mail destinatar") {
			alert("Va rugam adaugati e-mailul destinatarului pentru a continua.");
			document.recomanda.email_dest.focus();
			return false;
		}

		
		cp.call('cgi.php',"&r_link="+r_link+"&name_exp="+document.recomanda.name_exp.value+"&name_dest="+document.recomanda.name_dest.value+"&email_dest="+document.recomanda.email_dest.value+"&email_exp="+document.recomanda.email_exp.value, response);

		return false;
	}

	function clear_field(field,name)
	{
		//alert(field);
		if(field.value==name){
			field.value="";
		}
	}




	function key(){
		if (document.search_form.search_text.value==""){
			alert("Va rugam adaugati textul cautat.");
			document.search_form.search_text.focus();
			return false;
		}
		if(document.search_form.search_text.value!="") {
			if(document.search_form.search_text.value.length<4) {
			alert("Va rugam introduceti minim 4 caractere pentru cautare");
			document.search_form.search_text.focus();
			return false;
		}}
	}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function execute_order(){
		if(confirm("Doriti sa plasati comanda?")) return true;
		else return false;
		
		
}



/* box */


var persistclose=1 //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
var startX =600//set x offset of bar in pixels
var startY = 5 //set y offset of bar in pixels
var verticalpos="frombottom" //enter "fromtop" or "frombottom"

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function closebar(){
if (persistclose)
document.cookie="remainclosed=1"
document.getElementById("topbar").style.visibility="hidden"
}

function staticbar(){
	barheight=document.getElementById("topbar").offsetHeight
	var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
	var d = document;
	function ml(id){
		var el=d.getElementById(id);
		if (!persistclose || persistclose && get_cookie("remainclosed")=="")
		el.style.visibility="visible"
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
		el.x = startX;
		if (verticalpos=="fromtop")
		el.y = startY;
		else{
		el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;
		el.y -= startY;
		}
		return el;
	}
	window.stayTopLeft=function(){
		if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : iecompattest().scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
		var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 10);
	}
	ftlObj = ml("topbar");
	stayTopLeft();
}

if (window.addEventListener)
window.addEventListener("load", staticbar, false)
else if (window.attachEvent)
window.attachEvent("onload", staticbar)
else if (document.getElementById)
window.onload=staticbar
