// JavaScript Document

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function check_referer(id)
{
	
	if(id.value=='1'){
		$("#referer").css("display", ""); 
	} else {
		$("#referer").css("display", "none"); 
	}
	
}


function show_card()
{

		

		var left = getAbsoluteLeft('icon_contact');
	

		var top = getAbsoluteTop('icon_contact');
		
		
		var resp = document.getElementById('card');
		resp.style.top = top-180+'px';
		resp.style.left = left+45+'px';
		


		document.getElementById('card').style.display='';
		return false;

	
		
}


function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId);
	oLeft = o.offsetLeft ;           // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent ;   // Get parent object reference
		oLeft += oParent.offsetLeft; // Add parent left position
		o = oParent;
	}
	// Return left postion
	return oLeft;
}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId);
	oTop = o.offsetTop       ;     // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent ; // Get parent object reference
		oTop += oParent.offsetTop; // Add parent top position
		o = oParent;
	}
	// Return top position
	return oTop;
}


function check_order()
{
	if (document.order_form.fname.value=="") {
		alert("Va rugam adaugati numele pentru a continua.");
		document.order_form.fname.focus();
		return false;
	}

	if (document.order_form.lname.value=="") {
		alert("Va rugam adaugati prenumele pentru a continua.");
		document.order_form.lname.focus();
		return false;
	}
	
	if (document.order_form.cnp.value=="") {
		alert("Va rugam adaugati CNP-ul pentru a continua.");
		document.order_form.cnp.focus();
		return false;
	}
	
	if (document.order_form.city.value=="") {
		alert("Va rugam adaugati oras-ul pentru a continua.");
		document.order_form.city.focus();
		return false;
	}
	
	if (document.order_form.address_1.value=="") {
		alert("Va rugam adaugati adresa pentru a continua.");
		document.order_form.address_1.focus();
		return false;
	}	
	
	if (document.order_form.code.value=="") {
		alert("Va rugam adaugati codul postal pentru a continua.");
		document.order_form.code.focus();
		return false;
	}		
	
	if (document.order_form.phone.value=="") {
		alert("Va rugam adaugati numarul de telefon pentru a continua.");
		document.order_form.phone.focus();
		return false;
	}	
	
	if (document.order_form.email.value=="") {
		alert("Va rugam adaugati adresa de email pentru a continua.");
		document.order_form.email.focus();
		return false;
	}
	
	if (document.order_form.agg.checked==false) {
		alert("Pentru a continua va rugam sa accepati termenii si conditiile.");
		document.order_form.agg.focus();
		return false;
	}		
}


