curid='';
pcurid=''; 
var panels = ["crosley","frankart","record","radio","goldrecord"];

W_STANDARD = 165;
W_THIN = 80;
W_WIDE = 501;
W_PRODUCT = 600;

$(document).ready(function(){
	for(i=0; i<panels.length; i++) {
		panel = panels[i] + 'lnk';
		document.getElementById(panel).style.width=W_STANDARD+'px';
	}
	
	$("a#crosleylnk").hover(function() { over("crosley"); }, function() {off("crosley");});
	$("a#frankartlnk").hover(function() { over("frankart"); }, function() {off("frankart");});
	$("a#recordlnk").hover(function() { over("record"); }, function() {off("record");});
	$("a#radiolnk").hover(function() { over("radio"); }, function() {off("radio");});
	$("a#goldrecordlnk").hover(function() { over("goldrecord"); }, function() {off("goldrecord");});
	if (navigator.userAgent.search(/msie 8/i)== -1) {
		document.getElementById('producttxt').style.width='0px';
		$("a#productlnk").hover(function() { over("product"); }, function() {off("product");});
	}
});

function over(str) {
	if(str=="product") {
		pcurid=str;
		resizep(true);
	}
	else {
		curid=str;
		el=document.getElementById(str+'lnk');
		el.style.width=(parseInt(el.style.width)-4)+'px'; 
		resize(el.id, true);
	}
}

function off(str) {
	if(str=="product") {
		pcurid=''; 
		resizep(false);
	}
	else {
		curid=''; 
		el=document.getElementById(str+'lnk');
		el.style.width=(parseInt(el.style.width)+4)+'px'; 
		resize('', false);
	}
}

	
	function min(a,b) {
		if (a<b) return a;
		return b;
	}
	
	function max(a,b) {
		if (a>b) return a;
		return b;
	}
	
	function resize(el, first) {
		delay = 10;
		document.getElementById('crosleytxt').style.display='none';
		document.getElementById('frankarttxt').style.display='none';
		document.getElementById('recordtxt').style.display='none';
		document.getElementById('radiotxt').style.display='none';
		document.getElementById('goldrecordtxt').style.display='none';
		var loop = 0;
		if(curid!='') {
			if(el==curid+'lnk' && parseInt(document.getElementById(el).style.width)<W_WIDE) {
				var take=0;
				while(take < 20) {
					var temp = take;
					for(i=0; i<panels.length; i++) {
						if(panels[i]+'lnk'!=el && parseInt(document.getElementById(panels[i]+'lnk').style.width)>W_THIN) {
							totake=min(5, parseInt(document.getElementById(panels[i]+'lnk').style.width)-W_THIN);
							document.getElementById(panels[i]+'lnk').style.width = (parseInt(document.getElementById(panels[i]+'lnk').style.width)-totake)+'px';
							take = take + totake;
						}
					}
					if(temp==take)
						break;
				}
				loop=take;
				document.getElementById(el).style.width = min(W_WIDE,(parseInt(document.getElementById(el).style.width)+take))+'px';
			}
			
		}
		else {
			delay = 2;
			var take=0;
			for(i=0; i<panels.length; i++) {
				if(parseInt(document.getElementById(panels[i]+'lnk').style.width)>W_STANDARD) {
						totake=min(20, parseInt(document.getElementById(panels[i]+'lnk').style.width)-W_STANDARD);
						document.getElementById(panels[i]+'lnk').style.width = (parseInt(document.getElementById(panels[i]+'lnk').style.width)-totake)+'px';
						take = take + totake;
				}
			}
			loop=take;
			temp=0;
			while(take > 0) {
				temp=take;
				for(i=0; i<panels.length; i++) {
					if(parseInt(document.getElementById(panels[i]+'lnk').style.width)<W_STANDARD) {
						document.getElementById(panels[i]+'lnk').style.width = (parseInt(document.getElementById(panels[i]+'lnk').style.width)+1)+'px';
						take=take-1;
					}
				}
				if(temp==take)
					break;
			}
		}
		if(loop == 0 && el==curid) {
			for(i=0; i<panels.length; i++) {
				if(parseInt(document.getElementById(panels[i]+'lnk').style.width)!=W_STANDARD) {
					document.getElementById(panels[i]+'lnk').style.width = W_STANDARD+'px';
					take=take-1;
				}
			}
		}
		if(loop > 0 && (el==curid || el==curid+'lnk')) 
			setTimeout("resize('"+el+"', true)",delay);
		else if(curid!='')
			document.getElementById(curid+'txt').style.display='block';
	}
	
	function resizep(opening) {
		loop=false;
		if(opening && pcurid=="product") {
			if(parseInt(document.getElementById('producttxt').style.width)!=W_PRODUCT) {
				temp = min(W_PRODUCT,(parseInt(document.getElementById('producttxt').style.width)+25));
				if(temp != parseInt(document.getElementById('producttxt').style.width)) {
					document.getElementById('producttxt').style.width = temp + 'px';
					loop = true;
				}
				document.getElementById('producttxt').style.height = "112px";
			}
		}
		else {
			if(parseInt(document.getElementById('producttxt').style.width)!=0) {
				temp = max(0,(parseInt(document.getElementById('producttxt').style.width)-25));
				if(temp != parseInt(document.getElementById('producttxt').style.width)) {
					document.getElementById('producttxt').style.width = temp + 'px';
					loop = true;
				}
				document.getElementById('producttxt').style.height = "116px";
			}
		}
		if(parseInt(document.getElementById('producttxt').style.width)==0)
			document.getElementById('producttxt').style.display='none';
		else if(parseInt(document.getElementById('producttxt').style.width)==W_PRODUCT) {
			document.getElementById('producttxt2').style.display='block';
		}
		else {
			document.getElementById('producttxt').style.display='block';
			document.getElementById('producttxt2').style.display='none';
		}
		if(opening && loop) {
			setTimeout("resizep(true)",10);
		}
		if(!opening && loop) {
			setTimeout("resizep(false)",10);
		}
	}