function editArticle(){

}

function toggleLayer(whichLayer){
	if (document.getElementById){
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}else if (document.all){
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}else if (document.layers){
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

function state_Change(id){
	if (xmlhttp.readyState==4){
		if (xmlhttp.status==200){
			f=document.getElementById('ratingForm_'+id);
			f.innerHTML=xmlhttp.responseText;
		}else{
			alert("Problem retrieving XML data")
		}
	}
}

function loadRatingForm(id){
	toggleLayer('ratingForm_'+id);
	f=document.getElementById('ratingForm_'+id);
	f.innerHTML="Loading...";
	xmlhttp=null
	// code for Mozilla, etc.
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest()
	}
	// code for IE
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	if(xmlhttp!=null){
		xmlhttp.onreadystatechange= function () {
			if (xmlhttp.readyState == 4) {
				state_Change(id);
			}
		};


		d = new Date( );
		xmlhttp.open("GET",'include/Article/rating.php?id='+id+'&t='+d.getUTCMilliseconds(),true)
		xmlhttp.send(null)
	}else{ 
		f.innerHtml="Your browser does not support XMLHTTP.";
	}
}

function rating_select(index){
	for(i=1;i<=index;i++){
		p=document.getElementById("rating_"+i);
		p.style.backgroundColor="#EBAF2D";
	}
	for(i=(index+1);i<=10;i++){
		p=document.getElementById("rating_"+i);
		p.style.backgroundColor="#C0C0C0";
	}
}

function rating_save(id_item,rating){
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest()
	}
	// code for IE
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	if(xmlhttp!=null){
		xmlhttp.onreadystatechange=function () {
			if (xmlhttp.readyState == 4) {
				state_Change2(id_item);
			}
		};

		d = new Date( );
		xmlhttp.open("GET",'include/Article/rate.php?id_item='+id_item+'&rating='+rating+'&t='+d.getUTCMilliseconds(),true)
		xmlhttp.send(null)
	}else{ 
		f.innerHtml="Your browser does not support XMLHTTP.";
	}
}

function state_Change2(id){
	if (xmlhttp.readyState==4){
		if (xmlhttp.status==200){
			toggleLayer('ratingForm_'+id);
		}else{
			alert("Problem retrieving XML data")
		}
	}
}

function state_ChangeReact(id){
	if (xmlhttp.readyState==4){
		if (xmlhttp.status==200){
			f=document.getElementById('ratingForm_'+id);
			f.innerHTML=xmlhttp.responseText;
		}else{
			alert("Problem retrieving XML data")
		}
	}
}

function loadReactionForm(id){
	toggleLayer('ratingForm_'+id);
	f=document.getElementById('ratingForm_'+id);
	f.innerHTML="Loading...";
	xmlhttp=null
	// code for Mozilla, etc.
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest()
	}
	// code for IE
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	if(xmlhttp!=null){
		xmlhttp.onreadystatechange=function () {
			if (xmlhttp.readyState == 4) {
				state_ChangeReact(id);
			}
		};

		xmlhttp.open("GET",'include/Article/react.php?id='+id,true)
		xmlhttp.send(null)
	}else{ 
		f.innerHtml="Your browser does not support XMLHTTP.";
	}
}

function loadForwardForm(id){
	toggleLayer('ratingForm_'+id);
	f=document.getElementById('ratingForm_'+id);
	f.innerHTML="Loading...";
	xmlhttp=null
	// code for Mozilla, etc.
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest()
	}
	// code for IE
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	if(xmlhttp!=null){
		xmlhttp.onreadystatechange=function () {
			if (xmlhttp.readyState == 4) {
				state_ChangeForward(id);
			}
		};
			
		xmlhttp.open("GET",'include/Article/forward.php?id='+id,true)
		xmlhttp.send(null)
	}else{ 
		f.innerHtml="Your browser does not support XMLHTTP.";
	}
}

function state_ChangeForward(id){
	if (xmlhttp.readyState==4){
		if (xmlhttp.status==200){
			f=document.getElementById('ratingForm_'+id);
			f.innerHTML=xmlhttp.responseText;
		}else{
			alert("Problem retrieving XML data")
		}
	}
}

function printItem(id){
	openWindow('/include/print.php?id='+id,750,800,0,0,0,0,1,1,200,200);
}

function openWindow(url,w,h,tb,stb,l,mb,sb,rs,x,y){
	var t=(document.layers)? ',screenX='+x+',screenY='+y: ',left='+x+',top='+y; //A LITTLE CROSS-BROWSER CODE FOR WINDOW POSITIONING
	tb=(tb)?'yes':'no'; stb=(stb)?'yes':'no'; l=(l)?'yes':'no'; mb=(mb)?'yes':'no'; sb=(sb)?'yes':'no'; rs=(rs)?'yes':'no';
	var x=window.open(url, 'newWin', 'scrollbars='+sb+',width='+w+',height='+h+',toolbar='+tb+',status='+stb+',menubar='+mb+',links='+l+',resizable='+rs+t);
	x.focus();
}

function reaction(id){
	var url = "include/Article/reaction.php";
	var f=document.forms['reactionform_'+id];
	var params = "id="+escape(id)+"&name="+escape(f.name.value)+"&email="+escape(f.email.value)+"&reaction="+escape(f.reaction.value);
	
	xmlhttp=null
	// code for Mozilla, etc.
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest()
	}
	// code for IE
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	}

	xmlhttp.open("POST", url, true);

	//Send the proper header information along with the request
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");

	xmlhttp.onreadystatechange = function() {//Call a function when the state changes.
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			toggleLayer('ratingForm_'+id);			
		}
	}
	xmlhttp.send(params);
}