/*
 * General config
 * By poppo 
 * E-Mail: pop@silvermover.com
 * 
 */
var rootFolder="/";
var $url="http://"+document.domain+rootFolder; // for page with Rewrite URL
var ar=[];
$(function(){
	
	$.event.add( window, "load", function(){
             // put preloader in here if send param with Array only
             preloadImages(bannerSlide);
				$.each(bannerSlide,function(i,v){
					//preloadImages(v);
                                        $('#slideBanner').append('<img src="' +$url+v+'" width="734" height="279"\/>');
                                        //ar[i]={'src':"'"+$url+v+"'" ,'dir':"'up'"};
					});
					
                                        $('#slideBanner').cycle({
                                            fx:'fade', // fx: shuffle , turnDown ,curtainX ,fade ,zoom  ,slideY
                                            //easing: 'bounceout',
                                            delay:-8000 });
                                        
                                        /*
                                        $('#slideBanner').crossSlide({
                                        speed: 45,
                                        fade: 1
                                      }, [ar]);
                                        */                                   
								
				} );
         $('#getNewMatherVedio').click(function(){
            
            vdoBox($url+'vdo/newMather/AVSEQ01.flv');
            return false;
        
        });
        $('#getRepairVideo').click(function(){
            
            vdoBox($url+'vdo/repair/AVSEQ01.flv');
            return false;
        
        });
        $('body').append('<div id="vdoDiv"><\/div>');
        $('#vdoDiv').hide();






/***********************for cart bucket*****************************/

            $('body').append('<div class="jqmWindow" id="viewCartBox">Please wait... <img src="' +$url+'images/lightbox-ico-loading.gif" alt="loading" \/><\/div>');
          $('#viewCartBox').jqm({ajax: $url+'jax.php?flag=viewCart', trigger: '#showCartLink',onShow:function(h){
             h.w.slideDown();
            },overlay:40});
          
          $('#viewCartBox .removeLink').live('click',function(){
                var id=$(this).attr('rel');
                if(confirm('Confirm to Remove product #'+id))
                {
                
                $('#viewCartBox').html('Please wait... <img src="' +$url+'images/lightbox-ico-loading.gif" alt="loading" \/>');
                $.getJSON($url+'jax.php',{flag:'removeCart',id:id},function(data){
			
                    $('#viewCartBox').html(data.remove).hide().fadeIn('slow');
                    $('#showMycart').fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
                        $('.center_cart').html(data.showTop).hide().fadeIn('slow');
                    });
                }
            return false;
          });
          
           $('.content .removeLink').live('click',function(){
                var id=$(this).attr('rel');
                if(confirm('Confirm to Remove product #'+id))
                {
                $('.content').html('Please wait... <img src="' +$url+'images/lightbox-ico-loading.gif" alt="loading" \/>');
                $.getJSON($url+'jax.php',{flag:'removeCartCheckOut',id:id,paypalButton:1},function(data){
                    $('.content').html(data.remove).hide().fadeIn('slow');
                    $('#showMycart').fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
                     $('.calculator').calculator({
    showOn: 'both', buttonImageOnly: true, buttonImage: $url+'images/calc_img.gif'}); 
			checkHiligh();
                     /*$('.lightBox2').lightBox();*/
                    });
                }
            return false;
          });
          
          $('#viewCartBox .updateModal').live('click',function(){
                
                var id=$(this).attr('title');
                var prevInput=$(this).prev('input');
                $('#viewCartBox').html('Please wait... <img src="' +$url+'images/lightbox-ico-loading.gif" alt="loading" \/>');
                $.getJSON($url+'jax.php',{flag:'updateCart',id:id,num:prevInput.val()},function(data){
                    $('#viewCartBox').html(data.update).hide().fadeIn('slow');
                    $('#showMycart').fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
                    $('.center_cart').html(data.showTop).hide().fadeIn('slow');
                    });
                return false;
            });
          
          $('.content .updateModal').live('click',function(){
                
                var id=$(this).attr('title');
                var prevInput=$(this).prev('input');
                $('.content').html('Please wait... <img src="' +$url+'images/lightbox-ico-loading.gif" alt="loading" \/>');
                $.getJSON($url+'jax.php',{flag:'updateCartCheckOut',id:id,num:prevInput.val(),paypalButton:1},function(data){
                    $('.content').html(data.update).hide().fadeIn('slow');
                    $('#showMycart').fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
                    checkHiligh();
                     $('.calculator').calculator({
    showOn: 'both', buttonImageOnly: true, buttonImage: $url+'images/calc_img.gif'}); 
                    });
                return false;
            });
          
          $('#closeJQM').live('click',function(){
                $('#viewCartBox').jqmHide();
                return false;
                });
          


$(".add2cart,.cartPacLink").click(function() {
	 		var val=$(this).attr('rel');
                        var num=$(this).parent().prev().find('input').val();$('body').scrollTo(1500);
				$(this).effect("transfer", { to: ".center_cart" }, 1000,function(){
                                        $.get($url+"jax.php",{flag:'shop',pro_id:val,num:1},function(data){
						$('.center_cart').html(data);
                                                //alert(data);
						$('#showMycart').fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
					});
                                        
				}); 
				return false;
			});


          $('.inputInModal , .showline input').live('keyup',function(e){
		$(this).val(this.value.replace(/[^0-9]/g, ""));
		if(e.which==13)
		{
			$(this).next('a').click();
		}
		});



	function checkHiligh()
	{
	  $('.checkOutTable>table:even').css({'background':'none'});	
		$('.listItem>li:even').css({'background':'#7F7F2E'}).hover(function(){$(this).css({'background':'none'});},function(){$(this).css({'background':'#7F7F2E'});});
		$('.listItem>li:odd').css({'background':'#525D1E'}).hover(function(){$(this).css({'background':'none'});},function(){$(this).css({'background':'#525D1E'});});
	}	
		checkHiligh();
		$('.lightBox').lightBox();


/***********************end cart backet*****************************/











}); // n doc
function preloadImages(args){
	if(document.images){
		if(!document.imageArray) document.imageArray = new Array();
		//var i,j = document.imageArray.length, args = preloadImages.arguments;
                var i,j = document.imageArray.length;
		for(i=0; i<args.length; i++){
			if (args[i].indexOf("#")!=0){
				document.imageArray[j] = new Image;document.imageArray[j++].src = args[i];
			}
		}
	}
	
} // n fnc
function hideObj(){
	$('embed, object, select').css({ 'visibility' : 'hidden' });
} //

function showObj(){
	$('embed, object, select').css({ 'visibility' : 'visible' });
} //

function vdoBox(path){
		$('embed, object, select').css({ 'visibility' : 'hidden' });scrollTo(0,0);
		$('#vdoDiv').fadeIn().css({'left': $(window).width() / 2 - ($('#vdoDiv').width() / 2), 'visibility' : 'visible','display':'block' });
		$('#vdoDiv').html('');
                $('#vdoDiv').html('<div id="vdoSkin"></div><br/><div id="mapClose"><a href="javascript:closeMap()"><img src="' + $url + 'images/lightbox-btn-close.gif" style="float:right;" /> </a></div>');
                $('#vdoSkin').flash({
		src:$url+'vdo/spa-video.swf' ,
		width:700 ,
		height: 600,
		//wmode:'transparent',
                flashvars: { video: path, skinPath: $url+'vdo/SteelExternalPlaySeekMute.swf' }

		});

	$('#flashVDO').css({ 'visibility' : 'visible' }).show();
	} // end function

function closeMap(){
	$('#vdoDiv').fadeOut();
	$('embed, object, select').css({ 'visibility' : 'visible' });
	$('#flashVDO').css({ 'visibility' : 'hidden' }).hide();
} //end func

var map;var marker;
	var trafficInfo;
	var toggleState = 1;
	function loadMap(Lat,Lng,zoom,contentInfo,div) {
		//if (GBrowserIsCompatible()){
			map = new GMap2(document.getElementById(div));
			 setZoom=zoom;
                          icon_ = new GIcon(); 
			    icon_.image = $url+'images/marker.gif';
			    icon_.shadow = $url+'images/marker_shadow.png';
			    icon_.iconSize = new GSize(32, 32);
			    icon_.shadowSize = new GSize(52, 35);
			    icon_.iconAnchor = new GPoint(6, 20);
			    icon_.infoWindowAnchor = new GPoint(20, 1);

			/*var extLargeMapControl = new ExtLargeMapControl();
        	map.addControl(extLargeMapControl);*/
			/*var trafficOptions = {incidents:true};
			trafficInfo = new GTrafficOverlay(trafficOptions);
			map.addOverlay(trafficInfo);*/
			//map.addControl(new GSmallMapControl());
			//var boundaries = new GLatLngBounds(new GLatLng(12.933,100.864), new GLatLng(12.936,100.880));
			//var silvermoverLogo = new GGroundOverlay("http://localhost/LNK/images/silvermover-logo.png", boundaries);
			//map.addOverlay(silvermoverLogo);
			
			//map.addControl(new GMapTypeControl());
			//map.addControl(new GOverviewMapControl());
			map.addMapType(G_PHYSICAL_MAP);
			//map.getSize(new GSize(260, 234));
			map.setUIToDefault();


			//map.setMapType(G_PHYSICAL_MAP);
			map.setMapType(G_HYBRID_MAP);
			//map.setZoom(setZoom);
			point = new GLatLng(Lat,Lng);
			map.setCenter(point , setZoom);
			
		var letteredIcon = new GIcon(icon_);
		 letteredIcon.image = $url+"images/marker.gif";
		  	markerOptions = { icon:letteredIcon };
		 	 marker = new GMarker(point, markerOptions);
			map.addOverlay(marker);
			 /*
                         marker.openInfoWindow(contentInfo);
			 GEvent.addListener(marker, "click",function() {
				marker.openInfoWindowHtml(contentInfo);
				});
                         */

			
	//} //
        } //n func


// plugin Scrolling page
$.fn.extend({scrollTo:function(speed,easing){return this.each(function(){var targetOffset=$(this).offset().top;$('html,body').animate({scrollTop:targetOffset},speed,easing);});}});

