// getSpecialLink.js
// Patric Steinegger - ricardo.at GmbH
 /*********************************************************************************
 * Enables special Links (New, Starting at 1 EUR, etc.) for the category pages by *
 * extracting the category number from the URL and redirecting the user to the    *
 * search results.                                                                *
 *********************************************************************************/

function getSpecialLink(kind) {
	//Get the current URL
	var urlstring = window.location.href;
	var preUrl = window.location.protocol + "//" + window.location.host;
	var suche = "/search/search.asp?txtSearch=&Catg=";
	var ausdruck = /(Catg|List|Catg=)(\d{1,5})/;
	var auction = "&onlynewauction=0&CategoryType=0&ArticleType=0";
	var listingtype = "&ListingType=";
	var zip = "&Zip=&ZipRange=0&InTitleAndDesc=0&pagesize=30";
	var listingsort = "&ListingSort=";

	//Get CatID
	ausdruck.exec(urlstring);
	
	//Create Link
	switch (kind) {
		case "ende":
			listingtype += 7;
			listingsort += 5;
			break;
		case "sfr":
			listingtype += 3;
			listingsort += 5;
			break;
		case "neu":
			listingtype += 4;
			listingsort += 1;
			break;
	}
	window.location = preUrl + suche + RegExp.$2 + auction + listingtype + zip + listingsort;
	return false;
}