
$(document).ready(function(){

  var currentPosition = 0;
  var slideWidth = 320;
  var slides = $('.index-gallery-thumbnail');
  var numberOfSlides = slides.length;

  // Remove scrollbar in JS
  $('#slidesContainer').css('overflow', 'hidden');

  // Wrap all .slides with #slideInner div
  slides
    .wrapAll('<div id="slideInner"></div>')
    // Float left to display horizontally, readjust .slides width
	.css({
      'float' : 'left',
      'width' : slideWidth
    });

  // Set #slideInner width equal to total width of all slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert controls in the DOM
  $('#slideshow')
    .prepend('<span class="control" id="leftControl">Clicking moves left</span>')
    .append('<span class="control" id="rightControl">Clicking moves right</span>');

  // Hide left arrow control on first load
  manageControls(currentPosition);

  // Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
    // Determine new position
	currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
	// Hide / show controls
    manageControls(currentPosition);
    // Move slideInner using margin-left
    $('#slideInner').animate({
      'marginLeft' : slideWidth*(-currentPosition)
    });
  });

  // manageControls: Hides and Shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
	if(position==0){ $('#leftControl').hide() } else{ $('#leftControl').show() }
	// Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#rightControl').hide() } else{ $('#rightControl').show() }
  }

});

$(document).ready(function() {
	//When page loads...
	$(".tab-content").hide(); //Hide all content
	$("#service-icon li:first a").addClass("active").show(); //Activate first tab
	$(".tab-content:first").show(); //Show first tab content

	//On Click Event
	$("#service-icon li a").click(function() {
		$("#service-icon li a").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab-content").hide(); //Hide all tab content

		var activeTab = $(this).attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});/**/
});

$(document).ready(function() {
	//When page loads...
	$(".shop-content").hide(); //Hide all content
	$("#shopping-icon li:first a").addClass("active").show(); //Activate first tab
	$(".shop-content:first").show(); //Show first tab content

	//On Click Event
	$("#shopping-icon li a").click(function() {
		$("#shopping-icon li a").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".shop-content").hide(); //Hide all tab content
		selectOn($(this).attr("cid"));
		
		var activeTab2 = $(this).attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab2).fadeIn(); //Fade in the active ID content
		return false;
	});/**/
});

	$("#index-banner-thumbnail:has(a)").click(function() {
		//alert(1);
		//$("#index-banner-thumbnail li a").removeClass("active"); //Remove any "active" class
		//$(this).addClass("active");
		//return false;
	});
	
$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) { 
    $(pager).find('li').removeClass('active') 
        .filter('li:eq('+currSlideIndex+')').addClass('active'); 
};
	var currentIndex = 0;
	
    $('#main-banner').cycle({
        fx:     'scrollHorz',
        speed:  'slow',
        timeout: 6000,
        pager:  '#index-banner-thumbnail',
		activePagerClass: 'active',
		slideExpr: 'img',
		pagerAnchorBuilder: function(idx, slide) { 
		// return selector string for existing anchor 
      	return '#index-banner-thumbnail li:eq(' + idx + ')';
    	},
		after : function(currSlideElement, nextSlideElement, opts, forwardFlag) {
			$("#index-banner-thumbnail li a").removeClass("active");
			$("#index-banner-thumbnail li a:eq(" + opts.currSlide + ")").addClass("active");
    	}
    });
	function formatTitle(title, currentArray, currentIndex, currentOpts)
	{
    	return '<div id="iframe-title"><div class="close-btn"><a href="javascript:;" onclick="$.fancybox.close();">close</a></div>' + (title && title.length ? '<b>' + title + '</b>' : '' ) + '' + '' + ' ' + '' + '</div>';
	}
	
	function selectIt(obj)
	{
		$("#index-banner-thumbnail li a").removeClass("active");
		obj.className = "active";
	}
	
	function nextImg()
	{
		if (currentImg+1 < $('.linkpic').length )
		{
			currentImg++;
			showGalleryPic($('.linkpic:eq(' + currentImg + ')').attr('img'), currentImg);
		}
	}
	
	function backImg()
	{
		if (currentImg > 0 )
		{
			currentImg--;
			showGalleryPic($('.linkpic:eq(' + currentImg + ')').attr('img'), currentImg);
		}
	}
	
	var currentImg = 0;
	
$(function(){

    $('.scrollto').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;
                
            }
            
        }
        
    });
    
});


function selectOn(val)
{
	//var obj = getFlashMovieObject("FlashID");
	//obj.SetVariable("jsPass", val);
	if(window.FlashID) window.document["FlashID"].SetVariable("jsPass", val);
	if(document.FlashID) document.FlashID.SetVariable("jsPass", val);
}

function getFlashMovieObject(movieName)
{
	/*
	alert(navigator.appName);
	
	if (navigator.appName.indexOf("Netscape")!=-1)
	{
		alert(1);
		return document.embeds[movieName]; 
	}
	*/
	//alert(document.getElementsByName(movieName).item(0));
	return document.getElementsByName(movieName).item(0);
	//return document.getElementById(movieName);
	//return document.embeds[movieName];
	//return document.[movieName]
	//return window.document[movieName]; 
	
	if (navigator.appName.indexOf("Microsoft Internet")==-1)
	{
		if (document.embeds && document.embeds[movieName])
			return document.embeds[movieName]; 
	}
	else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
	{
		if (window.document[movieName]) 
		{
			return window.document[movieName];
		}
		else
		{
			return document.getElementById(movieName);
		}
	}
	
	
}

function changed(obj)
{
	alert(obj.value);	
}
