/* 
CREATE SPECIAL LINKS (Ultra Lame Version)
V 0.5 by Pascal Mollet @ ricardo.ch
*/

function getSpecialLink(kind) {
	//Get the current URL
	var urlstring= (location.href).toLowerCase();
	var preUrlPos = urlstring.indexOf("/", 8);
	var preUrl = urlstring.substring(0, preUrlPos);

	//Get CatID
	if (urlstring.indexOf("/c/cn")!=-1) {
		pos = urlstring.indexOf("/c/cn") + 5;
		catid = urlstring.substring(pos, pos+5);
	}
	else if (urlstring.indexOf("/l/cn")!=-1) {
		pos = urlstring.indexOf("/l/cn") + 5;
		catid = urlstring.substring(pos, pos+5);
	}
	else if (urlstring.indexOf("/b/cn")!=-1) {
		pos = urlstring.indexOf("/b/cn") + 5;
		catid = urlstring.substring(pos, pos+5);
	}
	else if (urlstring.indexOf("?catg=")!=-1) {
		pos = urlstring.indexOf("?catg=") + 6;
		catid = urlstring.substring(pos, pos+5);
	}
	
	// remove the character "/" in case of category number lenght = 4
	catid = catid.replace("/","");
	
	//Create Link
	if (kind == "ende") {
		newurl = preUrl + "/search/search.asp?txtSearch=&Catg=" + catid + "&onlynewauction=0&CategoryType=0&ArticleType=0&ListingType=7&Zip=&ZipRange=0&InTitleAndDesc=0&pagesize=30&ListingSort=5";
	}
	else if (kind == "sfr") {

		newurl = preUrl + "/search/search.asp?txtSearch=&Catg=" + catid + "&onlynewauction=0&CategoryType=0&ArticleType=0&ListingType=3&Zip=&ZipRange=0&InTitleAndDesc=0&pagesize=30&ListingSort=5";
	}
	else if (kind == "neu") {
		newurl = preUrl + "/search/search.asp?txtSearch=&Catg=" + catid + "&onlynewauction=0&CategoryType=0&ArticleType=0&ListingType=4&Zip=&ZipRange=0&InTitleAndDesc=0&catalog=1&pagesize=30&ListingSort=1";
	}
	else if (kind == "hot") {
		newurl = preUrl + "/search/search.asp?txtSearch=&Catg=" + catid + "&onlynewauction=0&CategoryType=0&ArticleType=0&ListingType=1&Zip=&ZipRange=0&InTitleAndDesc=0&catalog=1&pagesize=30&ListingSort=1";
	}
	else if (kind == "now") {
		newurl = preUrl + "/search/search.asp?txtSearch=&Catg=" + catid + "&onlynewauction=0&ListingType=7&InTitleAndDesc=0&catalog=1&CategoryType=0&ArticleType=2&Zip=&ZipRange=0&pagesize=30&ListingSort=1";
	}
	
	//Open Link
	window.location = newurl;
}