
function options_price($product,$n,$currency_code,$photo) {
    if($photo){
		   show_option_photo($photo);
		}
		
		return true;
		
    $options=new Array();
    for($i=1;$i<=$n;$i++) {
       $opt_str="option-"+$i;
		   $this_opt=document.getElementById($opt_str);
		   if(!$this_opt) { continue; }
		   $options[$i-1]=$this_opt.value;
		}
		if(!$options.length){$options[0]=0;}
		if($options.length) {
		   $opts=$options.sort();
       $url=ROOTURL+'inc/ajax/options_price.php?product='+$product+'&option='+$opts.join(",")+'&code='+$currency_code;
       ajax_do(ajax_init(),$url,change_price,'GET');
    }
}

//change the price on page
function change_price($xh_obj) {
   $response=$xh_obj.responseXML.documentElement;
   price=$response.getElementsByTagName('price')[0].firstChild.data;
   stock=$response.getElementsByTagName('stock')[0].firstChild.data;
   document.getElementById('totalprice').firstChild.nodeValue=price;
   $btn=document.getElementById('basket_button');
   $status=document.getElementById('availability');
	 if(stock==0){
	    $btn.style.display='none';
			$status.className='invalid';
			$status.firstChild.nodeValue='Item out of stock';
   }else{
	    $btn.style.display='block';
			$status.className='valid';
			$status.firstChild.nodeValue='Item in stock';
	 }
   document.getElementById("quantity").value=1;
}

function show_option_photo($photo){
   $url=ROOTURL+'inc/ajax/change_product_photo.php?photo='+$photo;
   ajax_do(ajax_init(),$url,change_product_photo,'GET');
}
function change_product_photo($xh_obj){
   $response=$xh_obj.responseText;
	 if($response=='<div></div>')return true;
	 document.getElementById('ajaxproductinsert').innerHTML=$response;
	 trigger_img_zoomer();
}

function trigger_img_zoomer() {
$(document).ready(function(){

	$("div#image_frame").imgZoomer({
		zoom_button: "img#zoom_button",
		zoom_in: "img/zoom_in.png",
		zoom_out: "img/zoom_out.png"
	});
	
	$("a.thumb").imgZoomerThumbs({});
	
	$("a.thumb:first").click();
	
});
}
