// get our element
var LB = {
	AJAX: Object
};

LB.AJAX = function(){
	
	var map = new Array();
	this.params = "";
	
	this.getAjaxObject = function(){
		try{return new XMLHttpRequest();}catch(ex){};
        try{return new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){};
        try{return new SOAPCall();}catch(ex){};
	}
	
	this.onError = function(error){
		alert(error);
	}
	
	this.getPage = function(url, callBack){
		try{
			var a_ob = this.getAjaxObject();
			a_ob.onreadystatechange = function(){
				if(a_ob.readyState == 4 || a_ob.readyState == "complete"){
					callBack(a_ob.responseText);
				}
			};
			
			a_ob.open("POST", url, true);
			a_ob.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	        a_ob.setRequestHeader("Content-length", this.params.length);
			a_ob.send(this.params);
			
		}catch(ex){
			this.onError(ex);
		}
	}
	
	this.addParam = function(key, value){
		if(this.params == ""){
			this.params = key+"="+value;
		}else{
			this.params += "&"+key+"="+value;
		}
	}
	
}

if(typeof LB_CONTESTANT == "undefined"){
	alert("Your lifeBLUE Web Design Contest Code is not installed properly, please re-copy the code and try again.");
}else{
	displayRank();	
}

function displayRank(){
	var lb_element = document.getElementById('lb_vote');
	
   	if(lb_element){

   		lb_element.innerHTML = "<a href=\"http://www.lifeblue.com/web_design_contest/voteNow.html?id="+LB_CONTESTANT+"\"><img src=\"http://www.lifeblue.com/web_design_contest/contestant/"+LB_CONTESTANT+".jpg\" alt=\"Web Design Contest Vote\" border=\"0\" /></a>";
   		
   		//var LB_SaveRequest = new LB.AJAX();
   		//LB_SaveRequest.addParam('contestid', LB_CONTESTANT);
		//LB_SaveRequest.getPage('http://www.lifeblue.com/web_design_contest/getRating.php', function(response) {
		//	lb_element.innerHTML = response;
		//});	
	}else{
		alert("Your lifeBLUE Web Design Contest Code is not installed properly, please re-copy the code and try again.");	
	}	
}

function placeVote(id){
	
	window.location.href = 'http://www.lifeblue.com/web_design_contest/voteNow.html?id='+id+'';
	
// no AJAX, we are redirecting to our site to verify
//	var lb_element = document.getElementById('lb_vote');
//	lb_element.innerHTML = '<div style="width:85px; height:100px; background-image:url(http://www.lifeblue.com/images/lb_contest_graphic.gif); background-repeat:no-repeat;"><div style="padding-top:25px; font-size:12px; font-family:tahoma;"><strong>Voting...</strong></div></div>';
//	
//	var LB_VoteRequest = new LB.AJAX();
//	LB_VoteRequest.addParam('id', id);
//	LB_VoteRequest.getPage('http://www.lifeblue.com/web_design_contest/voteNow.html', function(response) {
//		displayRank();
//	});	
	
}



