function doOnload() {
	if (window.doOnload_extended)
		doOnload_extended();
	if (iPhone) {
		//iphone onload actions
	} else {
		switch (x) {
			case 'main':
			case 'search':
				if (search_ctg == 0) {
					//reset search form
					get_object('td_brn').style.display='none';
					get_object('search_ctg').selectedIndex=0;
				}
			break;
		}
		onResize(true);
	}
}
function doX(theX,definedUrlVars) {
	var var_array=urlVar_array;
	var url='index.cfm?x='+theX;
	if (definedUrlVars) {
		url+=definedUrlVars;
		//remove defined url var names from var_array
		var definedUrlVars_array=definedUrlVars.split('&');
		var i,varName;
		for (i=0;i<definedUrlVars_array.length;i++) {
			varName=definedUrlVars_array[i].split('=')[0];
			//alert('remove "'+varName+'"');
			var_array.removeItems(varName);
		}
	}
	for (i=0;i<var_array.length;i++) {
		url+='&'+var_array[i]+'='+eval(var_array[i]);
	}
	window.location.href=url;
}
function getBrn(o) {
	var ctgId=o.value;
	var url='ajax_getBrn.cfm?ctgId='+ctgId;
//	trace(url);
	loadAJAX('brn',url);
}
function popAJAX_brn(responseXML) {
	var brnTag=responseXML.getElementsByTagName('brn');
	var o=get_object('search_brn');
	popBrnSelect(o,brnTag);
	var hits=brnTag.length;
	if (hits == 0) {
		get_object('td_brn').style.display='none';
		get_object('search_phrase').focus();
	} else {
		get_object('td_brn').style.display='';
		o.focus();
	}
}
function onBrn() {
	get_object('search_phrase').focus();
}
function popBrnSelect(o,brnTag,chooseLabel) {
	var choose_label=(chooseLabel)?chooseLabel:'Välj märke...';
	o.options.length=0;
	addOption(o,'0',choose_label);
	var hits=brnTag.length;
	var i,text,value;
	for (i=0;i<hits;i++) {
		text=brnTag[i].firstChild.data;
		value=brnTag[i].attributes[0].nodeValue;
		addOption(o,value,text);
	}
}
function onResize(onLoad) {
	largestWidth=0;	
	//loops through all ads shown to check the rightmost ads position
	//If objArray is not defined the page doesnt display small ads
	obj_perRow=0;
	switch (view) {
		case 'card':
			//handle object cards
			if (onLoad)
				cards=document.getElementsByClassName('obhld');
			if (obj_recordcount != 0) {
				var i;
				for (i=0;i<cards.length;i++) {
					if (cards[i]) {
						if (largestWidth < cards[i].offsetLeft) {
							largestWidth=cards[i].offsetLeft;
							obj_perRow=i+1;
						} else {
							break;
						}
					}
				}
			}
			oc.updateShowMore();
		break;
		default:
			largestWidth=692;
	}
	//Makes sure we dont make the topbox to small
	//Currently set to never to under 5 small box ads in width
	if (largestWidth < 692)
		largestWidth=692;
	if (get_object('ad')) {
		get_object('ad').style.left=largestWidth+180+"px";
		get_object('ad').style.visibility="visible";
	}
	if (get_object('topMenu')) {
		get_object('topMenu').style.left=largestWidth-534+"px";
		get_object('topMenu').style.visibility="visible";
	}
	if (get_object('objListHeader'))
		get_object('objListHeader').style.width=largestWidth+134+"px";
	if (get_object('objHolder')) {
		get_object('objHolder').style.width=largestWidth+160+"px";
		get_object('objHolder').style.visibility="visible";
	}
	if (get_object('topBox')) {
		get_object('topBox').style.width=largestWidth+144+"px";
		get_object('topBox').style.visibility="visible";
		//set body top margin
		var topBottom_y=findPosY(get_object('topBoxBottom'));
		get_object('body').style.marginTop=(topBottom_y+16)+'px';
//		trace(topBottom_y);
	}
}


