function changeTab(intID, intTotal) {
	var intID, intTotal, elem;
	for (var i=1, j=intTotal+1; i<j; i++) {
		if (i==intID) {
			elem = document.getElementById('pdnl_' + i);
			elem.className = 'product_detail_nav_on';
			elem.blur();
			elem = document.getElementById('pdnc_' + i);
			elem.className = 'product_detail_nav_content_on';
		}
		else {
			elem = document.getElementById('pdnl_' + i);
			elem.className = 'product_detail_nav_off';
			elem = document.getElementById('pdnc_' + i);
			elem.className = 'product_detail_nav_content_off';
		}
	}
	return null;
}

function highlight(intID) {
	var intID, elem;
	elem = document.getElementById('ol_' + intID);
	elem.className = 'product_detail_option_on';
	elem = document.getElementById('oi_' + intID);
	elem.className = 'product_detail_option_img_on';
	return null;
}

function unhighlight(intID) {
	var intID, elem;
	elem = document.getElementById('ol_' + intID);
	elem.className = 'product_detail_option_off';
	elem = document.getElementById('oi_' + intID);
	elem.className = 'product_detail_option_img_off';
	return null;
}

function sendScrollXY(intID) {
    var intID, elem, strHref, pattern, x = 0, y = 0;
    if( typeof( window.pageYOffset ) == 'number' ) {
        // Netscape
        x = window.pageXOffset;
        y = window.pageYOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        // DOM
        x = document.body.scrollLeft;
        y = document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        // IE6 standards compliant mode
        x = document.documentElement.scrollLeft;
        y = document.documentElement.scrollTop;
    }
	elem = document.getElementById('oi_' + intID);
	strHref = elem.href
	pattern = /\?/;
	if (pattern.test(elem.href)) {
		location.href = strHref + '&x=' + x + '&y=' + y;
	}
	else {
		location.href = strHref + '?x=' + x + '&y=' + y;
	}
    return null;
}

function getQuerystring(key) {
	key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
	var qs = regex.exec(window.location.href);
	if(qs == null) {
		return 0;
	}
	else {
		return qs[1];
	}
}

function setScroll() {
	var x = getQuerystring('x');
	var y = getQuerystring('y');
	if ((x != "") && (y != "")) {
		window.scrollTo(x,y);
	}
}

function hideButtons(what) {
	var elem = what.getElementsByTagName("input");
    for (var i=0; i<elem.length; i++) {
		if (elem[i].type == "submit") {
            elem[i].style.display = 'none';
			elem[i].style.visibility = 'hidden';
		}
	}
}

function submitConfig(what) {
    var x = 0, y = 0;
    if( typeof( window.pageYOffset ) == 'number' ) {
        // Netscape
        x = window.pageXOffset;
        y = window.pageYOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        // DOM
        x = document.body.scrollLeft;
        y = document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        // IE6 standards compliant mode
        x = document.documentElement.scrollLeft;
        y = document.documentElement.scrollTop;
    }
	what.x.value = x;
	what.y.value = y;
	document.body.focus();
	what.submit();
}

function detectEnter(e, what) {
	var Key='';
	if (window.event) {
		Key = window.event.keyCode;
	}
	else {
		Key = e.keyCode
	}
	if (Key == 13) {
		if (window.event) {
			event.returnValue = false;
			VerifyFormData(what)
		}
		else {
			VerifyFormData(what)
			event.cancel = true;
		}
	}
}

function VerifyFormData(what) {
	var myName = '';
	var myType = '';
	var myMatch = '';
	var myRequired = '';
	var myError = '';
	var valid = true;
	var rExp = new RegExp ('FIELD_', 'g');
	for (var i=0, j=what.elements.length; i<j; i++) {
		myType = what.elements[i].type;
		myName = what.elements[i].name;
		myMatch = myName.match(rExp);
		if (myMatch) {
			myRequired = myName.replace(rExp, 'REQUIRED_');
			myError = myName.replace(rExp, 'ERROR_');
			if (what[myRequired] && document.getElementById(myError)) {
				if (myType == 'text') {
					if (valid == true) {
						if (what.elements[i].value == what.elements[i].defaultValue || what.elements[i].value == "Enter Data") {
							valid = false;
							what[myName].value = "Enter Data";
							what[myName].select()
							what[myName].focus()
							document.getElementById(myError).innerHTML = '<p class="top_bottom_margin">Please enter ' + what[myRequired].value + '</p>';
						}
						else {
							document.getElementById(myError).innerHTML = "";
						}
					}
					else {
						if (what.elements[i].value == what.elements[i].defaultValue || what.elements[i].value == "Enter Data") {
							what[myName].value = "";
						}
						document.getElementById(myError).innerHTML = "";
					}
				}
				if (myType == 'radio') {
					var radioSelected = 0;
					for (var a=0; a<what[myName].length; a++){ 
						if (what[myName][a].checked) {
							radioSelected++;
						}
					}
					if (valid == true) {
						if (radioSelected < 1) {
							valid = false;
							document.getElementById(myError).innerHTML = '<p class="top_bottom_margin">Please enter ' + what[myRequired].value + '</p>';
						}
						else {
							document.getElementById(myError).innerHTML = "";
						}
					}
					else {
						document.getElementById(myError).innerHTML = "";
					}
				}
				if (myType == 'checkbox') {
					var checkSelected = 0;
					for (var a=0; a<what[myName].length; a++){ 
						if (what[myName][a].checked) {
							checkSelected++;
						}
					}
					if (valid == true) {
						if (checkSelected < 1) {
							valid = false;
							document.getElementById(myError).innerHTML = '<p class="top_bottom_margin">Please enter ' + what[myRequired].value + '</p>';
						}
						else {
							document.getElementById(myError).innerHTML = "";
						}
					}
					else {
						document.getElementById(myError).innerHTML = "";
					}
				}
				if (myType == 'select-one') {
					if (valid == true) {
						if (what.elements[i].selectedIndex < 0) {
							valid = false;
							what[myName].focus()
							document.getElementById(myError).innerHTML = '<p class="top_bottom_margin">Please enter ' + what[myRequired].value + '</p>';
						}
						else {
							document.getElementById(myError).innerHTML = "";
						}
					}
					else {
						document.getElementById(myError).innerHTML = "";
					}
				}
				if (myType == 'select-multiple') {
					if (valid == true) {
						if (what.elements[i].selectedIndex < 0) {
							valid = false;
							what[myName].focus()
							document.getElementById(myError).innerHTML = '<p class="top_bottom_margin">Please enter ' + what[myRequired].value + '</p>';
						}
						else {
							document.getElementById(myError).innerHTML = "";
						}
					}
					else {
						document.getElementById(myError).innerHTML = "";
					}
				}
				if (myType == 'textarea') {
					if (valid == true) {
						if (what.elements[i].value == what.elements[i].defaultValue || what.elements[i].value == "Enter Data") {
							valid = false;
							what[myName].value = "Enter Data";
							what[myName].select()
							what[myName].focus()
							document.getElementById(myError).innerHTML = '<p class="top_bottom_margin">Please enter ' + what[myRequired].value + '</p>';
						}
						else {
							document.getElementById(myError).innerHTML = "";
						}
					}
					else {
						if (what.elements[i].value == what.elements[i].defaultValue || what.elements[i].value == "Enter Data") {
							what[myName].value = "";
						}
						document.getElementById(myError).innerHTML = "";
					}
				}
			}
		}
	}
	if (what.FIELD_security) {
		if (valid == true) {
			if (what.FIELD_security.value != "studiotech") {
				valid = false;
				what.FIELD_security.focus()
				document.getElementById('ERROR_security').innerHTML = '<p class="top_bottom_margin">Please enter the security code</p>';
			}
			else {
				document.getElementById(myError).innerHTML = "";
			}
		}
		else {
			if (what.FIELD_security.value != "studiotech") {
				what.FIELD_security.value = "";
			}
			document.getElementById(myError).innerHTML = "";
		}
	}
	if (valid == true) {
		what.submit();
	}
	else {
		return false;
	}
}
