/**
 * @author Kovacs Gabriel
 * @author Andrei Pfeiffer
 */

// Quantity spin buttons
function increase_by_one(field) {
	var nr = document.getElementById(field).value;
	var newVal = 1;
	
	if (IsNumeric(nr)==true) {
		newVal = parseInt(nr)+1;
	}
	
	document.getElementById(field).value = newVal;
}

function decrease_by_one(field, min_quantity) {
	nr = document.getElementById(field).value;
	var newVal = 1;
	
	if (IsNumeric(nr)==true) {
		if (nr > min_quantity) {
			newVal = parseInt(nr)-1;
		} else {
			newVal = min_quantity;
		}
	}
	
	document.getElementById(field).value = newVal;
}

//  check for valid numeric strings	
function IsNumeric(strString) {
	var strValidChars = "0123456789.-";
	var strChar;
	var blnResult = true;
	
	if (strString.length == 0) return false;
	
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++) {
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1) {
			blnResult = false;
		}
	}
	
	return blnResult;
}




// on page load complete, fire off a jQuery 
$(document).ready(function() {
	
	$(".arrow-up, .arrow-down").click( function() {
		$($($(this).parent().get(0)).parent().get(0)).find("input").hide();
		$($($(this).parent().get(0)).parent().get(0)).find("input").fadeIn(200);
		return false;
	});
	
	//$('#more-details > ul').tabs({ fx: { opacity: 'toggle' } });

});