//------------------------------------------------------------------------------------------------------------------
// productList
function changeSort()
{
 	var oURL = document.getElementById("sorturl");
 	var oSortSelect = document.getElementById("sortselect");
	var sSortby = oSortSelect.options[oSortSelect.selectedIndex].value;
	var sURL = oURL.value + "&sb=" + sSortby;
	//alert(sURL);	
	window.location.href = sURL;
}
function changeViewAs()
{
 	var oURL = document.getElementById("viewasurl");
 	var oViewAsSelect = document.getElementById("viewas");
	var sVa = oViewAsSelect.options[oViewAsSelect.selectedIndex].value;
	var sURL = oURL.value + "&va=" + sVa;
	//alert(sURL);	
	window.location.href = sURL;
}
function hasItems()
{
	var oCheckbox = document.getElementsByName("itembox");
	if( oCheckbox == null ) return false;
	if( oCheckbox.length != null ){
		for( var i=0; i<oCheckbox.length; i++){
			if( oCheckbox[i].checked == true ){
				return true;
			}
		}
	}else{
		if( oCheckbox.checked == true ){
			return true;
		}
	}	
	return false;
}	
			
function addItem(id,maiDn)
{
	document.getElementById("addone_id").value = id;
	document.getElementById("addone_type").value = document.getElementById("itemtype"+id).value;
	document.forms[2].action = maiDn+"/buyProducts.do";
	document.forms[2].target = "tarfr";
	document.forms[2].submit();
	return true;
}

function addItems(maiDn)
{
	if( !hasItems() ){
		alert("Please select at least 1 products to add to shoppingcart.");
		return false;
	}
	document.getElementById("addone_id").value = "";
	document.getElementById("addone_type").value = "";
	document.forms[2].action = maiDn+"/buyProducts.do";
	document.forms[2].target = "tarfr";
	document.forms[2].submit();
	return true;
}

function resetPrice()
{
	document.getElementById('pf').value='';
	document.getElementById('pt').value='';
}

function checkPrice()
{
	return (document.getElementById('pf').value=='' && document.getElementById('pt').value=='') ? false : true; 
}

function showSub(o,d){
	var s = document.getElementById(d);
	if(s.style.display == 'none' || s.style.display==''){
		s.style.display = 'block';
		o.src='/images/iconSortupgray.gif';
		o.title='Fewer';
	}else{
		s.style.display = 'none';
		o.src='/images/iconSortdowngray.gif';
		o.title='More';
	}
}
//------------------------------------------------------------------------------------------------------------------



//------------------------------------------------------------------------------------------------------------------
// Common functions
//
function inputFloat(text1, suffix) {
    var str = text1.value;
    for (var i = (str.length - 1) * 1; i >= 0; i = i - 1) {
        if (!isFloat(str)) {
            var ilen = str.length;
            str = str.substring(0, ilen - 1);
        } else {
            var dotindex = str.indexOf(".");
            if (dotindex < 0) {
                if (str.length > 6) {
                    ilen = str.length;
                    str = str.substring(0, ilen - 1);
                }
            } else {
                if (dotindex > 0) {
                    if (str.length - dotindex > suffix + 1) {
                        ilen = str.length;
                        str = str.substring(0, ilen - 1);
                    }
                }
            }
            break;
        }
    }
    text1.value = str;
}
//------------------------------------------------------------------------------------------------------------------

