function showDialog(msg) {
	var body = document.getElementsByTagName("body")[0];
	var div = document.createElement("div");
	var closebtn = document.createElement("input");
	var input = document.createElement("input");

	div.style.position = "absolute";
	div.style.top = "50%";
	div.style.left = "50%";
	div.style.width = "300px";
	div.style.height = "60px";
	div.style.margin = "-50px 0 0 -170px";
	div.style.border = "3px double #999999";
	//div.style.opacity = "0.85";
	div.style.backgroundColor = "#FF7B0F";
	div.style.textAlign = "right";
	//div.style.padding = "20px";
	//div.style.fontSize = "60px";
	//div.style.lineHeight = "60px";
	div.style.opacity = "0.0";
	body.appendChild(div);

	input.type = "text";
	input.value = msg;
	input.style.position = "absolute";
	input.style.top = "30%";
	input.style.left = "0%";
	input.style.width = "300px";
	input.style.border = "1px solid #FF7B0F";
	input.style.backgroundColor = "#FF7B0F";
	input.style.fontSize = "12px"
	//input.style.fontFamily = "Arial, Helvetica, sans-serif";
	input.style.color = "#FFFFFF";
	input.style.textAlign = "center";

	div.appendChild(input);

 	closebtn.type = "image";
	closebtn.src = "./../images/close.gif";
	closebtn.style.textAlign = "right";

	closebtn = div.appendChild(closebtn);

	closebtn.onclick = function(e) {
		
		opacityDown(this.parentNode);
	}
	opacityUp(div);

};

function opacityUp(theElement) {
	var opacity = parseFloat(theElement.style.opacity);
	if (opacity > 0.80)	{
		return true;
	}
	else {
		opacity += 0.07;
		theElement.style.opacity = opacity;
		setTimeout(function(){opacityUp(theElement);}, 50);
	}
	
	return true;
};


function opacityDown(theElement) {
	var opacity = parseFloat(theElement.style.opacity);
	if (opacity < 0.08)	{
		theElement.parentNode.removeChild(theElement);
	}
	else {
		opacity -= 0.07;
		theElement.style.opacity = opacity;
		setTimeout(function(){opacityDown(theElement);}, 50);
	}
	
	return true;
};

var scrollspeed_body=0;

function move_up_down() {
	document.getElementById('scroll_body').scrollTop = document.getElementById('scroll_body').scrollTop+scrollspeed_body;
}

function viewPic(img) {
	if (img != null && img != '') {
		picfile = new Image();
   		picfile.src =(img);
		fileCheck(img);
	}
}

function fileCheck(img) {    
   if( (picfile.width!=0) && (picfile.height!=0) ) {
       makeWindow(img);
   }
   else {
       funzione="fileCheck('"+img+"')";
       intervallo=setTimeout(funzione,8);
   }
}

function makePopup2(url,docId,detailsId) {
  	wd = 550 + 20;
   	ht = 400 + 20;
   	var args= "height=" + ht;
   	args += ",width=" + wd;
   	if (window.screen) {
    	var avht = screen.availHeight - 30;
       	var avwd = screen.availWidth - 10;
       	var xcen = (avwd - wd) / 2;
       	var ycen = (avht - ht) / 2;
       	args += ",left=" + xcen + ",screenX=" + xcen;
       	args += ",top=" + ycen + ",screenY=" + ycen + ",resizable=yes,scrollbars=yes" ;    
   	}
	url = url + "?doc_id=" + docId + "&details_id=" + detailsId ;
   	window.open(url, 'popup', args);
}

function makePopup(url,initWd,initHt) {
  	wd = initWd + 20;
   	ht = initHt + 20;
   	var args= "height=" + ht;
   	args += ",width=" + wd;
   	if (window.screen) {
    	var avht = screen.availHeight - 30;
       	var avwd = screen.availWidth - 10;
       	var xcen = (avwd - wd) / 2;
       	var ycen = (avht - ht) / 2;
       	args += ",left=" + xcen + ",screenX=" + xcen;
       	args += ",top=" + ycen + ",screenY=" + ycen + ",resizable=yes,scrollbars=yes" ;    
   	}
   	window.open(url, 'popup', args);
}

function makePopupInfo(url,code,pr,disc,id) {
  	wd = 450 + 20;
   	ht = 460 + 20;
   	var args= "height=" + ht;
   	args += ",width=" + wd;
   	if (window.screen) {
    	var avht = screen.availHeight - 30;
       	var avwd = screen.availWidth - 10;
       	var xcen = (avwd - wd) / 2;
       	var ycen = (avht - ht) / 2;
       	args += ",left=" + xcen + ",screenX=" + xcen;
       	args += ",top=" + ycen + ",screenY=" + ycen + ",resizable=yes,scrollbars=yes" ;    
   	}
	url = url + "?code=" + code + "&price=" + pr + "&disc=" + disc + "&id=" + id;
   	window.open(url, 'popup', args);
}

function makePopupOldOrder(url,basketID) {
	wd = 600 + 20;
   	ht = 300 + 20;
   	var args= "height=" + ht;
   	args += ",width=" + wd;
   	if (window.screen) {
    	var avht = screen.availHeight - 30;
       	var avwd = screen.availWidth - 10;
       	var xcen = (avwd - wd) / 2;
       	var ycen = (avht - ht) / 2;
       	args += ",left=" + xcen + ",screenX=" + xcen;
       	args += ",top=" + ycen + ",screenY=" + ycen + ",resizable=yes,scrollbars=yes" ;    
   	}

	url = url + "?basketID=" + basketID;
   	window.open(url,'x',args);
}

function makeWindow(img) {    
   wd = picfile.width + 20;
   ht = picfile.height + 20;
   var args= "height=" + ht;
   args += ",width=" + wd;
   if (window.screen) {
       var avht = screen.availHeight - 30;
       var avwd = screen.availWidth - 10;
       var xcen = (avwd - wd) / 2;
       var ycen = (avht - ht) / 2;
       args += ",left=" + xcen + ",screenX=" + xcen;
       args += ",top=" + ycen + ",screenY=" + ycen + ",resizable=yes";    
   }
   return window.open(img, 'x', args);
}

function loadinparent(url, closeSelf){
	//location = url;
	self.opener.location = url;
	document.getElementById('basket:buttonConfirm').value='Loading...';
    document.getElementById('basket:buttonConfirm').onclick='return false';
    
	document.getElementById('basket:resetBasket').value='Loading...';
    document.getElementById('basket:resetBasket').onclick='return false';
	
	if(closeSelf) 
		self.close();
}

function refreshParent() {
	window.opener.location.href = "reload.jsp";

  	if (window.opener.progressWindow) {
		window.opener.progressWindow.close()
  	}
  	window.close();
}

function reloadParent(url) {
	//window.opener.location.href = "reload.jsp";
	self.opener.location = url;
}

function viewPDF(x) {
 	if (x != null && x != '') {
	    myTempWindow = window.open(x,'','left=10000,screenX=10000');
	    myTempWindow.document.execCommand('SaveAs','null',x);
	    myTempWindow.close();
    }
}

