function swap_img(element, tid)
{
	if(document.getElementById('width_'+tid))
	{
		if(document.getElementById('width_'+tid).value == 'true')
		{
			if(document.getElementById('tempsize').value == 'height')
			{
				/*var tdele = document.getElementById('imgtab');*/
				/*tdele.align = 'left';*/				
				document.getElementById('firsttd').align = 'center';
				document.getElementById('imgtab').align = 'left';
				document.getElementById('selprodimg').align = 'left';

				
				var row = document.getElementById('prodviewtab').insertRow(3);
				var cell= row.insertCell(0);
				var thumbcontent = document.getElementById('thumbimg').innerHTML;
				//cell.setAttribute("id", "thumbimg");
				cell.align = 'center';
				
				if(document.all)
				{
					thumbcontent = str_replace('MARGIN-TOP: 6px;', 'MARGIN-TOP: 0px;', thumbcontent);
					thumbcontent = str_replace('MARGIN-LEFT: 0px;', 'MARGIN-LEFT: 6.5px;', thumbcontent);
					thumbcontent = str_replace('CLEAR: both', 'FLOAT: left', thumbcontent);
				}
				else
				{
					thumbcontent = str_replace('margin-top: 6px;', 'margin-top: 0px;', thumbcontent);
					thumbcontent = str_replace('margin-left: 0px;', 'margin-left: 6.5px;', thumbcontent);
					thumbcontent = str_replace('clear: both', 'float: left', thumbcontent);
				}
								
				cell.innerHTML = '<div id="thumbimg" style="width:498px">'+thumbcontent+'</div>';
				var row = document.getElementById('mainimage');

				row.deleteCell(1);
				row.deleteCell(1);
				/*row.deleteCell(1);*/
				
				document.getElementById('tempsize').value = 'width';
			}
		}
		else
		{
			if(document.getElementById('tempsize').value == 'width')
			{
				document.getElementById('firsttd').align = 'center';
				document.getElementById('imgtab').align = 'center';
				
				var row = document.getElementById('mainimage');
				var cell = row.insertCell(1);
				cell.width= '20';
				cell.innerHTML = '&nbsp;';
				
				//right cell
				var cell = row.insertCell(2);
				cell.width= '95';
				cell.vAlign= 'top';
				var thumbcontent = document.getElementById('thumbimg').innerHTML;
				cell.setAttribute("id", "thumbimg")
				
				if(document.all)
				{
					thumbcontent = str_replace('MARGIN-TOP: 0px;', 'MARGIN-TOP: 6px;', thumbcontent);
					thumbcontent = str_replace('MARGIN-LEFT: 6.5px;', 'MARGIN-LEFT: 0px;', thumbcontent);
					thumbcontent = str_replace('FLOAT: left;', 'CLEAR: both;', thumbcontent);
				}
				else
				{
					thumbcontent = str_replace('margin-top: 0px;', 'margin-top: 6px;', thumbcontent);
					thumbcontent = str_replace('margin-left: 6.5px;', 'margin-left: 0px;', thumbcontent);
					thumbcontent = str_replace('float: left;', 'clear: both;', thumbcontent);
				}
				
				cell.innerHTML = thumbcontent;
				document.getElementById('prodviewtab').deleteRow(3);
				
				/*var cell = row.insertCell(3);
				cell.width= '40';
				cell.innerHTML = '&nbsp;';*/
				
				document.getElementById('tempsize').value = 'height';
			}
		}
		
	}
	
	element = document.getElementById(element);
	var el = element.getElementsByTagName('IMG');
	if(el[0])
	{
		var e = el[0];
		var newsrc = e.src;
		var newurl = newsrc.substr(0, strrpos(newsrc, '/')+1);
		var newimg = newsrc.substr(strrpos(newsrc, '/')+2);
	}
	
	var curesrc = document.getElementById('productimg').src;
	var cururl = curesrc.substr(0, strrpos(curesrc, '/')+1);
	var curimg = curesrc.substr(strrpos(curesrc, '/')+1);
	
	//11 pics
	if(document.getElementById('11_'+curimg))
	{
		document.getElementById('11_'+curimg).style.display = 'none';
	}
	
	if(document.getElementById('11_'+newimg))
	{
		document.getElementById('11_'+newimg).style.display = 'inline';
	}
	//end 11 pics
	
	//big pics
	if(document.getElementById('extended_'+curimg))
	{
		document.getElementById('extended_'+curimg).style.display = 'none';
	}
	
	if(document.getElementById('extended_'+newimg))
	{
		document.getElementById('extended_'+newimg).style.display = 'inline';
	}
	//end big pics
	
	var newurl = cururl+newimg;
	//alert(newurl);
	document.getElementById('productimg').src = newurl;
}

function PICextend(pic, x, y)
{
	x = parseInt(x);
	y = parseInt(y);
	//alert(x+' => '+y+' avail: '+screen.availWidth+' => '+screen.availHeight);
	if(x >= screen.availWidth || y >= (screen.availHeight-90))
	{
		if(x >= screen.availWidth)
		{
			y = Math.round((y/x)*(screen.availWidth-100));
			x = (screen.availWidth-100);
		}
		
		if(y >= (screen.availHeight-90))
		{
			x = Math.round((x/y)*(screen.availHeight-100));
			y = (screen.availHeight-100);
		}
		/*
		var ratio_x = (y/x);
		var ratio_y = (x/y);
		x = Math.round(x-(80*ratio_x));
		y = Math.round(y-(80*ratio_y));*/
	}
	//alert(x+' => '+y);
	window_open('/show11?img='+pic+'&x='+x+'&y='+y, x-4, y, 'bigger');
}

function m11(pic, x, y)
{
	//alert(screen.width+' X '+screen.height);
	window_open('/show11?img='+pic, x-18, y, 'oneone');
}

function doCalcStaff(){
	window.setTimeout('calcStaff();', 300);
}

function calcStaff(){
	var val = document.getElementById('amount').value;
	if(!IsNumeric(val)){
		val = 1;
	}
	var el = document.getElementsByTagName('SPAN');
	var price = null;
	var lastnumber = 0;
	for(var i = 0; i < el.length; i++){
		if(el[i].getAttribute('id')){
			var spanid = el[i].getAttribute('id');
			if(spanid.substr(0, 7) == 'amount_'){
				var number = parseFloat(spanid.substr(7));
				if(number <= val && lastnumber <= number){
					price = el[i].innerHTML;
					lastnumber = number;
				}
			}
		}
	}
	if(price){
		document.getElementById('currentProductPrice').innerHTML = price;
	}
}
