function replayIntro(){
 jQuery.cookie('cookies_enabled',null);
 jQuery.cookie('intro_play','play');
 setTimeout('window.location="?page=home"',500);
 }

function animation_onEndEvent(){ setTimeout('animation_onEndEvent2()',1000); }
function animation_onEndEvent2(){
 
 jQuery('#top_links_container').css({'overflow':'hidden'}).find('ul').eq(0).css({'top':'-28px'});
 jQuery('#left_links').css({'margin-left':'0px'}).parent().css({'display':'block'});
 setTimeout(function(){ jQuery('#left_links>li:first-child>a').trigger('click');},4000);
 
 //alert('Animation Ended. Load or reveal page.');
 rotateImageReset('pg_bg_img');
 jQuery('ul#footer_links,#pg_bg_img_src')
 .css({opacity:0,display:'block',visibility:'visible'})
 .animate({opacity:1},2000,'linear',function(e){
  //setTimeout('window.location="index.php"',500);
  //setTimeout('window.location="http://farnhamantiquecarpets.com/staging_2/"',500);  
  jQuery(this).get(0).style.filter='';
  });
 jQuery('div#header_1').css({opacity:0,display:'block',visibility:'visible'})
 .animate({opacity:1},1000,'linear',function(e){
  jQuery(this).get(0).style.filter='';
  });
 jQuery('#flashIntroAlternative').parent()
 .animate({opacity:0},2000,'linear',function(e){
  jQuery(this).css({'display':'none'}).remove();//.get(0).style.filter='';
  });
 //jQuery('div#tintfade').animate({top:'120px'},1000,'linear');
 //;
 }

function embedswf(dest,src,w,h,onComplete){
 dest = (!dest) ? 'swf'+randstr(16) : dest ;
 if(!document.getElementById(dest)){ document.write('<div id="'+dest+'"></div>'); }
 
 var flashvars = {};
 var params = {name:dest,play:'true',menu:'false',quality:'best',wmode:'transparent',allowFullScreen:'true',allowScriptAccess:'sameDomain'};
 //params.allowScriptAccess = "always";
 var attributes = {id:dest,name:dest};
 
 return swfobject.embedSWF(src, dest, w, h, "9.0.0", false, flashvars, params, attributes, onComplete);
 }
function loadStyleSheet(href){
 var head = document.getElementsByTagName("head")[0] || document.documentElement ;
 if(jQuery('link[href="'+href+'"]',head).length<1){
  jQuery(head).append('<link rel="stylesheet" type="text/css" media="screen,projection" href="'+href+'" />');
  jQuery(head).append('<style>@import url(\''+href+'\')</style>');
  }
 }

function rotateImage(id){
 elem = jQuery('#'+id+' .image-selected')
 .css({'z-index':0})
 .removeClass('image-selected')
 .animate({'opacity':0},1000,'linear',function(e){  })
 .get(0);
 
 var i = jQuery('#'+id+' .image').index(elem);
 var s = jQuery('#'+id+' .image').size();
 var j = (i<s-1 ? i+1 : 0 );
 
 jQuery('#'+id+' .image').eq(j)
 .css({'z-index':9})
 .addClass('image-selected')
 .animate({opacity:1},1000,'linear',function(e){  });
 }
function rotateImageReset(id){
 var elem = jQuery('#'+id+'>.image').stop()
 .css({'z-index':0,'opacity':0}).removeClass('image-selected')
 .parent().find('.image:first-child')
 .css({'z-index':9,'opacity':1})
 .addClass('image-selected')
 .get(0);
 clearInterval(jQuery('#'+id).data('rotator_int'));
 jQuery('#'+id).data('rotator_int',setInterval("rotateImage('"+id+"')",5000));  
 }
 

