﻿// JScript File
// Utility JS for Search Used Cars

var cX = 0; var cY = 0; var rX = 0; var rY = 0;
function UpdateCursorPosition(e) { cX = e.pageX; cY = e.pageY; }

function UpdateCursorPositionDocAll(e) { cX = event.clientX; cY = event.clientY;}

if(document.all) { 
	document.onmousemove = UpdateCursorPositionDocAll; 
}
else { 
	document.onmousemove = UpdateCursorPosition; 
}

function AssignPosition(d) {
	if(self.pageYOffset) {
		rX = self.pageXOffset;
		rY = self.pageYOffset;
	}
	else if(document.documentElement && document.documentElement.scrollTop) {
		rX = document.documentElement.scrollLeft;
		rY = document.documentElement.scrollTop;
	}
	else if(document.body) {
		rX = document.body.scrollLeft;
		rY = document.body.scrollTop;
	}
	if(document.all) {
		cX += rX; 
		cY += rY;
	}
	d.style.left = (cX+10) + "px";
	d.style.top = (cY+10) + "px";
}

function HideContent(d) {
	//d.style.display = "none";
	return false;	
}

function ShowContent(d) {
	AssignPosition(d);
	d.style.display = "block";
	return false;
}

function ReverseContentDisplay(d) {
	AssignPosition(d);
	if(d.style.display == "none") { d.style.display = "block"; }
	else { d.style.display = "none"; }
	return false;
}

function clearDropdown(targetSelect) {
	for (var count = targetSelect.options.length-1; count > -1; count--) {
		targetSelect.options[count] = null;
	}   
}

function addOption2Dropdown(targetSelect, optionTitle, optionValue) {
		var option = document.createElement("option");
		option.value = optionValue;
		option.appendChild(document.createTextNode(optionTitle));
		targetSelect.appendChild(option);
		return option;
}

function clearListBox(targetSelect) {
	for (var count = targetSelect.options.length-1; count > -1; count--) {
		targetSelect.options[count] = null;
	}   
}

function addOption2ListBox(targetSelect, optionTitle, optionValue) {
		var option = document.createElement("option");
		option.value = optionValue;
		option.appendChild(document.createTextNode(optionTitle));
		targetSelect.appendChild(option);
		return option;
}



function addOption3Dropdown(targetSelect, optionTitle, optionValue) {
		var option = document.createElement("option");
		option.value = optionValue;
		option.appendChild(document.createTextNode(optionTitle));
		targetSelect.appendChild(option);
		return option;
}


//Commented by PADMA
//function clearDropdown(targetSelect) {
//	for (var count = targetSelect.options.length-1; count > -1; count--) {
//	//targetSelect.options[count] = null;
//	}   
//}

//function addOption2Dropdown(targetSelect, optionTitle, optionValue) {
//		var option = document.createElement("option");
//		option.value = optionValue;
//		option.appendChild(document.createTextNode(optionTitle));
//		targetSelect.appendChild(option);
//		return option;
//}