/**
 * Created by IntelliJ IDEA.
 * User: chris.hilditch
 * Date: 28-Jun-2010
 * Time: 15:36:58
 * To change this template use File | Settings | File Templates.
 */


function getMarqueModels( arrIndex, modelId ) {
	if ( arrIndex > 1) {
		make = _model[arrIndex];
		while ( $(modelId).options.length > 0 ) {
		   	$(modelId).options[$(modelId).options.length-1] = null;
		}
		var i = 0;
	    for ( i = 0 ; i < make.length ; i++ ) {
	        if ( make[i] == "ANY" ) {
	            $(modelId).options[i] = new Option( "--Select A Model--", "NA" );
	        } else {
	            $(modelId).options[i] = new Option( make[i], make[i] );
	        }
	    }
	}
}

function getMakes( makeID ) {
	try {
	    for ( i=0; i<make_v.length; i++ ) {
	        if (i == 0) {
	        	$(makeID).options[i] = new Option( "--Select A Make--", "-----");
	        } else if (i == 1) {
		        $(makeID).options[i] = new Option( "-----", "-----");
	        } else {
		        $(makeID).options[i] = new Option( make_v[i], capitalizeMe(make_v[i]));
	        }
	    }

	    // this line attempts to slice around the unwanted 'ANY' element
	    //$('marqueDetailId').options = concat( $('marqueDetailId').options.slice( 0,1 ) , $('marqueDetailId').options.slice( 2 ) )
	} catch(e) {
	    //alert(j + '-' + e);
	    alert( "There has been a problem in getting details of the Makes.\nPlease contact GForces Web Management Ltd" );
	}

}

function capitalizeMe(value) {
    val = value.toLowerCase();
    newVal = '';
    val = val.split(' ');
    for(var c=0; c < val.length; c++) {
        newVal += val[c].substring(0,1).toUpperCase() + val[c].substring(1,val[c].length) + ' ';
    }
    return newVal;
}
