function play() 
{
	var f=document.getElementById("myFlash");
	f.SetVariable("method:setUrl", "test3.mp3");
	f.SetVariable("method:play", "");
	  myvol(35);
}

function format_price(val)
{ return formatCurrency(val);
/*	var temp=parseInt(val).toString();
	if(temp.length>3)
	{
		var temp2='';
		for(i=temp.length-3;i>0;i=i-3)
		{
			if(temp2=='') 
				temp2=temp.substr(i,3);
			else
				temp2=temp.substr(i,3)+','+temp2;
		}
		if(i<=0)
		{
			i=i+3;
			temp2=temp.substr(0,i)+','+temp2;
		}
		return temp2;
	}
	return temp;
//	alert(temp2);
*/
}

function loadHTML(URL, onSuccess){
  if (document.getElementById) {
    var http = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
  }
  if (http) {
    http.onreadystatechange = function() {
      if (http.readyState == 4 && http.status == 200) {
        //el = document.getElementById(resp_id);
        //el.innerHTML = http.responseText;
        if(onSuccess!==undefined){
        	onSuccess(http.responseText);
        }
      }
    }
    http.open("GET", URL, true);
    //http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    http.send(null);
  }
	
/*	if(window.XMLHttpRequest)
	{
    	request = new XMLHttpRequest();
    //request.onreadystatechange = processStateChange;
    	request.open("GET", URL, true);
    	request.send(null);
  	}
*/
}

function checkout_del(ch_id){

//	loadHTML(CheckOutURL+ch_id,function (a){alert(' test: '+a);});
	
	CheckOutCount--;
	if(CheckOutCount>0)
	{
		document.getElementById("ch_"+ch_id).className='hide';
		CheckOutTotal=CheckOutTotal-CheckOutPrice[ch_id];
		document.getElementById("ch_total").innerHTML=format_price(CheckOutTotal);
		document.getElementById("ch_count").innerHTML=CheckOutCount;
		document.getElementById("ch_count2").innerHTML=CheckOutCount;
//		alert(CheckOutURL+ch_id);
		loadHTML(CheckOutURL+ch_id);
	}else
	{
		loadHTML(CheckOutURL+ch_id);
		document.getElementById("accord-chk").className='hide';
		document.getElementById("empty_cart").className='';
		document.getElementById("shopping_bag").className='';
	}
}

function myvol(volume) 
{
	var f=document.getElementById("myFlash");
	f.SetVariable("method:setVolume", volume);
}
			
function init_slider()
{
  mySlider2 = new Bs_Slider();
  mySlider2.attachOnChange(bsSliderChange);
  mySlider2.direction     = 1;
  mySlider2.width         = 16;
  mySlider2.height        = 50;
  mySlider2.minVal        = 0;
  mySlider2.maxVal        = 49;
  mySlider2.valueInterval = 1;
  mySlider2.valueDefault  = 49;
  mySlider2.imgDir   = '/work/img/volume/';
  mySlider2.setSliderIcon('winampVerticalKnob.gif', 26, 12);
  mySlider2.useInputField = 0;
  mySlider2.styleValueFieldClass = 'sliderInput';
  mySlider2.drawInto('sliderDiv2');
  mySliderSound = new Bs_Slider();
  mySliderSound.attachOnChange(bsSliderChangeSound);
  mySliderSound.direction     = 1;
  mySliderSound.width         = 16;
  mySliderSound.height        = 50;
  mySliderSound.minVal        = 0;
  mySliderSound.maxVal        = 99;
  mySliderSound.valueInterval = 1;
  mySliderSound.valueDefault  = 0;
  mySliderSound.imgDir   = '/work/img/volume/';
  mySliderSound.setSliderIcon('winampVerticalKnob.gif', 26, 12);
  mySliderSound.useInputField = 0;
  mySliderSound.styleValueFieldClass = 'sliderInput';
  mySliderSound.drawInto('sliderDivSound');
}
function bsSliderChange(sliderObj, val, newPos)
{
  copyspeed = 50-val;
}

function bsSliderChangeSound(sliderObj, val, newPos)
{ 
  myvol(99-val);
}
	
function myswaphoto(ph1)
{
	var img = document.getElementById('myimage'+globalPhoto);
	img.style.display='none';	
	img.style.visibility='hidden';
	var div = document.getElementById('myimagediv'+globalPhoto);
	div.style.display='none';	
	div.style.visibility='hidden';

	var img2 = document.getElementById('myimage'+ph1);
	var div2 = document.getElementById('myimagediv'+ph1);
	div2.style.top='150px';
	div2.style.position='absolute';
	div2.style.display='';
	div2.style.visibility='visible';
	img2.style.display='';
	img2.style.visibility='visible';
	globalPhoto=ph1;	
}

function del_prod(item)
{
	total=total-PriceProd[item];
	a=document.getElementById('myTotal');
  	a.innerHTML=format_price(total);
}
function add_prod(item)
{
	total=total+PriceProd[item];
	a=document.getElementById('myTotal');
  	a.innerHTML=format_price(total);
}
	
function myScr2Move(dir,layer)
{
	var myWidth=76;
	if(layer=='scr2')
	{
		Scr2Pos=globalScr2Pos;
		Scr2Max=globalScr2Max;
	}
	else
	{
		Scr2Pos=globalScr2PosV;
		Scr2Max=globalScr2MaxV;
	}
	Scr2Pos+=dir;
	if(dir>0 && Scr2Pos>Scr2Max)
	{
  		dw_scrollObj.moveTo(layer,0,0);
		Scr2Pos=1;
	}
	if(dir<0 && Scr2Pos<0)
	{
  		dw_scrollObj.moveTo(layer,-Scr2Max*myWidth,0);
		Scr2Pos=Scr2Max-1;
	}
	dw_scrollObj.scrollTo(layer, Scr2Pos*myWidth,0);
	if(layer=='scr2')
	{
		globalScr2Pos=Scr2Pos;
		globalScr2Max=Scr2Max;
	}
	else
	{
		globalScr2PosV=Scr2Pos;
		globalScr2MaxV=Scr2Max;
	}

}



//allows $, int, % format
function numFormat(num, format){
	switch(format){
		case '$': return formatCurrency(num);
		case '%': return formatPerc(num);
		case 'int': return Math.floor(num);
		default:	return num;
	}
}

function formatCurrency(num) {
    if(isNaN(num)) return '';
    if(num==Infinity) return '';
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '' + num + '.' + cents);
}
function formatPerc(num) {
    if(isNaN(num)) return '';
    if(num==Infinity) return '';
//	num = num.toString().replace(/%|\,/g,'');
	num=num*1.00;//00.0;
	if(isNaN(num))	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '' + num + '.' + cents+'%');
}



