function o(div){
	if(object=document.getElementById(div)){
		return object;
	}
	return false;
}
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function resp(str,div){
	div=o(div);
	function stateChanged(){
		if(xml.readyState==4){
			div.innerHTML=xml.responseText;
		}
	}
	xml=GetXmlHttpObject();
	if(xml==null){
		alert("Il tuo browser non supporta AJAX");
		return;
	}
	url="./imgdeal.php?&i="+Math.random()+"&"+str;
	xml.onreadystatechange=stateChanged;
	xml.open("GET",url,true);
	xml.send(null);
}

function response(str,div){
	div=o(div);
	function stateChanged(){
		if(xml.readyState==4){
			div.innerHTML=xml.responseText;
		}
	}
	xml=GetXmlHttpObject();
	if(xml==null){
		alert("Il tuo browser non supporta AJAX");
		return;
	}
	url="./oracle.php?&i="+Math.random()+"&"+str;
	xml.onreadystatechange=stateChanged;
	xml.open("GET",url,true);
	xml.send(null);
}

function fade(id){
	if(  typeof( window.innerWidth ) == 'number' ) {
		i=o(id).style.opacity;
		i=parseFloat(i)+(1/10);
		o(id).style.opacity=i;
		if(parseFloat(i)<1){
			startFade(id);
		}else{
			//changeImg(id);
			setTimeout("if(o('wboard').title!='c3ll'){resp('','wboard');}",5000);
			//clearTimeout(t);
		}
	}else{
		i=o(id).filters[0].opacity;
		i=parseFloat(i)+(10);
		o(id).style.filter= "alpha(opacity=" + i + ")";;
		if(parseFloat(i)<100){
			startFade(id);
		}else{
			setTimeout("if(o('wboard').title!='c3ll'){resp('','wboard');}",5000);
			//clearTimeout(t);
		}
	}
}

function startFade(id){
	if(o('wboard').title!="c3ll"){
		if( typeof( window.innerWidth ) == 'number') {
			op=o(id).style.opacity;
			if(parseFloat(op)<1){
				t=setTimeout("fade('"+id+"');",100);
			}
		}else{
			op=o(id).filters[0].opacity;
			if(parseFloat(op)<100){
				t=setTimeout("fade('"+id+"');",100);
			}
		}
	}
}

function changeImg(id){
	if( typeof( window.innerWidth ) == 'number') {
		o(id).style.opacity=0;
	}else{
		o(id).style.filter= "alpha(opacity=0)";
	}
	startFade(id);
}
function gallery(img1,img2,parent){
	//recupero la posizione e imposto i metodi per i nuovi oggetti
			var Y=0;
			var X=0;
			var obj=document.getElementById("foto");
			while (obj=obj.offsetParent){
				Y+=obj.offsetTop;
				X+=obj.offsetLeft;
			}
			Y=Y+133;
			X1=X+10;
			X2=X+200;
			X1+="px";
			X2+="px";
			Y+="px";

			var position="absolute";
			var visibility="visible";
			var zIndex="20";
			var cursor="pointer";

	//imposto le due immagini
	var id1="th1";
	if(o(id1)){
		var th1=o(id1);
	}else{
		var th1=document.createElement('img');
		var newDiv1=true;
	}
	th1.setAttribute('id',id1);
	th1.setAttribute("onclick","o('foto').src='/iphp/bigImg.php?w=400&h=267&src="+img1+"'");
	if(typeof (window.external.AddService)=="undefined"&&typeof( window.innerWidth ) == 'number'){
		th1.style.opacity='0.1';
		th1.setAttribute('onmouseover','this.style.opacity=1');
		th1.setAttribute('onmouseout',"this.style.opacity=0.1");
	}else{
		//th1.style.filter='alpha(opacity=10)';
		th1.style.filter='progid:DXImageTransform.Microsoft.Alpha(Opacity=10)';
		th1.setAttribute('onmouseover',"this.style.filters.alpha(opacity=100)'");
		th1.setAttribute('onmouseout',"this.filters.alpha.opacity=10");
	}
	//alert(th1.getAttribute('onmouseover'));
	if(newDiv1){
		o(parent).appendChild(th1);
	}
	th1.style.position=position;
	th1.style.top=Y;
	th1.style.left=X1;
	th1.style.visibility=visibility;
	th1.style.zIndex=zIndex;
	th1.style.cursor=cursor;
	th1.setAttribute('width',"180px");
	th1.style.width='180px';
	th1.src='/iphp/bigImg.php?w=180&h=133&src='+img1;
	var id2="th2";
	if(o(id2)){
		var th2=o(id2);
	}else{
		var th2=document.createElement('img');
		var newDiv2=true;
	}
	th2.setAttribute('id',id2);
	th2.setAttribute("onclick","o('foto').src='/iphp/bigImg.php?w=400&h=267&src="+img2+"'");
	if(typeof (window.external.AddService)=="undefined"&&typeof( window.innerWidth ) == 'number'){
		th2.style.opacity='0.1';
		th2.setAttribute('onmouseover','this.style.opacity=1');
		th2.setAttribute('onmouseout',"this.style.opacity=0.1");
	}else{
		th2.style.filter='alpha(opacity=10)';
		th2.setAttribute('onmouseover','visible(th1)');
		th2.setAttribute('onmouseout',"this.style.filters.alpha.opacity=10");
	}
	if(newDiv2){
		o(parent).appendChild(th2);
	}
	th2.style.position=position;
	th2.style.top=Y;
	th2.style.left=X2;
	th2.style.visibility=visibility;
	th2.style.zIndex=zIndex;
	th2.style.cursor=cursor;
	th2.src='/iphp/bigImg.php?w=180&h=133&src='+img2;
}

function visible(id){
	o(id).style.filter= "alpha(opacity=100)";
}

function fastSearch(str,parent){
	var id="fastSearch";
	if(o(id)){
		var waitIcon=o(id);
	}else{
		var waitIcon=document.createElement('div');
		var newDiv=true;
	}
	waitIcon.setAttribute('id',id);
	if(newDiv){
		o(parent).appendChild(waitIcon);
	}
	function stateChanged(){
		if(xml.readyState==4){
			var Y=0;
			var X=0;
			var obj=document.getElementById("sKey");
			while (obj=obj.offsetParent){
				Y+=obj.offsetTop;
				X+=obj.offsetLeft;
			}
			Y=Y+21;
			Y+='px';
			X+='px';
			//dest.style.display='inline';
			waitIcon.style.position='absolute';
			waitIcon.style.left=X;
			waitIcon.style.top=Y;
			waitIcon.style.visibility='visible';
			waitIcon.style.zIndex='20';
			waitIcon.style.backgroundColor='white';
			waitIcon.style.width="200px";
			waitIcon.style.height="100px";
			waitIcon.style.border="1px solid #A0A0A0";
			waitIcon.style.overflow='auto';
			waitIcon.style.cursor='default';
			waitIcon.innerHTML=xml.responseText;
		}
	}
	xml=GetXmlHttpObject();
	if(xml==null){
		alert("Il tuo browser non supporta AJAX");
		return;
	}
	url="./inquire.php?&i="+Math.random()+"&str="+str;
	xml.onreadystatechange=stateChanged;
	xml.open("GET",url,true);
	xml.send(null);
}


function clForm(){
	inp=document.getElementsByTagName("input");
	l=inp.length;
	i=0;

	while(i<l){
		//el.value="";
		if(inp.item(i).getAttribute('id')!="ck"){
			inp.item(i).value="";
		}
		i+=1;
	}
	return true;
}

function check(obj){
	/*div=o(obj);
			div.style.backgroundColor='red';
	//alert(div.innerHTML);
	function stateChanged(){
		if(xml.readyState==4){
			div.innerHTML=xml.responseText;
		}
	}
	xml=GetXmlHttpObject();
	if(xml==null){
		alert("Il tuo browser non supporta AJAX");
		return;
	}*/
	e=o('email').value;
	p=o('pswd').value;
	c=o('ck').value.toLowerCase();
	op=o('co')?"&cartOperations="+o('co').value:"";
	qs="a=cart&step=checkLogin&e="+e+"&p="+p+"&c="+c+op;
	if(o('cartOperation')){
		qs+="&cart=1";
	}
	response(qs,obj);
	/*url="./oracle.php?a=cart&step=checkLogin&i="+Math.random()+qs;
	xml.onreadystatechange=stateChanged;
	xml.open("GET",url,true);
	xml.send(null);*/
}

function clessidra(){
	var id="clessidra";
	if(o(id)){
		var waitIcon=o(id);
	}else{
		var waitIcon=document.createElement('div');
		var newDiv=true;
	}
	waitIcon.setAttribute('id',id);
	waitIcon.style.backgroundColor='black';
	waitIcon.style.width=maxW(-10);
	waitIcon.style.height=maxH(-10);
	waitIcon.style.overflow='hidden';
	waitIcon.style.cursor='wait';
	waitIcon.style.position='absolute';
	waitIcon.style.top='0px';
	waitIcon.style.left='0px';
	waitIcon.style.visibility='visible';
	if( typeof( window.innerWidth ) == 'number' ) {
		waitIcon.style.opacity="0.2";
	}else{
		waitIcon.style.filter="alpha(opacity=20)";
	}
	if(newDiv){
		document.body.appendChild(waitIcon);
	}
}

function getByName(objName,tagName,parent){
	var dad=document.getElementById(parent);
	var collection=dad.getElementsByTagName(tagName);
	for(i=0;i<collection.length;i++){
		if(collection.item(i).getAttribute("name")==objName){
			id=collection.item(i).getAttribute("id");
			return o(id);
		}
	}
	return false;
}