var nv = (navigator.appName.indexOf("Netscape") != -1) || window.opera;

function initSettings(){
	if($('.goTop').length > 0){ 
		$('.goTop').each(function(index) {
				  $(this).click(function() {goTop();});
		});
	}
}

function checkSendContact(f)
{
	if(!isEMailAddr(f.email.value)){
		f.email.focus();
		alert('Adresa de email invalida!');
		return false;
	}
	if(isEmpty(f.mesaj.value)){
		f.mesaj.focus();
		alert('Introduceti mesajul!');
		return false;
	}
return true;	
}

function goTop(){
	$('html, body').animate({scrollTop:0}, 'slow');
}

function changePq(dir){
	if(dir=='up') pq +=1;
	else if(pq>1) pq -=1;
	$("#pq_cont").html(pq);
}

function changePqInCart(id,val){
	document.location='index.php?loc=8&updatePq='+id+'&q='+val;
}

function checkSendOrder(f){
	if(isEmpty(f.nume.value)){
		f.nume.focus();
		alert('Introduceti Nume!');
		return false;
	}
	if(!isEMailAddr(f.email.value)){
		f.email.focus();
		alert('Adresa de email invalida!');
		return false;
	}
	if(isEmpty(f.cnp_CIF.value)){
		f.cnp_CIF.focus();
		alert('Introduceti CNP/CIF!');
		return false;
	}
	return true;
}

function checkNltFrm(f){
	if(!isEMailAddr(f.email.value)){
		f.email.focus();
		alert('Adresa de email invalida!');
		return false;
	}
	$.ajax({
	   type: "POST",
	   url: "ajaxHendler.php",
	   data: "action=doAddNltUser&email="+f.email.value+"&list_id="+f.list.value,
	   success: function(msg){
		 res = get_response_tag('tag1',msg);
		 //$("#tmp_id").html(res);
	   }
	});
	f.email.value = '';
	alert('Adresa dumneavoastra a fost inregistrata. Va multumim.');
	return false;
}

function chechAddComment(f){
	if(isEmpty(f.nume.value)){
		f.nume.focus();
		alert('Introduceti Numele!');
		return false;
	}
	if(!isEMailAddr(f.email.value)){
		f.email.focus();
		alert('Adresa de email invalida!');
		return false;
	}if(isEmpty(f.mess.value)){
		f.mess.focus();
		alert('Introduceti parerea dumneavoastra!');
		return false;
	}
	
	$.ajax({
	   type: "POST",
	   url: "ajaxHendler.php",
	   data: "action=doAddComent&pid="+f.pid.value+"&nume="+f.nume.value+"&email="+f.email.value+"&mess="+f.mess.value,
	   success: function(msg){
		 res = get_response_tag('tag1',msg);
		 $("#add_com").html('<b>Mesajul dumneavostra a fost trimis. Va multumim.</b>');
	   }
	});
	
	return false;
}

function checkRecomanda(f){
	if(isEmpty(f.nume.value)){
		f.nume.focus();
		alert('Introduceti Numele!');
		return false;
	}
	if(!isEMailAddr(f.email.value)){
		f.email.focus();
		alert('Adresa de email invalida!');
		return false;
	}if(isEmpty(f.mess.value)){
		f.mess.focus();
		alert('Introduceti mesajul dumneavoastra!');
		return false;
	}	
	
	$.ajax({
	   type: "POST",
	   url: "ajaxHendler.php",
	   data: "action=doSendRecom&pid="+f.pid.value+"&nume="+f.nume.value+"&email="+f.email.value+"&mess="+f.mess.value,
	   success: function(msg){
		 res = get_response_tag('tag1',msg);
		 $("#snd_recom").html('<b>Mesajul dumneavostra a fost trimis. Va multumim.</b>');
	   }
	});
	
	return false;
}

function showComDet(com_id){
	$.ajax({
	   type: "POST",
	   url: "ajaxHendler.php",
	   data: "action=showComDet&com_id="+com_id,
	   success: function(msg){
		 res = get_response_tag('tag1',msg);
		 $("#comment_det").html(res);
	   }
	});
}

function closeShFrm(){
	$("#shFrmCont").slideUp('fast');
	$("#sh_smnu").slideDown('fast');
}
