var t;
var doLoop = true;
function scroll_left(){

var div = document.getElementById('contentscroll');
if (div.scrollLeft>0  && doLoop){
div.scrollLeft-=1; //scroll 1 pixel up
t = setTimeout('scroll_left()', 1);
}
else clearTimeout(t);
}

function scroll_right(){

var div = document.getElementById('contentscroll');
if (div.scrollLeft<10000000000 && doLoop){
div.scrollLeft+=1; //scroll 1 pixel up
t = setTimeout('scroll_right()', 1);
}
else clearTimeout(t);
}

function stop()
{
	doLoop = false;
	setTimeout('doLoop = true;', 5);
}



function PopupPic(sPicURL, id, which) { 
     window.open( "popup.php?image="+sPicURL+"&id="+id+"&which="+which, "popup",  
     "resizable=1,HEIGHT=200,WIDTH=200"); 
   } 
   
function PopupPic2(sPicURL, id, which) { 
     window.open( "popup2.php?image="+sPicURL+"&id="+id+"&which="+which, "popup",  
     "resizable=1,HEIGHT=200,WIDTH=200"); 
   } 


function openWindow(URL, name, width, height) {
  var variables = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+width+",height="+height+",left=0,top=10";
  var newWindow = window.open(URL, name, variables);
}

function update_curr()
{
	var dropdown = document.getElementById('converter');
	if(dropdown)
	{
		var selIndex = dropdown.selectedIndex;
		var value = dropdown.options[selIndex].value;
		var i = 1;
		var curr_span;
		var price_span;
		var times_by;
		var new_value;
		var orig_value;
		
		while(i < 60)
		{
			curr_span = document.getElementById('curr_'+i);
			price_span = document.getElementById('price_'+i);
			price_orig = document.getElementById('price_orig_'+i);
			if(price_orig)
			{
			if(curr_span)
			{
				orig_curr = curr_span.innerHTML;
				curr_span.innerHTML = value;
			}
			if(price_span)
			{
				times_by = (1 / curr['USD']) * curr[value];
				orig_value = price_orig.value;
				new_value = orig_value * times_by;
				new_value = Math.round(new_value*100)/100;
				price_span.innerHTML = addCommas(new_value.toFixed(2));
			}
			}
			i++;	
		}
	}
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}
