//<script type="text/javascript">

// front page cycle
    
            $(document).ready(function(){
                    if (!$('.header_loop').length) {
                        return;
                    }
                    $('.header_loop').cycle({
                            fx:             'fade',
                            speedIn:        1500,  // speed of the 'in' transition
                            speedOut:   700,
                            delay:      150,
                            timeout:        0,
                            pager:          '.header_bottom:eq(0)',
                            pagerEvent:     'mouseover',
                            pagerAnchorBuilder: function(idx, slide) {
                                    return 'a.home:eq(' + (idx) + ')';
                            }
                    });
                    $(document).pngFix({blankgif: rootURL + 'images/blank.gif'});
             
            
            });
            
            // every page loop
  
            $(document).ready(function(){
                  
            
                if (document.getElementById('tweet')) {
                    
                    getTwitters('tweet', {
                      id: 'BGasia',
                      count: 5,
                      enableLinks: true,
                      ignoreReplies: true,
                      clearContents: true,
                      template: '%text%'
                    });
                  }
            
            });
 
 
 
 
     
     
function bloomgrow_add_previews () {
    
   /* CONFIG */
		
    var xOff = 10; // defaults
    var yOff= 10;// defaults
    var xOffset = 10;
    var yOffset = 30;
    var vAlign = 'top';
    var hAlign = 'left';
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
        hAlign = e.clientX > ($(window).width() / 2) ?  'left' : 'right';
        vAlign = e.clientY > ($(window).height() / 2) ? 'above' : 'below';
        
        
        xOffset = -100000;
        yOffset = -100000;
        
		var c =  "";
     //   console.log(e); 
        
		$("body").append("<p id='image-preview'><img id='image-preview-img' src='"+ this.t +"' alt='Image preview' />"+ c +"</p>");								 
		
        $("#image-preview").css('top',"-10000px").css('left',"-10000px");
        
        $("#image-preview-img").load( function() {
            xOffset = hAlign == 'left' ? -1 *(xOff + 300) : xOff;
            yOffset = vAlign == 'above' ?  -1 * (yOff + 300): yOff;
        
            
            //console.log('ready');
            $("#image-preview").css('top',(e.pageY + yOffset) + "px")
                .css('left',(e.pageX + xOffset) + "px")
                .fadeIn("fast");		
        });
         
		
    },
	function(){
		this.title = this.t;	
		$("#image-preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#image-preview")
			.css('top',(e.pageY + yOffset) + "px")
			.css('left',(e.pageX + xOffset) + "px");
	});		
 
}
 
 $(document).ready(bloomgrow_add_previews);
 
    // category page page player..
 
	var player = false;

	$(document).ready(function(){
        if (!$('.cate').length) {
            return;
        }
        if ($('.select_brand_top').length) {
            return;
        }
        
		$('.cate').click(function(){
			var obj = this;
			
			
			$.blockUI({
				message: '<p style="margin:3px 0px 2px 0px;"></p><br clear="all" /><p style="margin:2px 0px 3px 0px;"><img src="images/ajax-loader.gif" alt="Loading..." title="Loading..." /></p>',
				css: {
					color: '#000000',
					'font-size': '12px',
					padding: '10px 3px',
					opacity: 0.5
				}
			});		
			
			var data = {
				mode:		'categoryData',
				id:	    $(this).attr('name')	
			};
	
			$.ajax({
				url:		baseURL + '/CategoryData',
				data:		data,
				type:		'POST',
				timeout:	12000,
				dataType:	'json',
				success:	function(jData, textStatus){
					//alert(jData.message);
					$('#content').html(jData.message);
					$('.pro_sub').addClass("ulhide");
			
					$('#cate-' + data.id ).next().removeClass("ulhide");				
					bloomgrow_add_previews();
					if (jData.video ) {
						player = flowplayer("player2", rootURL  + "/flowplayer/flowplayer-3.1.5.swf",
						{
						    clip: {
							    url : rootURL + '/product/video/' + jData.video,
							 autoPlay: true,
							autoBuffering: true,
							provider:'http'

						    }  
						});
						
						 
					}
					
					
					$.unblockUI();
				},
				error:		function(XMLHttpRequest, textStatus, errorThrown){
					$.unblockUI();
					
				}
			});			
					  
							  
		});			
	});
    
    // product page..
    
    

	$(document).ready(function(){
        
        
        if($('#product_player').length) {
          
            player = flowplayer("product_player", rootURL  + "/flowplayer/flowplayer-3.1.5.swf",
            { 
            
                clip: { 
                        
                    onStart: function(clip) { 
                        var wrap = jQuery(this.getParent()); 
                        wrap.css({
                            width: clip.width, 
                            height: clip.height,
                            'margin-top': (( 322 - clip.height )/2).toString()+"px",
                            'background-color' : '#000'
                        }); 
                      }  
                },
                plugins: {                        
                    controls: 
                    {                                                     
                        autoHide: 'always'                                                  
                    }                                        
                }
                
            });
        
        }
         
		$(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});	
        
        
		 
		$('.smallimg').click(function(){
			$('#bigimage').attr('src', rootURL + '/phpThumb/phpThumb.php?src='+rootURL + '/' + $(this).attr('name') + '&w=322&h=322&zc=C');				  
			$('#product_player').slideUp(1800);
			$('#bigimage').slideDown(1800);		
			$('#large').attr('href',$(this).attr('name'));
		});
		$('#plr').click(function(){
								 
			$('#bigimage').slideUp(1800);		
			$('#product_player').slideDown(1800);
			
			if (player.getState() > 1) 
			{ 
				player.stop(); 
			} 
			player.play(rootURL + '/' +$('#videopath').val() );
			player.play(rootURL +'/' + $('#videopath').val() );
			
			return;
			
		});
		
	});
    
    // === stockist
    
    
    var sel_country = 0;
    
    
    $(document).ready(function(){
        if (!$('.stock-country').length) {
            return;
        }
        
        var stockist_fn = function() {
            $('#stockist_div').hide();
            $('#stockist_list').html('');
            $.ajax({
                url:		baseURL +'/Stockist.php',
                data:		{
                    country :  sel_country,
                    category : $(this).attr('name').split('-').pop()
                },
                type:		'POST',
                timeout:	12000,
                dataType:	'json',
                success:	function(jData, textStatus){
                    $('#stockist_div').slideDown(500);
                    var cd = $('#stockist_list');
                    cd.html('');
                    //console.log(jData);
                    for(var i = 0; i < jData.length; i++) {
                        var e = jData[i];
                        var title = $('<strong>');
                        title.text(e.name);
                        var content = $('<p>');
                        content.html(e.content);
                        var d = $('<div class="stockist_text_div">');
                        var htitle = $('<p class="stockist_bold_text">');
                        
                        d.append(htitle);
                        htitle.append(title);
                        d.append(content);
                        cd.append(d);
                    }
                    
                    
                }
            });

        };
        
        
		$('.stock-country').click(function(){
			
			$('#stockist_div').hide();
			//$('#stockist_div').html('');
			
			
			$('#brand_div').hide();
		//	$('#brand_div').html('');
			
			
			$('.stock-country').removeClass('first'); // remove first to all items.
			$(this).addClass('first'); // add it to selected..
            
			var obj = this;
			
            sel_country = $(this).attr('name').split('-').pop();
	
           
    
    
			$.ajax({
				url:		baseURL +'/Stockist.php',
				data:		{
                    country : sel_country
                },
				type:		'POST',
				timeout:	12000,
				dataType:	'json',
				success:	function(jData, textStatus){
					//alert(jData.message);
                    $('#brand_div').slideDown(500);
                    var cd = $('#brand_list');
                    cd.html('');
                   // console.log(jData);
                    for(var i = 0; i < jData.length; i++) {
                        var e= jData[i];
                        
                        var anode = jQuery('<a>')
                        anode.attr('href', "javascript:void(0)");
                        anode.attr('class', "stock-category");
                        anode.attr('name', 'category-' + e.id );
                        
                        var lnode = jQuery('<li>');
                         
                        
                        cd.append(lnode);
                        lnode.append(anode);
                        anode.text(e.uname);
                        
                        anode.click(stockist_fn);
                        
                           
                    }
                    //alert(cd.html());
                    
                    
					//$('#country_div').html(jData.message);
					//$('.pro_sub').addClass("ulhide");
					//$(obj).next().removeClass("ulhide");				
					
					//$.unblockUI();
				},
				error:		function(XMLHttpRequest, textStatus, errorThrown){
					//$.unblockUI();
					
				}
			});			
					  
							  
		});			
	});
    
    function htmlEncode(value){ 
        if (value) {
            return jQuery('<div/>').text(value).html(); 
        } else {
            return '';
        }
    }
    
	function openDiv(id)
	{
	 
		
		$('.country_list_div_text').removeClass('selec');
		$('#aaa'+id).addClass('selec');
		
		$('#stockist_div').slideUp(500);
		$('#stockist_div').html('');
		
		$('#stockist_div').html($('#'+id).html());
		$('#stockist_div').slideDown(500);
	}
 
    
    
    
    
    
    
    // used where???
	function setcss( obj , con)
	{
		$('.tab').removeClass("open");
		$(obj).addClass("open");
		
		var index = $('.tab').index(obj);
		$('.container').not('eq(' + index + ')').slideUp(800);
		$('.container:eq(' + index + ')').slideDown(800);
	}
    
    
    // google..
    

      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-19232843-1']);
      _gaq.push(['_setDomainName', 'none']);
      _gaq.push(['_setAllowLinker', true]);
      
      _gaq.push(['_trackPageview']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();

