// StartNosPopup: (deprecated... use 'newProductOrder' instead...)
// Function to launch the ordering of a new product. This function only still
// exists for backward compatibility to allow invocations from the flash 
// actionscript(s) within the product shaker, 'the appartement', LOF, ...
// Behind the scenes it calls the new 'newProductOrder' javascript 
// -----------------------------------------------------------------------------
startNosPopup = function( productId, na, orderingOptions, urlParameters ) {
	newProductOrder( productId, na, orderingOptions, urlParameters );
}

// NewProductOrder:
// Function to launch the ordering wizard for a new product (or even a set of 
// products if you pass a comma-separated list of dcr names)
// Other optional parameters are the na, orderingOptions & urlParameters.
// OrderingOptions is an Object of which every property is converted into
// a single parameter. Each property can also contain a simple array value
// which gets converted to a comma delimited list when being passed to NOS 
// UrlParameters is mainly used to pass e.g. special Webtrends parameters */
newProductOrder = function( productId, na, orderingOptions, urlParameters ) {
	// build invocation url to redirect to
     var newProductOrderUrlParams = new Array();
     
     if (productId) {
    	 newProductOrderUrlParams.push("productId=" + productId);
     };
     
     if (na) {
    	 newProductOrderUrlParams.push("na=" + na);
     };
     
     if (orderingOptions) {
     	for (var aOrderingOption in orderingOptions) {
    		aOrderingOptionValue = orderingOptions[aOrderingOption];
    		// in case the value is an array, convert it to comma separated string value
    		if (aOrderingOptionValue.constructor.toString().indexOf("Array") > -1) {
    			aOrderingOptionValue = aOrderingOptionValue.join(); 
    		}
    		newProductOrderUrlParams.push( aOrderingOption + "=" + aOrderingOptionValue );
    	}
     };
     
     if (urlParameters) {
    	 newProductOrderUrlParams.push(urlParameters);
     }

     var newProductOrderUrl = "newProductOrder";
     if (newProductOrderUrlParams.length > 0) {
    	 newProductOrderUrl = newProductOrderUrl + "?" + newProductOrderUrlParams.join("&");
     }
     
     // redirect
	 window.location.replace(newProductOrderUrl);
}