// Esegue il download di un file attraverso uno script php

var is_login = 0;
var user_ok = 0;
var mesg_sent = 0;

function download(path,name){		

	var req = Math.floor(Math.random()*1000);	
	location.href="/extra/danieli/download.php?file="+path+"&nome="+name+"&req="+req;
	
}

function login(){
	unset_cookie('Library_Login');
	Mediabox.open('#mb_login_alert', '', '300 250');
}

function library_login(){
	set_cookie_val('Library_Login','true');
	Mediabox.open('#mb_library_alert', '', '300 250');
}

function go_to_library(){
	unset_cookie('Library_Login');
	top.location.href= '/News/Danieli-Library';	
}

function copy_request(name,nid,uid){
	document.getElementsByName("name").item(0).value = name;
	document.getElementsByName("name_id").item(0).value = nid;
	document.getElementsByName("uid").item(0).value = uid;
	setTimeout("Mediabox.open('#mb_order', '', '390 395')", 300);
	//Mediabox.open('#mb_order', '', '390 395');	
}

function send_library(){
	var req = Math.floor(Math.random()*1000);
	var num = document.getElementsByName("num").item(1).value;
	var title = document.getElementsByName("title").item(1).value;
	var last_name = document.getElementsByName("last_name").item(1).value;
	var first_name = document.getElementsByName("first_name").item(1).value;
	var position = document.getElementsByName("position").item(1).value;
	var company = document.getElementsByName("company").item(1).value;
	var address = document.getElementsByName("address").item(1).value;
	var city = document.getElementsByName("city").item(1).value;
	var state = document.getElementsByName("state").item(1).value;
	var zip = document.getElementsByName("zip").item(1).value;
	var country = document.getElementsByName("country").item(1).value;
	var account = document.getElementsByName("account").item(0).value;
	var name = document.getElementsByName("name").item(0).value;
	var name_id = document.getElementsByName("name_id").item(0).value;
	var uid = document.getElementsByName("uid").item(0).value;
	var chk = document.getElementsByName("chk").item(0).value;
	var request = 'num='+num+'&title='+title+'&last_name='+last_name+'&first_name='+first_name+'&position='+position+'&company='+company+'&address='+address+'&city='+city+'&state='+state+'&zip='+zip+'&country='+country+'&uid='+uid+'&account='+account+'&name='+name+'&name_id='+name_id+'&chk='+chk+'&req='+req;
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	  var fnWhenDone = function (oXML) {
	  var response = oXML.responseText;
	  document.getElementById("mbImage").innerHTML = "<div id=\"order_content\">"+response+"</div>";
	};			  
   myConn.connect("/extra/danieli/mailer/send_library.php", "POST",request, fnWhenDone);	
}

function historical(name,nid,uid){	
	setTimeout("Mediabox.open('http://www.danieli.com/extra/danieli/Library/index.php?c=welcome&m=viewGrid_Historical&pubb="+name+"&uid="+uid+"&nid="+nid+"', '', '950 360')", 300);
	//Mediabox.open('http://www.danieli.com/extra/danieli/Library/index.php?c=welcome&m=viewGrid_Historical&pubb='+name+'&uid='+uid+'&nid='+nid, '', '950 360');
}