function collapse(row){
	bar = document.getElementById('id' + row);
	img = document.images['img' + row];
	if (bar.style.display=='none'){
		bar.style.display='block';
		img.src='../images/block.gif';			
	} 
	else {
		bar.style.display='none';
		img.src='../images/none.gif';			
	}
}
//
function collapse_all(num,task){
	for (i=0;i<num;i++){
		if (document.getElementById('id' + i)){
			document.getElementById('id' + i).style.display=task;
			document.images['img' + i].src='../images/' + task + '.gif';
		}
	}
}
//
function rollover(row){
	img = document.images['img' + row];
	img_split = img.src.split('/');
	image = img_split[4];
	switch(image){
	case "none.gif":
		img.src='../images/none2.gif';
		break
	case "none2.gif":
		img.src='../images/none.gif';
		break
	case "block.gif":
		img.src='../images/block2.gif';
		break
	case "block2.gif":
		img.src='../images/block.gif';
		break
	}
}
//
function combo (row,trig){
	var vars = row.split("_");
	var	pair = new Array(row,trig);
	var newpair = 'yes';
	//make sure it has already been clicked and recorded in the pairs array
	for (q=0;q<pairs.length;q++){
		if ((pairs[q][0]==row && pairs[q][1]==trig) || vars[1]==''){
			newpair = 'no';
			break;
		}
	}
	if (newpair=='yes'){
		pairs[pairs.length]=pair;
		num=document.orderbox.elements['i'+vars[1]].length+2;
		for(i=1;i<num;i++){
			document.getElementById('r_'+vars[1]+'_'+(vars[2]*1+i)).style.display="";
			if (i==1){
				document.getElementById('i_'+vars[1]+'_'+(vars[2]*1+2)).checked=true;
			}
		}
	}
	else {
		for (q=0;q<pairs.length;q++){
			if(trig==pairs[q][1]){//you know it's not the trigger, but the trigger group-so hide sub options
				vars=pairs[q][0].split("_");
				num=document.orderbox.elements['i'+vars[1]].length+2;
				for(i=1;i<num;i++){
					document.getElementById('r_'+vars[1]+'_'+(vars[2]*1+i)).style.display="none";
					document.getElementById('i_'+vars[1]+'_'+(vars[2]*1+2)).checked=false;
				}
				pairs.splice(q,1);
				for (h=0;h<pairs.length;h++){
					j=pairs[h][1].split("i");
					if (vars[1]==j[1]){
						combo(pairs[h][0],pairs[h][1]);
					}
				}
				break;
			}
		}
	}
}

function ob() {
	trscan();	
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Today's Date 
function todaydate(){
	var months=new Array(13);
	months[1]="January";
	months[2]="February";
	months[3]="March";
	months[4]="April";
	months[5]="May";
	months[6]="June";
	months[7]="July";
	months[8]="August";
	months[9]="September";
	months[10]="October";
	months[11]="November";
	months[12]="December";
	
	var time=new Date();
	var lmonth=months[time.getMonth() + 1];
	var date=time.getDate();
	var year=time.getYear();
	
	if ((navigator.appName == "Microsoft Internet Explorer") && (year < 2000)){ 
		year="19" + year; 
	}
	if (navigator.appName == "Netscape"){
		year=1900 + year;
	}
	var d = lmonth + " " + date + ", " + year;
	return d;
}
//image swamp******************************************************************************************
function imageswap(img,id){
	var image = img.src;
	var image_name = image.substring(0,image.length-4);
	var image_ext = image.substring(image.length-4,image.length);
	if (id == 1){
		if (document.getElementById('bigimg').style.display=='none'){
			document.images.bigimg.src = image_name+'-b'+image_ext;
			document.getElementById('bigimg').style.display='block';
			document.getElementById('litimg').innerHTML='&laquo;click to hide big image&raquo;'
		}
		else {
			document.getElementById('bigimg').style.display='none';
			document.getElementById('litimg').innerHTML='&laquo;click image to enlarge&raquo;'
		}
	}
	else {
		if (image_name.substring(image_name.length-2,image_name.length)=='-b'){
			img.src = image_name.substring(0,image_name.length-2) + image_ext;
		}
		else {
			img.src = image_name + '-b' + image_ext;
		}
	}
}
//tab mouseovers**************************************************************************************
function tab_over(tab){
	for (i=1;i<10;i++){//tab_out any existing tabs.
		if(document.getElementById('tab'+ i) && document.getElementById('tab'+ i).style.height=='27px'){
			tab_out(document.getElementById('tab'+ i));
			break;
		}
	}
	tab.style.height='27px';
	tab.style.marginTop='0';
}
function tab_out(tab){
	tab.style.height='20px';
	tab.style.marginTop='7px';
}
function tabset(tab,act,num){
	switch (act){
		case "expand_all":
			for (x=1;x<=num;x++){
				if (document.getElementById('tab'+ x).style.color=='#999999' || document.getElementById('tab'+ x).style.color=='rgb(153, 153, 153)'){
					continue;
				}
				document.getElementById('tab_'+ x).style.display='block';
				document.getElementById('tab'+ x).style.visibility ='hidden';
			}
			document.getElementById('exp_id').style.display='none';
			document.getElementById('col_id').style.display='block';
			break;
		case "collapse_all":
			for (x=2;x<=num;x++){
				document.getElementById('tab_'+ x).style.display='none';
				document.getElementById('tab'+ x).style.visibility ='visible';			
			}
			document.getElementById('tab_1').style.display='block';
			document.getElementById('tab1').style.visibility ='visible';			
			document.getElementById('col_id').style.display='none';
			document.getElementById('exp_id').style.display='block';
			break;
		default://front
			if (document.getElementById('tab'+ tab).style.color=='#999999' || document.getElementById('tab'+ tab).style.color=='rgb(153, 153, 153)'){
				return false;
			}
			for (x=1;x<=num;x++){
				document.getElementById('tab_'+ x).style.display='none';
				//document.getElementById('tab'+ x).style.color='#000000';	
				document.getElementById('tab' + x).style.height='20px';
			}
			if (tab==5){
				document.getElementById('kbase').src='../kbase/knowbase2.cfm?term=' + prodid.split('-L')[0] + '&filter=all&sortbox=order by custom2 desc';
			}
			document.getElementById('tab_' + tab).style.display='block';
			document.getElementById('tab'+ tab).style.height='27px';
			document.getElementById('tab'+ tab).style.marginTop='0';
			//document.getElementById('tab'+ tab).style.color='#000066';	
		}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Search Product Index
function menu_search(form,str,menu){
	search_string = str.toUpperCase();
	text_length = search_string.length;	
	var i=menu.options.length;
	var e=0;
	do {
		test_item = menu.options[e].text;
		match_item = test_item.substr(0, text_length).toUpperCase();
  		
		if(search_string == match_item){
			menu.selectedIndex = e;
			break;
		}
	e++;
	}
	while (--i);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Find element's position
function whoseesthis(par,dv){
	var tar = document.getElementById(dv);
	if (tar.style.display=='none'){
		tar.style.display='block';
		//alert('top= ' + findPosY2(par));
		//alert('left= ' + findPosX2(par));
		tar.style.left=findPosX2(par) + 'px';
		tar.style.top=findPosY2(par)+15 + 'px';
	}
/*	else {
		tar.style.display='none';
	}
*/}
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x){
		curleft += obj.x;
	}
	return curleft;
}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y){
		curtop += obj.y;
	}
	return curtop;
}

function findPosX2(obj){
	curleft = obj.offsetLeft
	return curleft;
}

function findPosY2(obj){
	curtop = obj.offsetTop
	return curtop;
}
