var obj;
var tmpElementId;
function ajax(ajaxUrl, elementId){
	//alert(ajaxUrl);
	tmpElementId = elementId;
	if (window.XMLHttpRequest) {
		// Not IE
		obj = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try{
			obj = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e){
			try{
				obj = new ActiveXObject("Microsoft.XMLHTTP");						
			}
			catch(e1){
				obj = null;
			}
		}
	}
	
	if(obj!=null){
		//need to keep IE from caching the CT
		obj.onreadystatechange = onResponse;
		obj.open("GET", ajaxUrl,  true);
		//alert(ajaxUrl);
		
		obj.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');		
		obj.send(null);
	}
}

function onResponse(){
	var elementId = tmpElementId;
	if(obj.readyState == 4){
		if(obj.status == 200){
			//alert('success');	
			var retval=obj.responseText;
			//alert(retval);
			document.getElementById(elementId).innerHTML = retval;
		}
		else{
			//alert(obj.status);
			//alert(obj.responseText);
		}
	//}else if(obj.readyState == 0){
	//	document.getElementById(elementId).innerHTML = 'Requesting...';
	//}else if(obj.readyState == 1){
	//	document.getElementById(elementId).innerHTML = 'Loading...';
	//}else if(obj.readyState == 2){
	//	document.getElementById(elementId).innerHTML = 'Loaded...';
	//}else if(obj.readyState == 3){
	//	document.getElementById(elementId).innerHTML = 'Ready...';
	}else{
		//document.getElementById(elementId).innerHTML = '<span style="text-align: center;">loading...</span>';
	}
}

var obj2;
var tmpElementId2;
function ajax2(ajaxUrl, elementId){
	tmpElementId2 = elementId;
	if (window.XMLHttpRequest) {
		// Not IE
		obj2 = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try{
			obj2 = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e){
			try{
				obj2 = new ActiveXObject("Microsoft.XMLHTTP");						
			}
			catch(e1){
				obj2 = null;
			}
		}
	}
	
	if(obj2!=null){
		//need to keep IE from caching the CT
		obj2.onreadystatechange = onResponse2;
		obj2.open("GET", ajaxUrl,  true);
		//alert(ajaxUrl);
		
		obj2.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');		
		obj2.send(null);
	}
	//return true;
}

function onResponse2(){
	var elementId = tmpElementId2;
	if(obj2.readyState == 4){
		if(obj2.status == 200){
			//alert('success');	
			var retval=obj2.responseText;
			//alert(retval);
			document.getElementById(elementId).innerHTML = retval;
		}
		else{
			//alert(obj2.status);
			//alert(obj2.responseText);
		}
	}else if(obj2.readyState == 0){
		//document.getElementById(elementId).innerHTML = 'Requesting...';
	}else if(obj2.readyState == 1){
		//document.getElementById(elementId).innerHTML = 'Loading...';
	}else if(obj2.readyState == 2){
		//document.getElementById(elementId).innerHTML = 'Loaded...';
	}else if(obj2.readyState == 3){
		//document.getElementById(elementId).innerHTML = 'Ready...';
	}else{
		//alert(obj2.readyState);
	}
}


// -- Form hack for enter button, ugly, but needed.
	function clickButton(e, buttonid){ 
		var bt = document.getElementById(buttonid); 
		if (typeof bt == 'object'){ 
			if(navigator.appName.indexOf("Netscape")>(-1)){ 
				  if (e.keyCode == 13){ 
						bt.click(); 
						return false; 
				  } 
			} 
			if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
				  if (event.keyCode == 13){ 
						bt.click(); 
						return false; 
				  } 
			} 
		} 
	}

//CSS Menu IE Fix
sfHover = function() {
	var sfEls = document.getElementById("rollovermenu").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


function dealerTab(id, mousePosition){
	if (mousePosition == 1){
		id.style.backgroundColor = '#323c53';
		id.style.color = '#EEEEEE';
	}else{
		id.style.backgroundColor = id.style.backgroundColor;
		id.style.color = id.style.color;
	}
}

function dealerTabClick(id){
	document.getElementById('tabAll').style.backgroundColor = '#EEEEEE';
	document.getElementById('tabAll').style.color = '#323c53';
	
	document.getElementById('tabNeg').style.backgroundColor = '#EEEEEE';
	document.getElementById('tabNeg').style.color = '#323c53';
	
	document.getElementById('tabPos').style.backgroundColor = '#EEEEEE';
	document.getElementById('tabPos').style.color = '#323c53';
	
	document.getElementById('tabSales').style.backgroundColor = '#EEEEEE';
	document.getElementById('tabSales').style.color = '#323c53';
	
	document.getElementById('tabService').style.backgroundColor = '#EEEEEE';
	document.getElementById('tabService').style.color = '#323c53';
	
	//document.getElementById('tabVer').style.backgroundColor = '#EEEEEE';
	//document.getElementById('tabVer').style.color = '#323c53';
	
	document.getElementById(id.id).style.backgroundColor = '#323c53';
	document.getElementById(id.id).style.color = '#EEEEEE';
	
}

function showRatings(elementId, question1, question2, question3, question4, question5){
	var questions;
	if (question1 > 0){
		questions = 'Customer Service: <img src="/images/rating-' + question1 + '.gif" alt="1 Star" />';
	}else{
		questions = 'Customer Service: N/A<img src="/images/spacer.gif" alt="N/A" style="width: 71px; height: 16px;" />'
	}
	if (question2 > 0){
		questions += '<br />Quality of Work: <img src="/images/rating-' + question2 + '.gif" alt="2 Star" />';
	}else{
		questions += '<br />Quality of Work: N/A<img src="/images/spacer.gif" alt="N/A" style="width: 71px; height: 16px;" />'
	}
	if (question3 > 0){
		questions += '<br />Friendliness: <img src="/images/rating-' + question3 + '.gif" alt="3 Star" />';
	}else{
		questions += '<br />Friendliness: N/A<img src="/images/spacer.gif" alt="N/A" style="width: 71px; height: 16px;" />'
	}
	if (question4 > 0){
		questions += '<br />Overall Experience: <img src="/images/rating-' + question4 + '.gif" alt="4 Star" />';
	}else{
		questions += '<br />Overall Experience: N/A<img src="/images/spacer.gif" alt="N/A" style="width: 71px; height: 16px;" />'
	}
	if (question5 > 0){
		questions += '<br />Price: <img src="/images/rating-' + question5 + '.gif" alt="5 Star" />';
	}else{
		questions += '<br />Price: N/A<img src="/images/spacer.gif" alt="N/A" style="width: 71px; height: 16px;" />'
	}
	if (questions.length > 0) {
		document.getElementById(elementId).innerHTML =  questions;
	}
}

function showOverallRatings(elementId, question1, q1Round, question2, q2Round, question3, q3Round, question4, q4Round, question5, q5Round){
	var questions;
	if (q1Round.length > 0){
		questions = 'Customer Service: <img src="/images/ratings/rating-' + q1Round + '.png" alt="1 Star" /> ' + question1;
	}
	if (q2Round.length > 0){
		questions += '<br />Quality of Work: <img src="/images/ratings/rating-' + q2Round + '.png" alt="2 Star" /> ' + question2;
	}
	if (q3Round.length > 0){
		questions += '<br />Friendliness: <img src="/images/ratings/rating-' + q3Round + '.png" alt="3 Star" /> ' + question3;
	}
	if (q4Round.length > 0){
		questions += '<br />Overall Experience: <img src="/images/ratings/rating-' + q4Round + '.png" alt="4 Star" /> ' + question4;
	}
	if (q5Round.length > 0){
		questions += '<br />Price: <img src="/images/ratings/rating-' + q5Round + '.png" alt="5 Star" /> ' + question5;
	}
	
	document.getElementById(elementId).innerHTML =  questions;
}

function openWindow(url, id){
	window.open(url, id, 'toolbar=no,scrollbars=yes,location=no,width=575,height=420,resizable=yes');
	return false;
}

function commentReply(sortOrder, commentId){
	document.forms.aspnetForm.ctl00$middleContent$sortOrder.value=sortOrder;
	document.forms.aspnetForm.ctl00$middleContent$parentId.value=commentId;
	document.forms.aspnetForm.ctl00$middleContent$userComments.focus();
}

var obj2;
function checkLogin(checkLoginUrl){
	if (window.XMLHttpRequest) {
		// Not IE
		obj2 = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try{
			obj2 = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e){
			try{
				obj2 = new ActiveXObject("Microsoft.XMLHTTP");						
			}
			catch(e1){
				obj2 = null;
			}
		}
	}
	
	if(obj2!=null){
		//need to keep IE from caching the CT
		obj2.onreadystatechange = onLoginResponse;
		obj2.open("GET", checkLoginUrl,  true);
		//alert(ajaxUrl);
		
		obj2.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');		
		obj2.send(null);
	}
}

function onLoginResponse(){
	if(obj2.readyState == 4){
		if(obj2.status == 200){
			//alert('success');	
			var retval=obj2.responseText;
			//alert(retval == 'true');
			if (retval == 'true'){
				document.getElementById('ctl00_middleContent_btnCommentSubmit').disabled = false;
				document.getElementById('loginLinkText').style.display='none';
			}else{
				document.getElementById('ctl00_middleContent_btnCommentSubmit').disabled= true;
				document.getElementById('loginLinkText').style.display='inline';
			}
		}
		else{
			//alert(obj2.status);
			//alert(obj.responseText);
		}
	//}else if(obj.readyState == 0){
	//	document.getElementById(elementId).innerHTML = 'Requesting...';
	//}else if(obj.readyState == 1){
	//	document.getElementById(elementId).innerHTML = 'Loading...';
	//}else if(obj.readyState == 2){
	//	document.getElementById(elementId).innerHTML = 'Loaded...';
	//}else if(obj.readyState == 3){
	//	document.getElementById(elementId).innerHTML = 'Ready...';
	}else{
	//	document.getElementById(elementId).innerHTML = '<div style="text-align: center;">loading...</div>';
	}
}

function blockChars(objEvent){
	var iKeyCode, strKey;

	if (isIE) {
	iKeyCode = objEvent.keyCode;
	} else {
	iKeyCode = objEvent.which; 
	}
	//strKey = String.fromCharCode(iKeyCode);
	if (iKeyCode == 13){
		return false; 
	}else{
		//my_autocomplete_event_handler();
	}

}