
/* Country specific constants */
qxlSite = {
	host_main: 'www.qxl.no',
	host_sellers: 'auksjon.qxl.no',
	host_beta: 'www.no.betaqxl.com',
	host_dev: 'www.no.devqxl.com',
	segment_buy: 'pris',
	segment_erotic: 'erotikk-sexleketoy-erotiske-filmer',
	segment_cars: 'bil-mc-baat',
	/* Special links in order: new, ending soon, popular, from-1-euro */
	special_links: ['nye-auksjoner','slutter-snart','populaere','utropspris-1-kr']
};
/* Environment variables for the current page */
/* We pre-define a few vars so they can be referenced in the qxlVars object below */
qV = {
	href: location.href.toLowerCase(),
	host: location.hostname.toLowerCase(),
	path: (location.pathname+location.search+location.hash).toLowerCase(),
	segm: location.pathname.toLowerCase().match(/\/[^\/\#\?\&]*/)[0].substring(1)
};
qxlVars = {

	/* Base URL handling (pre-defined) */
	lower_href: qV.href,
	lower_host: qV.host,
	lower_path: qV.path,
	lower_first_segment: qV.segm,

	/* Secondary URL handling */
	base_href: location.protocol + '//' + location.hostname + '/',

	/* Protocol */
	is_http: (location.protocol == 'http:'),
	is_https: (location.protocol == 'https:'),

	/* Production/Beta environment */
	is_prod: ((qV.host == qxlSite.host_main) || (qV.host == qxlSite.host_sellers)),
	is_beta: (qV.host == qxlSite.host_beta),
	is_dev: (qV.host == qxlSite.host_dev),

	/* Active page */
	is_search: (qV.path.indexOf('/search/search.asp') == 0) || (qV.path.indexOf('/carsandbikes/search.aspx') == 0),
	is_special_search: ($.inArray( decodeURIComponent(qV.segm), qxlSite.special_links ) > -1),
	is_seller_listing: (qV.host == qxlSite.host_sellers),
	is_cars: ((decodeURIComponent(qV.path).indexOf(qxlSite.segment_buy + '/' + qxlSite.segment_cars) == 1) || (qV.href.indexOf("viewitem_cb.aspx") > -1) || (qV.path.indexOf('/carsandbikes/search.aspx') == 0)),
	is_myqxl: (qV.segm == 'mypages'),
	is_category_top: (qV.path == '/' + qxlSite.segment_buy + '/'),
	is_category_index: (qV.href.indexOf("/c/cn") > -1),
	is_category_listing: ((qV.href.indexOf("/l/cn") > -1) || (qV.href.indexOf("/b/cn") > -1)),
	is_itempage: ((qV.href.indexOf("/v/an") > -1) || (qV.href.indexOf("viewitem.aspx") > -1) || (qV.href.indexOf("viewitem_cb.aspx") > -1)),
	is_sellingformpage1: (qV.path.indexOf('/form/addobj.asp') == 0),
	is_sellingformpage2: (qV.path.indexOf('/form/addobj_step2.asp') == 0),
	is_erotic_category: (decodeURIComponent(qV.path).indexOf(qxlSite.segment_buy + '/' + qxlSite.segment_erotic) == 1),
	is_erotic_search: (qV.href.indexOf('catalog=4') > -1),

	/* Category path default values */
	categoryID: 1
};
qxlVars.is_www = (qxlVars.is_prod || qxlVars.is_beta || qxlVars.is_dev); // I.e. not help, subdomains, cobrands, mobile, etc.
qxlVars.is_homepage = ( (location.pathname == '/') && qxlVars.is_www );
qxlVars.is_category = (qxlVars.is_category_index || qxlVars.is_category_listing);
qxlVars.is_listing = (qxlVars.is_search || qxlVars.is_category_listing || qxlVars.is_special_search);
qxlVars.is_erotic = (qxlVars.is_erotic_category || qxlVars.is_erotic_search);
if (qxlVars.is_seller_listing) qxlVars.base_href = location.protocol + '//' + qxlSite.host_main + '/';

/* Debugging function */
function trace(s) {
	try { console.log(s) } catch (e) { }
}


