function GenerateUrl(theForm){

	var goUrl = '';
	
	var attributeValue = '';
	var catID = '';
	var producerID = '';
	
	
	try{
		attributeValue = theForm.atr.options[theForm.atr.selectedIndex].value; // document.getElementById('atr');
	}
	catch(ex){
		attributeValue = '';
	}
	
	
	try{
		catID = theForm.cid.options[theForm.cid.selectedIndex].value;
	}
	
	catch(ex){
	}
	
	try{
		producerID = theForm.prd.options[theForm.prd.selectedIndex].value; // document.getElementById('prd');
	}
	
	catch(ex){
		producerID = 0;
	}
	
	var queryOrder = theForm.fqcporder.value;
	var queryProducerPrefix = theForm.fqppre.value;
	var queryCategoryPrefix = theForm.fqcpre.value;
	var queryNewsPrefix = theForm.fqnpre.value;
	var querySalePrefix = theForm.fqspre.value;
	var queryUsePrefixFor = theForm.fqupre.value;
	var queryFilterPrefix = theForm.fqprefix.value;
	var queryFilterPrefixPosition = theForm.fqprefixpos.value;
	var queryFilterExt = theForm.fqext.value;
		
	var catUrl = '';
	if(catID.length >0){
		try{
			catUrl = document.getElementById('cat'+ catID ).value;
		}
		
		catch(ex){
		}
	}
	
	var producerUrl = '';
	if(producerID.length >0){
		try{
			producerUrl = document.getElementById('producer'+ producerID ).value;
		}
		catch(ex){
		}	
	}

	
	switch(queryOrder){
		case 'category-producer':
			if(catUrl.length > 0){
				if(queryUsePrefixFor == 'category') goUrl = goUrl +''+ queryCategoryPrefix +'-';
				goUrl = goUrl + ''+ catUrl;
			}
			
			if(producerUrl.length > 0 ){
				if(goUrl.length > 0 ) goUrl = goUrl +'-';
				if(queryUsePrefixFor == 'producer') goUrl = goUrl +''+ queryProducerPrefix +'-';
				goUrl = goUrl + ''+ producerUrl;
			}
			break;
	
		case 'producer-category':
			if(producerUrl.length > 0 ){
				if(goUrl.length > 0 ) goUrl = goUrl +'-';
				if(queryUsePrefixFor == 'producer') goUrl = goUrl +''+ queryProducerPrefix +'-';
				goUrl = goUrl + ''+ producerUrl;
			}

			if(catUrl.length > 0){
				if(queryUsePrefixFor == 'category') goUrl = goUrl +''+ queryCategoryPrefix +'-';
				goUrl = goUrl + ''+ catUrl;
			}			
			break;
	}


	
	if(attributeValue.length > 0 ){
		switch(attributeValue){
			case 'news':
				if(goUrl.length > 0) goUrl = goUrl +'-';
				goUrl = goUrl +''+ queryNewsPrefix;
				break;

			case 'sale':
				if(goUrl.length > 0) goUrl = goUrl +'-';
				goUrl = goUrl +''+ querySalePrefix;			
				break;
		}	
	}

	if(goUrl.length > 0){
		switch(queryFilterPrefixPosition) {
			case 'before':
				goUrl = queryFilterPrefix +'-'+ goUrl;
				break;
		
			case 'after':
				goUrl = goUrl +'-'+ queryFilterPrefix ;			
				break;
		}
		goUrl = goUrl +'.'+ queryFilterExt;
	}

	// alert('goUrl: '+ goUrl );
	
	var strOrder = '';
	// Order
	try{
		strOrder = theForm.order[theForm.order.selectedIndex].value;
		// alert('order: '+ strOrder );
		feedCookie('plistorder', strOrder);
	}
	catch(ex){}
	
	
	location.href = goUrl;
	
	return false;

}



function feedCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


