
	var mydiv;
	var http;
	var a;
	
	function get_rank(form_name){
		var b_found=false;
		var rank;
		
		for(i=0;i<document.forms[form_name].my_vote.length;i++){
			if(document.forms[form_name].my_vote[i].checked==true){
				b_found=true;
				rank = i + 1;
			}
		}
		if(b_found){
			return rank;
		}
		else{
			return -1;
		}
	}
	
	function createRequestObject(){
		var request_o; //declare the variable to hold the object.
		var browser = navigator.appName; //find the browser name
		if(browser == "Microsoft Internet Explorer"){
			/* Create the object using MSIE's method */
			request_o = new ActiveXObject("Microsoft.XMLHTTP");
		}else{
			/* Create the object using other browser's method */
			request_o = new XMLHttpRequest();
		}
		return request_o; //return the object
	}
	
	function record_ranking(id, div, form){
		mydiv = div;
		my_rank = get_rank(form);
		my_id = id;
		
		if(my_rank == -1){
			alert("You must first select a value for the ranking.");
		}
		else {
			document.getElementById(mydiv).innerHTML = "<img src='http://100k.blackorc.com/images/updating.gif' />";
			http = createRequestObject(); 
		
			/* Create the request. The first argument to the open function is the method (POST/GET),
			and the second argument is the url... 
			document contains references to all items on the page
			We can reference document.form_category_select.select_category_select and we will
			be referencing the dropdown list. The selectedIndex property will give us the 
			index of the selected item. 
			*/
			http.open('get', 'art_contest_ranking_process.php?id=' + id + '&rank=' + my_rank);
			/* Define a function to call once a response has been received. This will be our
				handleProductCategories function that we define below. */
			http.onreadystatechange = handle_ranking; 
			/* Send the data. We use something other than null when we are sending using the POST
				method. */
			http.send(null);
		}
	}
	
	function update_rating(div){
		mydiv = div;
		document.getElementById(mydiv).innerHTML = "<img src='http://100k.blackorc.com/images/updating.gif' />";
		x = new String(div);
		a = x.split("_");
		http = createRequestObject(); 
		http.open('get', 'art_contest_ranking_update.php?id=' + a[a.length - 1]);
		http.onreadystatechange = handle_ranking; 
		http.send(null);		
	}
	
	function handle_ranking(){
		/* Make sure that the transaction has finished. The XMLHttpRequest object 
			has a property called readyState with several states:
			0: Uninitialized
			1: Loading
			2: Loaded
			3: Interactive
			4: Finished */
		if(http.readyState == 4){ //Finished loading the response
			/* We have got the response from the server-side script,
				let's see just what it was. using the responseText property of 
				the XMLHttpRequest object. */
			var response = http.responseText;
			/* And now we want to change the product_categories <div> content.
				we do this using an ability to get/change the content of a page element 
				that we can find: innerHTML. */
			document.getElementById(mydiv).innerHTML = response;
			if (mydiv.substr(0,5) == 'rank_'){
				update_rating('rate_' + my_id);
			}
		}
	}	
	
	function record_link(url){
		http = createRequestObject(); 
		http.open('get','link_counter.php?u=' + url);
		http.onreadystatechange = handle_link;
		http.send(null);
	}

	function handle_link(){
		if(http.readyState == 4){
		}
	}
	
	