
var rate;



	function frmtCurrency(ele,symb,val,code,cls) {
		// round the currency to the nearest .05
		val *= 2.0;
		val = val.toFixed(1) / 2.0;
		val = val.toFixed(2);
		// build the text in the form: '$' '12.35' 'USD'
		ele.text(symb+val+code );
		// add the currency code to the element class.
		ele.addClass(cls);
	};


 $(document).ready(function() {
   
       $('a[href*=#]').click(function() {
    
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
        
            var $target = $(this.hash);
            
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            
            if ($target.length) {
            
                var targetOffset = $target.offset().top;
                
                $('html,body').animate({scrollTop: targetOffset}, 1000);
                    
                return false;
                
            }
            
        }
        
    });
   
   
   $('.currency').each(function(index) {
    $(this).attr('rel',$(this).text());
    $(this).html($(this).text() + "&nbsp;Frs");
  });
   
      $('.currency').each(function(index) {
  });
  
  
  $(".currencyPicker").change(
		function ()
		{
			var currTo=$(this).val();
			var currSign=$(this).children("option:selected").attr("title");
			var currFrom="XPF"
			if(currTo==currFrom)
				{
					$('.currency').show('highlight',1500);
					$('.currency').each(function(index) {
						$(this).html($(this).attr('rel') + "&nbsp;"+ currSign);
					});
				}
		
			else{
				$.ajax(
					   { 
					   url: "currency-ajax.php?"+"action=rate" + "&currfrom=" + currFrom + "&currto=" + currTo, 
					   context: document.body, success: function(rate){
							$('.currency').show('highlight',1500);
							$('.currency').each(function(index) {
								$(this).html(Math.round(rate*parseFloat($(this).attr('rel'))) + "&nbsp;"+ currSign);
								});
							}
						});
				}
			
			$('.currencyPicker').each(function(index) {
						$(this).val(currTo);
					});
					
			
$(".contactuslink").colorbox({iframe:true, innerWidth:830, innerHeight:400});
					
		});
		
   
 });
