//new jaf object
var jaf = new jaf();

var hover = jaf.animate.hover;

// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// -----------------------------------------------------------------------------

//public main
function main()
{
    dynamicScroll();


    // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
    var hasProductInstall = DetectFlashVer(6, 0, 65);
    // Version check based upon the values defined in globals
    var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

    // Check to see if a player with Flash Product Install is available and the version does not meet the requirements for playback
    if ( ( ( hasProductInstall && !hasReqestedVersion ) || ( !hasProductInstall) ) && ( typeof noVA == 'undefined' || noVA != true  ) )
    {
		
		_revealAlternate();
    }
    else if (hasReqestedVersion)
    {
       _detectionSuccess();
    }
    else
    {
      _revealAlternate();
    }
}

/**
* SUCCESSFUL FLASH EMBEDING
* (IF Current Flash DETECTED)
*
* End preloader, embed flash.  when embedded, allow alt content to show for the sake of the being present
*
*/

var favcount = 0; 

var cookies =  document.cookie.split( ';' );

for ( i = 0; i < cookies.length; i++ )
{
	a_temp_cookie = cookies[i].split( '=' );
	
	if( a_temp_cookie.length > 1  )
	{
		cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
	
		if( cookie_value == 'tacori_fav' )
		{
			favcount++;
		}	
	}
}

favcount = parseInt( favcount );

var movieID = "full_flash_wrapper";
function _detectionSuccess()
{
    //_endPreloadAnimation();

    if(getObj('full_flash_wrapper'))
    {
        var flashvars = {favnum:favcount, page:pageID};
        var params = { swliveconnect:"true", allowScriptAccess:"always", wmode:"window" };
        var attributes = { id:movieID, name:movieID };
        swfobject.embedSWF("swf/tacori_carousel.swf", movieID, "950", "580", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
		  $("#menuSystem").css( "display", "none" );
$(".simpleSlide-window").css( "display", "none" );
    }
   


}

var num = 1;
function update_nav_fav()
{
    var obj = document.getElementById(movieID);

    obj.navupdate(num++);
}

/**
* REMOVE PRELOADER / ENABLE SCROLLING
*
*/
function _endPreloadAnimation()
{
    document.body.removeChild(getObj('preloader'));
    document.body.style.overflow = 'auto';
}


function _revealAlternate()
{

                        
                        $("#pageDetail").css( "display", "inline" );
                        
                        simpleSlide( 
                        
                                                        {
                                                                'set_speed': 300,
                                                                'status_width': 20,
                                                                'status_color_outside': '#403E3E',
                                                                'status_color_inside': '#d2d2d2',
                                                                'fullscreen': 'false',
                                                                'swipe': 'true'
                                                        }
                                                        
                                
                        
                        ); 
                
                        
                $("#full_flash_wrapper").css("display", "none");
                

        
         
        
                $('.simpleSlide-tray').each( function() { 
                        var related_group = $(this).attr('rel');
                        var intervalId = window.setInterval("simpleSlideAction('.right-button', " + related_group + ");", 5000);
                        windowIntervalId = intervalId;
                        
                        $('.left-button').click( function() {
                                window.clearInterval( intervalId );
                        } );
                        
                        $('.right-button').click( function() {
                                window.clearInterval( intervalId );
                        } );
                        
                        $('.jump-to').click( function() {
                                window.clearInterval( intervalId );
                        } );
                });
}



function simpleSlide(incoming_options){jQuery(function($){var options={'status_width':20,'status_color_inside':'#fff','status_color_outside':'#aaa','set_speed':500,'fullscreen':'false','swipe':'false','callback':'function()'};$.extend(options,incoming_options);$.ss_options=options;$('.simpleSlide-slide').css('opacity','0');$('.simpleSlide-tray').css('margin','0');$('.simpleSlide-window').prepend('<span id="ssLoading" style="color: #808080;font-family:Helvetica, Arial, sans-serif;font-size: 12px; margin: 10px 0 0 10px;display: block">Loading slides...</span>');var no_of_images=$('.simpleSlide-slide img').size();if(no_of_images>0){var images=new Array();var i=0;$('.simpleSlide-slide img').each(function(){images[i]=$(this).attr('src');i++;});i=0;$(images).each(function(){var imageObj=new Image();imageObj.src=images[i];if(imageObj.complete){no_of_images--;i++;if(no_of_images==0){ssInit();};}else{$(imageObj).load(function(){no_of_images--;i++;if(no_of_images==0){ssInit();};});};});}else{ssInit();};});};function ssInit(){jQuery(function($){$('.simpleSlide-window').each(function(){if($.ss_options.fullscreen=='true'){$('body').css('overflow','hidden');}var window_contents=$(this).html();var cleaned_contents=removeWhiteSpace(window_contents);$(this).html(cleaned_contents);var slide_count=$(this).find('.simpleSlide-slide').size();$(this).find('.simpleSlide-slide').css('display','block');var window_height=$(this).find('.simpleSlide-slide').first().outerHeight();if($.ss_options.fullscreen=='true'){fullScreen(this);};$(this).find('.simpleSlide-slide').css({'display':'inline','float':'left'});var window_width=$(this).find('.simpleSlide-slide').first().outerWidth();var window_rel=$(this).attr('rel');if($.ss_options.fullscreen=='false'){$(this).css({'height':window_height,'width':window_width,'position':'relative'});};$(this).css('overflow','hidden');setTraySize(this,slide_count,window_width);setSimpleSlideStatus(window_rel,window_height,window_width,slide_count);setPaging(this);$(this).find('#ssLoading').remove();if($.ss_options.swipe=='true'&&!$.browser.msie){simpleSwipe(this);};$(this).find('.simpleSlide-slide').animate({'opacity':'1'},300,"swing");});if(typeof($.ss_options.callback)=='function'){$.ss_options.callback.call(this);};function setPaging(this_window){var page_count=1;$(this_window).find('.simpleSlide-slide').each(function(){$(this).attr('alt',page_count);page_count++;});};function fullScreen(this_s_window){var base_img=new Image();base_img.src=$(this_s_window).find('img').first().attr('src');var window_prop=$(window).width()/$(window).height();var image_prop=base_img.width/base_img.height;var wh=$(window).height();var ww=$(window).width();if(window_prop>image_prop){var new_height=(ww/base_img.width)*base_img.height;var height_offset=(new_height-wh)/2;$(this_s_window).find('img').attr('width',ww).attr('height',new_height).css('marginLeft',0);$(this_s_window).css({'marginLeft':0,'marginTop':'-'+height_offset+'px','height':wh+height_offset});$(this_s_window).find('.simpleSlide-slide').css({'width':ww,'height':new_height,'overflow':'hidden'});}else{var new_width=(wh/base_img.height)*base_img.width;var width_offset=(new_width-ww)/2;$(this_s_window).find('img').attr('height',wh).attr('width',new_width);$(this_s_window).find('img').css({'marginLeft':'-'+width_offset+'px'});$(this_s_window).find('.simpleSlide-slide').css({'width':ww,'height':wh,'overflow':'hidden'});$(this_s_window).css({'marginTop':0,'height':wh});};$(this_s_window).find('.simpleSlide-tray').css('marginLeft',0);};function setTraySize(slideWindow,count,viewer_width){var slider_width=count*viewer_width;$(slideWindow).find('.simpleSlide-tray').css({'width':slider_width+'px'});$(slideWindow).find('.simpleSlide-slide').css('display','inline-block');};function setSimpleSlideStatus(this_rel,height,width,image_count){var ratio=$.ss_options.status_width/width;var status_height=ratio*height;$('.simpleSlideStatus-tray[rel="'+this_rel+'"]').css({'width':$.ss_options.status_width*image_count,'height':status_height,'background-color':$.ss_options.status_color_outside});$('.simpleSlideStatus-window[rel="'+this_rel+'"]').css({'width':$.ss_options.status_width,'height':status_height,'background-color':$.ss_options.status_color_inside});if(jQuery.support.opacity){$('.simpleSlideStatus-window .simpleSlideStatus-tray[rel="'+this_rel+'"]').css({'opacity':'.5','background-color':$.ss_options.status_color_inside});};if(!jQuery.support.opacity){$('.simpleSlideStatus-window .simpleSlideStatus-tray[rel="'+this_rel+'"]').css({'filter':'alpha(opacity=50)','background-color':$.ss_options.status_color_inside});};};$('.left-button, .right-button, .jump-to').live('click',function(){var rel=$(this).attr('rel');if(!$('div.simpleSlide-tray[rel="'+rel+'"]').is(':animated')){simpleSlideAction(this,rel);};});});};function simpleSwipe(this_window){var defaults={threshold:{x:$(this_window).width()*.15,y:$(this_window).height()*.1},swipeLeft:function(){window.clearInterval(windowIntervalId);simpleSlideAction('.right-button',$(this_window).attr('rel'));},swipeRight:function(){window.clearInterval(windowIntervalId);simpleSlideAction('.left-button',$(this_window).attr('rel'));},preventDefaultEvents:true};var options=$.extend(defaults,options);if(!this_window)return false;return $(this_window).each(function(){var me=$(this_window);var originalCoord={x:0,y:0};var finalCoord={x:0,y:0};function touchStart(event){originalCoord.x=event.targetTouches[0].pageX;originalCoord.y=event.targetTouches[0].pageY;};function touchMove(event){if(defaults.preventDefaultEvents){event.preventDefault();};finalCoord.x=event.targetTouches[0].pageX;finalCoord.y=event.targetTouches[0].pageY;};function touchEnd(event){var changeY=originalCoord.y-finalCoord.y;if(changeY<defaults.threshold.y&&changeY>(defaults.threshold.y*-1)){changeX=originalCoord.x-finalCoord.x;if(changeX>defaults.threshold.x){defaults.swipeLeft();};if(changeX<(defaults.threshold.x*-1)){defaults.swipeRight();};};};function touchCancel(event){console.log('Canceling swipe gesture...');};this_window.addEventListener("touchstart",touchStart,false);this_window.addEventListener("touchmove",touchMove,false);this_window.addEventListener("touchend",touchEnd,false);this_window.addEventListener("touchcancel",touchCancel,false);});};function simpleSlideAction(action,rel_no){jQuery(function($){var move_speed=$.ss_options.set_speed;var image_count=$('.simpleSlide-window[rel="'+rel_no+'"]').find('.simpleSlide-slide').size();var window_width=$('.simpleSlide-window[rel="'+rel_no+'"]').innerWidth();var status_window_width=$('.simpleSlideStatus-window[rel="'+rel_no+'"]').innerWidth();var status_tray_width=status_window_width*image_count;var current_tray_margin=parseInt($('.simpleSlide-tray[rel="'+rel_no+'"]').css('marginLeft'),10);var current_status_window_margin=parseInt($('.simpleSlideStatus-tray .simpleSlideStatus-window[rel="'+rel_no+'"]').css('marginLeft'),10);var current_status_tray_margin=parseInt($('.simpleSlideStatus-window .simpleSlideStatus-tray[rel="'+rel_no+'"]').css('marginLeft'),10);if($(action).is('.jump-to')){var to_page=$(action).attr('alt');var j_margin=(to_page-1)*(window_width*(-1));var st_margin=(to_page-1)*(status_window_width*(-1));var sw_margin=(to_page-1)*(status_window_width);$('.jump-to').removeClass('active');$(action).addClass('active');move(j_margin,sw_margin,st_margin);};if($(action).is('.left-button')){if(current_tray_margin==0){var j_margin=current_tray_margin-((image_count-1)*window_width);var st_margin=current_status_tray_margin-((image_count-1)*status_window_width);var sw_margin=current_status_window_margin+((image_count-1)*status_window_width);}else{var j_margin=current_tray_margin+window_width;var st_margin=current_status_tray_margin+status_window_width;var sw_margin=current_status_window_margin-status_window_width;};currentlyActiveAltNumber=(parseInt($('.active').attr('alt')));toBeActive=$('span[alt|="'+parseInt(currentlyActiveAltNumber-1)+'"]');$('.jump-to').removeClass('active');if(parseInt(toBeActive.attr('alt'))){toBeActive.addClass('active');}else
{if(currentlyActiveAltNumber==1){$('#page span:last-child').addClass('active');}else
{$('span[alt|="1"]').addClass('active');}}move(j_margin,sw_margin,st_margin);};if($(action).is('.right-button')){if(current_tray_margin==(image_count-1)*(window_width*-1)){var j_margin=0;var st_margin=0;var sw_margin=0;}else{var j_margin=current_tray_margin-window_width;var st_margin=current_status_tray_margin-status_window_width;var sw_margin=current_status_window_margin+status_window_width;};currentlyActiveAltNumber=(parseInt($('.active').attr('alt')));toBeActive=$('span[alt|="'+parseInt(currentlyActiveAltNumber+1)+'"]');$('.jump-to').removeClass('active');if(parseInt(toBeActive.attr('alt'))){toBeActive.addClass('active');}else
{if(currentlyActiveAltNumber>1){$('span[alt|="1"]').addClass('active');}else
{$('#page span:last-child').addClass('active');}}move(j_margin,sw_margin,st_margin);};function move(new_margin,new_swindow_margin,new_stray_margin){$('.simpleSlide-tray[rel="'+rel_no+'"]').animate({'marginLeft':new_margin},move_speed,"swing");$('.simpleSlideStatus-window .simpleSlideStatus-tray[rel="'+rel_no+'"]').animate({'marginLeft':new_stray_margin},move_speed,"swing");$('.simpleSlideStatus-tray .simpleSlideStatus-window[rel="'+rel_no+'"]').animate({'marginLeft':new_swindow_margin},move_speed,"swing");};});};function removeWhiteSpace(raw){var cleaned_string=raw.replace(/[\r+\n+\t+]\s\s+/g,"");return cleaned_string;};var windowIntervalId=0;

