
function getMyXhr()
{
	var xhr = null;
	if(window.XMLHttpRequest) // Firefox et autres
		xhr = new XMLHttpRequest();
	else if(window.ActiveXObject)
	{ // Internet Explorer
		try 
		{
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else
	{ // XMLHttpRequest not suported by browser
		alert("Please upgrade your browser...");
		xhr = false;
	}
	return xhr;
}

function setOpacity(opac)
{
	var formBoxOpac=document.getElementById('formBox');
	var boxOverlayOpac=document.getElementById('boxOverlay');

	if (opac==-1)
	{
		formBoxOpac.style.display = 'none';
		boxOverlayOpac.style.display = 'none';
	}

	if (opac<=7)
	{
		boxOverlayOpac.style.opacity = opac/10;
		boxOverlayOpac.style.filter = 'alpha(opacity=' + opac*10 + ')';
	}

	formBoxOpac.style.opacity = opac/10;
	formBoxOpac.style.filter = 'alpha(opacity=' + opac*10 + ')';
}

function openFormBox()
{
	var contentBox=document.getElementById('contentBox');
	contentBox.innerHTML='<table width="100%" border="0" cellspacing="5" cellpadding="5" ><tr ><td class="divTableTitleAjax" align="center">RIVIĖRES D\'OCÉANIE</td></tr><tr><td class="divTableContentAjax" style="text-align: center" align="center" valign="middle" height="300px"><img src="/images/loading.gif" alt="LOADING" align="center" /></td></tr><tr bgcolor="#99CCFF"><td class="divTableTitleAjax" align="center">RIVIĖRES D\'OCÉANIE</td></tr></table>';
	
	if(window.innerHeight && window.scrollMaxY ) // Firefox 
	{
		pageWidth = window.innerWidth + window.scrollMaxX;
		pageHeight = window.innerHeight + window.scrollMaxY;
	}
	else if( document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
	{
		pageWidth = document.body.scrollWidth;
		pageHeight = document.body.scrollHeight;
	}
	else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	{ 
		pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
		pageHeight = document.body.offsetHeight + document.body.offsetTop; 
	}

	if (pageHeight<screen.height) pageHeight=screen.height;
	if (pageWidth<screen.width) pageWidth=screen.width;

	var boxOverlay=document.getElementById('boxOverlay');
	var formBox=document.getElementById('formBox');
	boxOverlay.style.opacity = 0;
	boxOverlay.style.filter = 'alpha(opacity=0)';
	boxOverlay.style.display = 'block';
	boxOverlay.style.width= pageWidth + 'px';
	boxOverlay.style.height= pageHeight + 'px';
	formBox.style.opacity = 0;
	formBox.style.filter = 'alpha(opacity=0)';
	formBox.style.display = 'block';

	for (var i=0;i<=10;i++) setTimeout('setOpacity('+i+')',70*i);
}

function closeFormBox()
{
	var formBox=document.getElementById('formBox');
	var boxOverlay=document.getElementById('boxOverlay');
	var contentBox=document.getElementById('contentBox');

	for (i=7;i>=-1;i--)
	{
		setTimeout('setOpacity('+i+')',100*(10-i));
	}
}

function onlyNumbers(evt)
{
	evt = (evt) ? evt : window.event
  var charCode = (evt.which) ? evt.which : evt.keyCode

  if (charCode > 31 && ((charCode < 48 || charCode > 57) && charCode!=46 && charCode!=37 && charCode!=39 && charCode!=35)) 
  {
  	status = "This field accepts numbers only."
    return false
	}
  status = "";
  return true;
}

function getSelectedValue(obj)
{
	return obj.options[obj.selectedIndex].value;
}


function editPictures(idProduct, url, lg)
{
		debug=false;
		var contentBox=document.getElementById('contentBox');

		openFormBox();

		if (debug==true ) alert('going now');

		xhrManu=getMyXhr();

		// we define what will happen when we will get the answer
		xhrManu.onreadystatechange = 	function()
													{
														if (debug==true ) alert('xhrManu.readyState' + xhrManu.readyState + '\nxhrManu.status' + xhrManu.status);
														// only if we get everything and all if well
														if (xhrManu.readyState == 4 && xhrManu.status == 200)
														{
															divContent= xhrManu.responseText;
															if (debug==true ) alert('I receive '+ divContent);
															contentBox.innerHTML=divContent;
														}
													}

		// POST way of doing
		xhrManu.open("POST","/fr/editPictures/",true);

		// do not forget this line for the post
		xhrManu.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

		// construct params
		param="idProduct="+idProduct+"&url="+url+"&lg="+lg;

		if (debug==true ) alert('I ask with parameters ' + param);
		xhrManu.send(param);
}
//construct params

