function NavChange(id) {
	var n = getElementsByName_iefix('li', 'nav_title').length;

	for (i='1'; i<=n; i++) {
		var nav_x = 'nav_main' + i;
		document.getElementById(nav_x).style.display = 'none';
	}

	for (i='1'; i<=n; i++) {
		document.getElementById('nav_a' + i).style.backgroundPosition = 'left top';
		document.getElementById('nav_ar' + i).style.backgroundPosition = 'right top';
		document.getElementById('nav_ar' + i).style.color = '#000';
	}

	document.getElementById('nav_main' + id).style.display = 'block';
	document.getElementById('nav_a' + id).style.backgroundPosition = '0% -42px';
	document.getElementById('nav_ar' + id).style.backgroundPosition = '100% -42px';
	document.getElementById('nav_ar' + id).style.color = '#fff';
}
function getElementsByName_iefix(tag, name) {
	var elem = document.getElementsByTagName(tag);
	var arr = new Array();
	
	for(i = 0,iarr = 0; i < elem.length; i++) {
		att = elem[i].getAttribute("name");
		
		if(att == name) {
			arr[iarr] = elem[i];
			iarr++;
		}
	}
	return arr;
}

function AHoverOver(i) {
	document.getElementById('nav_a' + i).style.backgroundPosition = '0% -42px';
	document.getElementById('nav_ar' + i).style.backgroundPosition = '100% -42px';
	document.getElementById('nav_ar' + i).style.color = '#fff';
}
function AHoverOut(i) {
	if (document.getElementById('nav_main' + i).style.display != 'block') {
			document.getElementById('nav_a' + i).style.backgroundPosition = 'left top';
			document.getElementById('nav_ar' + i).style.backgroundPosition = 'right top';
			document.getElementById('nav_ar' + i).style.color = '#000';
	}
}

function init() {
	//Ä¬ÈÏµ¼º½Ò³Ãæ
	var n = '2';
	document.getElementById('nav_main' + n).style.display = 'block';
	document.getElementById('nav_a' + n).style.backgroundPosition = '0% -42px';
	document.getElementById('nav_ar' + n).style.backgroundPosition = '100% -42px';
	document.getElementById('nav_ar' + n).style.color = '#fff';
}

function OpenUrl(form) {
	url = form.page.options[form.page.options.selectedIndex].value;
	top.location.href=url;
}
function OpenUrl1(form) {
	url = form.company1.options[form.company1.options.selectedIndex].value;
	top.location.href=url;
}

function ShowInfo(id) {
	window.open('/info.php?id=' + id, '', 'width=640, height=480, top=100, left=100, scrollbars=yes');
}

function getOption(src, to) {
	var srcID = src.options[src.selectedIndex].value;
	if (srcID == 0 && to == 'brand') {
		document.getElementById(to).options.length = 1;
		document.getElementById('series').options.length = 1;
		return;
	} else if (srcID == 0 && to == 'series') {
		document.getElementById(to).options.length = 1;
		return;
	} else if (srcID == 0 && to == 'company') {
		document.getElementById(to).options.length = 1;
		return;
	}
	if (to == 'brand') {
		var url = 'product.php?action=getoption&method=' + to + '&id=' + srcID;
	} else if (to == 'series') {
		cid = document.getElementById('category').value;
		var url = 'product.php?action=getoption&method=' + to + '&cid=' + cid + '&id=' + srcID;
	} else if (to == 'company') {
		var url = 'debt.php?action=getoption&method=' + to + '&id=' + srcID;
	}
	var xmlHttp = createXmlHttp();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4) {
			eval(xmlHttp.responseText);
			if (arr != null) {
				document.getElementById(to).options.length = 1;
				for (var i=0;i<arr.length;i++) {
					var option = document.createElement("option");
					option.value = arr[i][0];
					option.text = arr[i][1];
					document.getElementById(to).options.add(option);
				}
			} else {
				document.getElementById(to).options.length = 1;
			}
		}
	}
	xmlHttp.send(null);
}

function getOption1(src, to) {
	var srcID = src.options[src.selectedIndex].value;
	if (srcID == 0 && to == 'company1') {
		document.getElementById(to).options.length = 1;
		return;
	}
	if (to == 'company1') {
		var url = 'debt.php?action=getoption1&id=' + srcID;
	}
	var xmlHttp = createXmlHttp();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4) {
			eval(xmlHttp.responseText);
			if (arr != null) {
				document.getElementById(to).options.length = 1;
				for (var i=0;i<arr.length;i++) {
					var option = document.createElement("option");
					option.value = arr[i][0];
					option.text = arr[i][1];
					document.getElementById(to).options.add(option);
				}
			} else {
				document.getElementById(to).options.length = 1;
			}
		}
	}
	xmlHttp.send(null);
}

function createXmlHttp() {
	var xmlHttp = false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	try {
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e2) {
			xmlHttp = false;
		}
	}
	@end @*/
	if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
	  xmlHttp = new XMLHttpRequest();
	}
	return xmlHttp
}
