<!--//Michel DEBOOM 06/2005
gk=window.Event?1:0; // navigateurs Gecko ou IE
D=document;popup=encours=0

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function printGligliTxt(el, s, p){
  pos = findPos(el);
  x = pos[0];
  y = pos[1];
  D.getElementById('gliglitxt').innerHTML = s;
  popup = D.getElementById('gliglitxt').style; 
  if(p == "haut"){
   if(gk){
    with(popup){display="block";left=x-70+'px';top=y-40+'px';}
   }
   else{
    with(popup){display="block";left=x-70+'px';top=y-15+'px';}
   }
  }
  else{
   if(gk){
    with(popup){display="block";left=x-70+'px';top=y+15+'px';}
   }
   else{
    with(popup){display="block";left=x-70+'px';top=y+35+'px';}
   }
  }
}
function printSampleTxt(el){
  pos = findPos(el);
  x = pos[0];
  y = pos[1];
  popup = D.getElementById('divsample').style; 
with(popup){display="block";left=x-50+'px';top=y-112+'px';}
}

function printRatingTxt(el, id, position){
  pos = findPos(el);
  x = pos[0];
  y = pos[1];
  D.getElementById('ratecigarid').value = id;
  popup = D.getElementById('divrating').style; 
  if(position == "haut"){
   D.getElementById('imgmainrating'+id).src = '/cuban-cigars/img/main_rating_vert.gif';
   if(gk){
    with(popup){display="block";left=x-30+'px';top=y-290+'px';}
   }
   else{
    with(popup){display="block";left=x-55+'px';top=y-295+'px';}
   }
  }
  else if(position == "bas"){
   D.getElementById('imgmainrating'+id).src = '/cuban-cigars/img/MAIN_Petite_vert2.gif';
   if(gk){
    with(popup){display="block";left=x-30+'px';top=y+25+'px';}
   }
   else{
    with(popup){display="block";left=x-55+'px';top=y+25+'px';}
   }
  }
  else if(position == "hautgauche"){
   D.getElementById('imgmainrating'+id).src = '/cuban-cigars/img/main_rating_vert.gif';
   if(gk){
    with(popup){display="block";left=x-200+'px';top=y-290+'px';}
   }
   else{
    with(popup){display="block";left=x-200+'px';top=y-295+'px';}
   }
  }
  else if(position == "hautdroite"){
   D.getElementById('imgmainrating'+id).src = '/cuban-cigars/img/main_rating_vert.gif';
   if(gk){
    with(popup){display="block";left=x-400+'px';top=y-290+'px';}
   }
   else{
    with(popup){display="block";left=x-413+'px';top=y-295+'px';}
   }
  }
  else if(position == "hautdroite2"){
   D.getElementById('imgmainrating'+id).src = '/cuban-cigars/img/main_rating_vert.gif';
   if(gk){
    with(popup){display="block";left=x-222+'px';top=y-290+'px';}
   }
   else{
    with(popup){display="block";left=x-413+'px';top=y-295+'px';}
   }
  }
}

function hideGligliTxt(){
  popup = D.getElementById('gliglitxt').style; 
  with(popup){display="none";}
}
function hideSampleTxt(){
  popup = D.getElementById('divsample').style; 
  with(popup){display="none";}
}
function hideRatingTxt(){
  D.getElementById('imgmainrating'+D.getElementById('ratecigarid').value).src = '/cuban-cigars/img/main_rating.gif';

  popup = D.getElementById('divrating').style; 
  with(popup){display="none";}

  D.getElementById('changerating').value = "";

  popup = D.getElementById('perror').style; 
  with(popup){color="#000"; fontsize="12px"; textTransform="none"}

  D.getElementById('penter').style.display = 'block';
  D.getElementById('pthank').style.display = 'none';
}

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 makeRequest(form) {
        var httpRequest = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!httpRequest) {
            alert('Abandon :( Impossible de créer une instance XMLHTTP');
            return false;
        }
        httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
        httpRequest.open('POST', 'http://www.cigarone.com/cuban-cigars/cigar-rating.inc.php', true);
	httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        httpRequest.send("ratecigarid="+form.ratecigarid.value+"&changerating="+form.changerating.value);
}

function alertContents(httpRequest) {

        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {
                if(httpRequest.responseText == "1"){
			D.getElementById('penter').style.display = 'none';
			D.getElementById('pthank').style.display = 'block';
		}
		else{
			popup = D.getElementById('perror').style; 
			with(popup){color="#FF9A00"; fontSize="11px"; textTransform="uppercase"}
		}
            } else {
                alert('Un problème est survenu avec la requête.');
            }
        }

}
