var update_history;

function autoslide(){
	if ((tempX>document.getElementById('main').offsetLeft) && (tempX<(document.getElementById('scrollmenu').offsetWidth+document.getElementById('main').offsetLeft))) {
		if ((tempY>document.getElementById('scrollmenu').offsetTop) && (tempY<(document.getElementById('scrollmenu').offsetHeight+document.getElementById('scrollmenu').offsetTop))){
			
		}else{
			if(curSel=="0"){
				autosliding();
			}
		}
	}else{ 
			if(curSel=="0"){
				autosliding();
			}
	}	
	
	if(document.getElementById(banner)){//check if this is the main page .. can also use current_page
		if (banner_moving==1){
			if (banner_cycle<21){
				document.getElementById(banner).style.left=600-(banner_cycle*30)+"px";	
				document.getElementById(banner).style.width=((banner_cycle*30)-2)+"px";
				document.getElementById('banner_move'+prevbanner).style.width=600-(banner_cycle*30)+"px";
				banner_cycle=banner_cycle+1;
			}else{
				banner_cycle=1;
				banner_moving=0;
				document.getElementById('banner_move'+prevbanner).style.left=600+"px";	
				document.getElementById('banner_move'+prevbanner).style.width=0+"px";
			}
		}
	}
	
	if (submenu_moving==1){
		if (submenu_direction=="start"){
			if(submenu_name==""){
				var submenu_startname="sub_twitter";
				var sub_startheight=document.getElementById('sub_twitter').offsetHeight;
			}else{
				var submenu_startname ="sub_"+submenu_name;
				var sub_startheight=document.getElementById(submenu_startname).offsetHeight+20;
				document.getElementById(submenu_startname).style.border="1px solid #9F9F9F";
			}
		
			if (submenu_cycle<11){
				document.getElementById(submenu_startname).style.height="auto";
				submenu_height = sub_startheight/10;
				document.getElementById('sub_scrolldown').style.height = (submenu_cycle*submenu_height)+"px";
				submenu_cycle = submenu_cycle+1;
				if(BrowserDetect.browser == 'Explorer' && submenu_cycle<11){
					document.getElementById('sub_scrolldown').style.height = (submenu_cycle*submenu_height)+"px";
					submenu_cycle = submenu_cycle+1;
				}
			}else{
				submenu_cycle=1;
				submenu_moving=0;
			}
		}else if (submenu_direction=="down"){
			if(submenu_cycle<6){			
				document.getElementById('sub_category').style.height=0+"px";
				document.getElementById('sub_brand').style.height=0+"px";
				document.getElementById('sub_computer').style.height=0+"px";
				document.getElementById('sub_laptop').style.height=0+"px";
				document.getElementById('sub_twitter').style.height="auto";
				submenu_height = (document.getElementById('sub_twitter').offsetHeight)/5;
				document.getElementById('sub_scrolldown').style.height = (submenu_height*5)-(submenu_cycle*submenu_height)+"px";
				submenu_cycle = submenu_cycle+1;
				if(BrowserDetect.browser == 'Explorer' && submenu_cycle<6){
					document.getElementById('sub_scrolldown').style.height = (submenu_height*5)-(submenu_cycle*submenu_height)+"px";
					submenu_cycle = submenu_cycle+1;
				}
			}else if(submenu_cycle>5 && submenu_cycle<16){ //now going down
				document.getElementById('sub_'+submenu_name).style.border="1px solid #9F9F9F";
				document.getElementById('sub_twitter').style.height="0px";
				document.getElementById('sub_'+submenu_name).style.height="auto";
				submenu_height = (document.getElementById('sub_'+submenu_name).offsetHeight+20)/10;
				adj_cycle = submenu_cycle-5;
				document.getElementById('sub_scrolldown').style.height = (adj_cycle*submenu_height)+"px";
				submenu_cycle = submenu_cycle+1;
				if(BrowserDetect.browser == 'Explorer' && submenu_cycle>5 && submenu_cycle<16){
					adj_cycle = submenu_cycle-5;
					document.getElementById('sub_scrolldown').style.height = (adj_cycle*submenu_height)+"px";
					submenu_cycle = submenu_cycle+1;
				}
			}else{
				submenu_cycle=1;
				submenu_moving=0;
			}
		}else if (submenu_direction=="up"){  //going up
			if(submenu_cycle<11){
				document.getElementById('sub_scrolldown').style.height=(submenu_height*10-(submenu_cycle*submenu_height))+"px";
				submenu_cycle = submenu_cycle+1;
				if(BrowserDetect.browser == 'Explorer' && submenu_cycle<11){
					document.getElementById('sub_scrolldown').style.height=(submenu_height*10-(submenu_cycle*submenu_height))+"px";
					submenu_cycle = submenu_cycle+1;
				}
			}else if(submenu_cycle>10 && submenu_cycle<16){ //now going down
				document.getElementById('sub_category').style.border="none";
				document.getElementById('sub_brand').style.border="none";
				document.getElementById('sub_computer').style.border="none";
				document.getElementById('sub_laptop').style.border="none";
				document.getElementById('sub_category').style.height=0+"px";
				document.getElementById('sub_brand').style.height=0+"px";
				document.getElementById('sub_computer').style.height=0+"px";
				document.getElementById('sub_laptop').style.height=0+"px";
				document.getElementById('sub_twitter').style.height="auto";
				
				submenu_height = (document.getElementById('sub_twitter').offsetHeight)/5;
				adj_cycle = submenu_cycle-10;
				document.getElementById('sub_scrolldown').style.height = (adj_cycle*submenu_height)+"px";
				submenu_cycle = submenu_cycle+1;
				if(BrowserDetect.browser == 'Explorer' && submenu_cycle>10 && submenu_cycle<16){
					adj_cycle = submenu_cycle-10;
					document.getElementById('sub_scrolldown').style.height = (adj_cycle*submenu_height)+"px";
					submenu_cycle = submenu_cycle+1;
				}
			}else{
				submenu_cycle=1;
				submenu_moving=0;
				document.getElementById('sub_twitter').style.height="auto";
			}
		}else{ //up & then down
			if(submenu_cycle<11){ //first going up
				document.getElementById('sub_scrolldown').style.height=submenu_height*10-(submenu_cycle*submenu_height)+"px";
				submenu_cycle = submenu_cycle+1;
				if(BrowserDetect.browser == 'Explorer' && submenu_cycle<11){
					document.getElementById('sub_scrolldown').style.height=submenu_height*10-(submenu_cycle*submenu_height)+"px";
					submenu_cycle = submenu_cycle+1;
				}
			}else if(submenu_cycle>10 && submenu_cycle<21){ //now going down
				if(submenu_cycle==11){//vanish the border
					document.getElementById('sub_category').style.border="none";
					document.getElementById('sub_brand').style.border="none";
					document.getElementById('sub_computer').style.border="none";
					document.getElementById('sub_laptop').style.border="none";
				}
				document.getElementById('sub_'+submenu_name).style.border="1px solid #9F9F9F";
				document.getElementById('sub_category').style.height=0+"px";
				document.getElementById('sub_brand').style.height=0+"px";
				document.getElementById('sub_computer').style.height=0+"px";
				document.getElementById('sub_laptop').style.height=0+"px";
				document.getElementById('sub_'+submenu_name).style.height="auto";
				
				submenu_height = (document.getElementById('sub_'+submenu_name).offsetHeight+20)/10;
				adj_cycle = submenu_cycle-10;
				document.getElementById('sub_scrolldown').style.height = (adj_cycle*submenu_height)+"px";
				submenu_cycle = submenu_cycle+1;
				if(BrowserDetect.browser == 'Explorer' && submenu_cycle>10 && submenu_cycle<21){
					adj_cycle = submenu_cycle-10;
					document.getElementById('sub_scrolldown').style.height = (adj_cycle*submenu_height)+"px";
					submenu_cycle = submenu_cycle+1;
				}
			}else{
				submenu_cycle=1;
				submenu_moving=0;
			}
		}	
	}
	
	if (brand_scrollmoving==1){
		elem = document.getElementById('sub_brand_scrollmenu');
		if (brand_scrolldirection=='left'){//moving left
			if (brand_scrollcycle < 6){
				elem.scrollLeft=elem.scrollLeft - brand_scrollpulse;
				brand_scrollcycle=brand_scrollcycle+1;
			}else{
				brand_scrollcycle=1;
				brand_scrollmoving=0;
			}	
		}else{//moving right
			if (brand_scrollcycle < 6){
				elem.scrollLeft=elem.scrollLeft + brand_scrollpulse;
				brand_scrollcycle=brand_scrollcycle+1;
			}else{
				brand_scrollcycle=1;
				brand_scrollmoving=0;
			}
		}
	}
	
	if(fade==1){
		if(submenu_name==""){
			if (fade_cycle<6){//fade out
				document.getElementById('sub_twitter'+fade_name).style.height="40px";
				opacityAsInt =100 - (20*fade_cycle);
				opacityAsDecimal = opacityAsInt / 100;
				document.getElementById('sub_twitter'+fade_name).style.filter  = "alpha(opacity=" + opacityAsInt + ")";
				document.getElementById('sub_twitter'+fade_name).style.opacity = (opacityAsDecimal);
				fade_cycle=fade_cycle+1;
			}else if(fade_cycle<11){ //fade in
				opacityAsInt = 20*(fade_cycle-5);
				opacityAsDecimal = opacityAsInt / 100;
				document.getElementById('sub_twitter'+fade_name).style.height="0px";
				if (fade_name==5){
					fadename=1;
				}else{
					fadename = fade_name+1;
				}
				
				document.getElementById('sub_twitter'+fadename).style.filter  = "alpha(opacity=" + opacityAsInt + ")";
				document.getElementById('sub_twitter'+fadename).style.opacity = (opacityAsDecimal);
				document.getElementById('sub_twitter'+fadename).style.height="40px";
				fade_cycle=fade_cycle+1;
			}else{ //settling everything
				fade=0;
				fade_cycle=1;
				if (fade_name==5){
					fade_name=1;
				}else{
					fade_name=fade_name+1;
				} 
			}
		}else{
			for(x=1;x<6;x++){
				document.getElementById('sub_twitter'+x).style.height="0px";
			}
		}
	}		
}

function autosliding(){
	element=document.getElementById('scrollable');
	maxim=element.scrollWidth-element.offsetWidth;
	if (going==1){
		if (slidepos<maxim){			
			if(slidepos<0){
				slidepos=0;
		  	}
			slidepos = slidepos+1;
			value=slidepos*slider4.maximum/maxim;
			slider4.setValue(value);
		}else{

			going=0;
			slidepos = slidepos-1;
			value=slidepos*slider4.maximum/maxim;
			slider4.setValue(value);
		}
	}else{
		if (slidepos>0){
			if(slidepos>maxim){
				slidepos=maxim;
		  	}
			slidepos = slidepos-1;
			value=slidepos*slider4.maximum/maxim;
			slider4.setValue(value);
		}else{
			going=1;
			//slider4.setValueBy(0.002);
			slidepos = slidepos+1;
			value=slidepos*slider4.maximum/maxim;
			slider4.setValue(value);
		}
	}
	element.scrollLeft=slidepos;
}

function fadeNews(){
	fade = 1;
}

function change(id,desc){
	if (curSel!=id){
		categtext = "SuperCategText_"+id;
		document.getElementById(categtext).style.color = "#02B1C8";
		if(document.getElementById("supercategcenter_"+id)){
			document.getElementById("supercategcenter_"+id).className="supercateg_centerover";
		}
	};
	//document.getElementById('Information').innerHTML = desc;
}

function changeback(id){
	if (curSel!=id){
		categtext = "SuperCategText_"+id;
		document.getElementById(categtext).style.color = "#000000";
		if(document.getElementById("supercategcenter_"+id)){
			document.getElementById("supercategcenter_"+id).className="supercateg_center";
		}
	};
}

function superClick(id, name, num , total){
	if(current_file=="/index.php"){
		document.getElementById('hidebox').style.visibility="visible";
		document.getElementById('ProductListing').style.visibility="hidden";
		document.getElementById('WaitMessage').style.visibility="visible";
		document.getElementById('filterhistory').innerHTML="";
		catid='new';
		if(total!=0){
			slider4.setValue(num/(total-1));
			slidepos = Math.round((num/(total-1))/slider4.maximum*(document.getElementById('scrollable').scrollWidth-document.getElementById('scrollable').offsetWidth));		
		}
		if(curSel=="0"){
			catid='new';	
			document.getElementById('SuperCateg_'+id).style.backgroundColor = "#91E0FF";
			document.getElementById('SuperCategText_'+id).style.backgroundColor = "#91E0FF";	
			document.getElementById('SuperCategText_'+id).style.color = "#000000";
			document.getElementById('SuperCategText_'+id).style.fontWeight = "bold";
			dhtmlHistory.add("scatid="+id, null);
			document.getElementById('search_input_id').value="";
			curSel = id;
		} else if(curSel==id){
			if(curSel!="0"){changeSel(curSel)};
			curSel="0";
			document.getElementById('search_input_id').value="";
			catid='home';
			var r = window.location.href;
			var i = r.indexOf("?");
			if (i>=0){
				window.location.href="/index.php";
			}
			dhtmlHistory.add("home", null);
		} else {
			catid='new';
			if(curSel!="0"){changeSel(curSel)};
			document.getElementById('SuperCateg_'+id).style.backgroundColor = "#91E0FF";
			document.getElementById('SuperCategText_'+id).style.backgroundColor = "#91E0FF";	
			document.getElementById('SuperCategText_'+id).style.color = "#000000";
			document.getElementById('SuperCategText_'+id).style.fontWeight = "bold";
			document.getElementById('search_input_id').value="";
			curSel = id;
			dhtmlHistory.add("scatid="+id, id);	
		}
		
		name_adj = name.replace( /&/g,'-AND-')
		var myAjax = new Ajax.Updater('ProductListing','index.php',
					{method: 'get', parameters:'sort='+sorty+'&imgsize='+imgsize+'&catid='+catid+'&prodperpage='+prodperpage+'&pgnumber='+pgnumber+'&show='+showy+'&supercatid='+id+'&supercategname='+name_adj,
						onComplete : function(){
							resize_topban();
						}
						
						} );
		var myAjax = new Ajax.Updater('CategoryList',current_file,
					{method: 'get', parameters:'action=draw_leftcatmenu&catid='+catid+'&supercatid='+curSel+'&supercategname='+name_adj} );	
		catSel="0";
	}else{
		window.location.href="/index.php/#scatid="+id;
	}	
}

function submenu_click(id){
	var banheight=0;
	var left=0;	
	
	if (id=="category"){
		left=0;
	}else if (id=="brand"){
		left=245;
	}else if (id=="computer"){
		left=491;
	}else if (id=="laptop"){
		left=737;
	}
	
	submenu_moving=1;
	submenu_cycle=1;
	
	if(submenu_name==""){
		submenu_name=id;
		submenu_direction="down";
		document.getElementById('br_'+id).style.backgroundPosition = "-"+left+"px -114px";
	}else if(submenu_name==id){
		submenu_direction="up";
		document.getElementById('br_'+id).style.backgroundPosition = "-"+left+"px -76px";
		submenu_name="";
		document.getElementById('sub_'+id).style.height="auto";
		submenu_height = (document.getElementById('sub_'+id).offsetHeight)/10;
	}else{
		submenu_direction="updown";
		submenu_height = document.getElementById('sub_'+submenu_name).offsetHeight/10;
		document.getElementById('br_'+id).style.backgroundPosition = "-"+left+"px -114px";
		
		if (submenu_name=="category"){
			left=0;
		}else if (submenu_name=="brand"){
			left=245;
		}else if (submenu_name=="computer"){
			left=491;
		}else if (submenu_name=="laptop"){
			left=737;
		}
		document.getElementById('br_'+submenu_name).style.backgroundPosition = "-"+left+"px 0px";
		submenu_name=id;
	}
}

function submenu_hover(id){
	var banheight=document.getElementById('sub_scrolldown').offsetHeight;
	var left=0;	
	
	if (id=="category"){
		left=0;
	}else if (id=="brand"){
		left=245;
	}else if (id=="computer"){
		left=491;
	}else if (id=="laptop"){
		left=737;
	}
		
	if (submenu_name==id){
		if(banheight<3){ //closed
			document.getElementById('br_'+id).style.backgroundPosition = "-"+left+"px -76px";
		}else{//open
			if(submenu_moving==1 && submenu_direction=="up"){
				document.getElementById('br_'+id).style.backgroundPosition = "-"+left+"px -76px";
			}else{
				document.getElementById('br_'+id).style.backgroundPosition = "-"+left+"px -114px";
			}
		}
	}else{
		document.getElementById('br_'+id).style.backgroundPosition = "-"+left+"px -76px";
	}	
}

function submenu_out(id){
	var banheight=document.getElementById('sub_scrolldown').offsetHeight;
	var left=0;
	
	if (id=="category"){
		left=0;
	}else if (id=="brand"){
		left=245;
	}else if (id=="computer"){
		left=491;
	}else if (id=="laptop"){
		left=737;
	}
	
	if (submenu_name==id){
		if(banheight<3){ //closed
			document.getElementById('br_'+id).style.backgroundPosition = "-"+left+"px 0px";
		}else{//open
			if(submenu_moving==1 && submenu_direction=="up"){
				document.getElementById('br_'+id).style.backgroundPosition = "-"+left+"px 0px";
			}else{
				document.getElementById('br_'+id).style.backgroundPosition = "-"+left+"px -38px";		
			}
		}
	}else{
		document.getElementById('br_'+id).style.backgroundPosition = "-"+left+"px 0px";
	}
}

function brand_scroll(direction, pgno){
	elem = document.getElementById('sub_brand_scrollmenu');
	brand_scrollmoving=1;
	brand_scrollpulse=150;
	if(direction=='right'){
		brand_scrolldirection='right';
		document.getElementById('sub_brand_pageno'+brand_pageno).style.backgroundPosition = "0px 0px";
		if (elem.scrollLeft==elem.scrollWidth - 750){
			brand_pageno=1;
			document.getElementById('sub_brand_pageno'+brand_pageno).style.backgroundPosition = "0px -16px";
			elem.scrollLeft =  0;
			brand_scrollmoving=0;
		} else{
			brand_pageno++;
			document.getElementById('sub_brand_pageno'+brand_pageno).style.backgroundPosition = "0px -16px";
		}
	}else if(direction=='left'){
		brand_scrolldirection='left';
		document.getElementById('sub_brand_pageno'+brand_pageno).style.backgroundPosition = "0px 0px";
		if (elem.scrollLeft==0){
			brand_pageno = elem.scrollWidth / 750;
			elem.scrollLeft = elem.scrollWidth;
			brand_scrollmoving=0;
			document.getElementById('sub_brand_pageno'+brand_pageno).style.backgroundPosition = "0px -16px";
		}else{
			brand_pageno--;
			document.getElementById('sub_brand_pageno'+brand_pageno).style.backgroundPosition = "0px -16px";
		}
	}else{
		document.getElementById('sub_brand_pageno'+brand_pageno).style.backgroundPosition = "0px 0px";
		document.getElementById('sub_brand_pageno'+pgno).style.backgroundPosition = "0px -16px";
		brand_pageno=pgno;
		
		dest_scroll = (pgno-1)*750;
		if (dest_scroll > elem.scrollLeft){//scrolling right
			brand_scrolldirection='right';
			brand_scrollpulse = (dest_scroll - elem.scrollLeft)/5;
		}else{//scrolling left
			brand_scrolldirection='left';
			brand_scrollpulse = (elem.scrollLeft - dest_scroll)/5;
		}
	}	
}

function brand_scrollimage(direction,image){
	if (image=='in'){
		document.getElementById('sub_brand_move'+direction).style.backgroundPosition = "0px -27px";
	}else{
		document.getElementById('sub_brand_move'+direction).style.backgroundPosition = "0px 0px";
	}
}

function brand_pagenoimage(direction, pgno){
	if(pgno!=brand_pageno){
		if(direction=='in'){
			document.getElementById('sub_brand_pageno'+pgno).style.backgroundPosition = "0px -8px";
		}else{
			document.getElementById('sub_brand_pageno'+pgno).style.backgroundPosition = "0px 0px";
		}
	}
}
		
function sub_computer_acc_hover(image,direction){
	var left=0;
	
	if (image==1){
		left=0;
	}else if(image==2){
		left=71;
	}else if (image==3){
		left=142;
	}else{
		left=213;
	}
	if (document.getElementById('sub_computer_title'+image).className.indexOf('active')==-1){
		if (direction=="in"){
			document.getElementById('sub_computer_title'+image).style.backgroundPosition ="-"+left+"px -171px";
		}else{
			document.getElementById('sub_computer_title'+image).style.backgroundPosition ="-"+left+"px 0px";
		}
	}
}

function sub_laptop_acc_hover(image,direction){
	var left=0;
	
	if (image==1){
		left=0;
	}else if(image==2){
		left=71;
	}else if (image==3){
		left=142;
	}
	
	if (document.getElementById('sub_laptop_title'+image).className.indexOf('active')==-1){
		if (direction=="in"){
			document.getElementById('sub_laptop_title'+image).style.backgroundPosition ="-"+left+"px -171px";
		}else{
			document.getElementById('sub_laptop_title'+image).style.backgroundPosition ="-"+left+"px 0px";
		}
	}
}


function accordion_select(){
	var left=0;
	for (var x=1;x<5;x++){
		if (x==1){
			left=0;
		}else if(x==2){
			left=71;
		}else if (x==3){
			left=142;
		}else{
			left=213;
		}
		if (document.getElementById('sub_computer_title'+x).className.indexOf('active')>0){
			document.getElementById('sub_computer_title'+x).style.backgroundPosition="-"+left+"px -342px";
		}else if(document.getElementById('sub_computer_title'+x)){
			document.getElementById('sub_computer_title'+x).style.backgroundPosition="-"+left+"px 0px";
		}
		if(x<4){
			if (document.getElementById('sub_laptop_title'+x).className.indexOf('active')>0){
				document.getElementById('sub_laptop_title'+x).style.backgroundPosition="-"+left+"px -342px";
			}else if(document.getElementById('sub_laptop_title'+x)){
				document.getElementById('sub_laptop_title'+x).style.backgroundPosition="-"+left+"px 0px";
			}
		}
	}	
}

function brandover(id){
	document.getElementById("brand_"+id).className="supercateg_centerover";
	if (document.getElementById('brandcenter_'+id)){
		document.getElementById("brandcenter_"+id).className="supercateg_centerover";
	}
}

function brandout(id){
	document.getElementById("brand_"+id).className="supercateg_center";
		if (document.getElementById('brandcenter_'+id)){
			document.getElementById("brandcenter_"+id).className="supercateg_center";
		}
}

function slideLeft(slider){
	element=document.getElementById('scrollable');
	val = (element.scrollWidth-element.offsetWidth)/10;
	
	slidepos = slidepos-val;
	value=slidepos*(slider4.maximum)/maxim;
	slider4.setValue(value);
	element.scrollLeft = slidepos;
	going=0;
}

function slideRight(slider){
	element=document.getElementById('scrollable');
	val = (element.scrollWidth-element.offsetWidth)/10;
	
	slidepos = slidepos+val;
	value=slidepos*(slider4.maximum)/maxim;
	slider4.setValue(value);
	element.scrollLeft = slidepos;
	going=1;
}

function update_search(showing){		
	categshow = showing;
	doSearch();
}

function update_prodsearch(showing){		
	prodshow = showing;
	doSearch();
}

function search_updatehistory(searchstring){
	if(searchstring.length !=0 ){
		dhtmlHistory.add("catid=search:searchstring="+searchstring, 'Search for '+searchstring);
	}else{	
		var r = window.location.href;
		var i = r.indexOf("?");
		if (i>=0){
			window.location.href="/index.php";
		}
		dhtmlHistory.add("home", "Home Page");
	}
}

function doSearch(){
	var keycount=document.getElementById('search_input_id').value.length;
	var searchstring=document.getElementById('search_input_id').value;
	if (keycount !=0 ){
		clearTimeout(timeout);
		clearTimeout(update_history);
		
		pgnumber=1;
		timeout = setTimeout('sndReq("'+searchstring+'")', 600);	
		update_history=setTimeout('search_updatehistory("'+searchstring+'")',1500);
	}else{
		clearTimeout(timeout);
		//document.getElementById('SuperCatInfo').innerHTML = "Scroll and Klikk from the Main categories above";
		curSel="0";
		var myAjax = new Ajax.Updater('ProductListing',current_file,
				{method: 'get', parameters:'sort='+sorty+'&imgsize='+imgsize+'&catid='+catid+'&prodperpage='+prodperpage+'&pgnumber='+pgnumber+'&show='+showy} );	
		catSel="0";
		update_history=setTimeout('search_updatehistory("'+searchstring+'")',1500);
	}	
}

function sndReq(searchstring){
	if(current_file == "/index.php"){
		pageTracker._trackPageview('search/searchstring/'+searchstring);
		document.getElementById('WaitMessage').style.visibility="visible";
		if(curSel!="0"){changeSel(curSel)};
		curSel="0";
		catid='home';
		var myAjax = new Ajax.Updater('ProductListing',current_file,
						{method: 'get', parameters:'sort=search&imgsize='+imgsize+'&catid=search&prodperpage='+prodperpage+'&pgnumber='+pgnumber+'&show='+showy+'&searchstring='+searchstring+'&categshow='+categshow+'&prodshow='+prodshow,
						onComplete: function(){
										resize_topban();
										var myAjax = new Ajax.Updater('CategoryList',current_file,
												{method: 'get', parameters:'action=draw_leftcatmenu&catid='+catid+'&supercatid='+curSel} );
										}} );	
	}else{
		window.location.href='/index.php?searchstring='+searchstring;
	}
}

function searchCatClick(cat_id, name){
	pgnumber=1;
	document.getElementById('WaitMessage').style.visibility="visible";
	catid=cat_id;
	name_adj=name.replace(/&/g,'-AND-',name);
	var myAjax = new Ajax.Updater('ProductListing','index.php', 
				{method: 'get', parameters:'sort='+sorty+'&imgsize='+imgsize+'&catid='+catid+'&prodperpage='+prodperpage+'&pgnumber='+pgnumber+'&catname='+name_adj+'&show='+showy, 
				onComplete:function(){
										//document.getElementById('SuperCatInfo').innerHTML = "This is the selection of products in the Category chosen";
										document.getElementById('CatSelected').style.marginTop="0";
										catSel=cat_id;
										//document.getElementById('Cat_Cat').style.visibility="visible";
										//document.getElementById('Cat_Cat').innerHTML = name;
										document.getElementById('WaitMessage').style.visibility="hidden";
										}
			});	
}

function changeSel(id){
	categImage = "SuperCateg_"+id;
	categText = "SuperCategText_"+id;
	document.getElementById(categText).style.textDecoration = "none";
	document.getElementById(categText).style.backgroundColor="";
	document.getElementById(categImage).style.backgroundColor = "";
	document.getElementById(categText).style.color = "#000000";
	//document.getElementById(categText).style.fontSize = "11px";
	document.getElementById(categText).style.fontWeight = "bold";
}