function switchpopup() {
  if($('#searchpopup').css('display')!='none'){
    $('#searchpopup').animate({opacity: 'hide' }, 'slow');
  }else{
    $('#searchpopup').animate({opacity: 'show' }, 'slow');
  }
}

var cache=Array();

function preLoadImages(images) {
  var imgs_len = images.length;
  for (var i = 0; i<imgs_len; i++) {
    var cacheImage = new Image();
    cacheImage.src = images[i];
    cache[i]=cacheImage;
    }
}

if ($.browser.opera){
   $(document).ready(function(){
      $(window).resize(function(){
         $('#wrapper').append('<div id="resize_bug_fixer" style="display:none;"');
         $('#resize_bug_fixer').remove();
      })
   });
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

var timerleft1, timerright1, timercenter1, timerleft2, timerright2, timercenter2;

$(document).ready(function() {
  imgs=["/img/footer/im_left.jpg",
                 "/img/footer/im_center.jpg",
                 "/img/footer/im_right.jpg",
                 "/img/footer/bg_left.gif",
                 "/img/footer/bg_center.gif",
                 "/img/footer/bg_right.gif",
                 "/img/searchpopup.png",
                 "/img/sclose.gif"];
  preLoadImages(imgs)
  cook=readCookie('nopopup');
  if(cook!='true'){
    timerleft1=window.setTimeout("gsomleft()",2500);
    timerright1=window.setTimeout("gsomcenter()",2750);
    timercenter1=window.setTimeout("gsomright()",3000);
    timerleft2=window.setTimeout("gsomleft()",7500);
    timerright2=window.setTimeout("gsomcenter()",7750);
    timercenter2=window.setTimeout("gsomright()",8000);
    
    createCookie('nopopup','true',14);
  }
})





function cleartimeouts(){
  
    clearTimeout(timerleft1);
    clearTimeout(timerright1);
    clearTimeout(timercenter1);
    clearTimeout(timerleft2);
    clearTimeout(timerright2);
    clearTimeout(timercenter2);
}

function gsomleft(kill){
  if(kill){
    cleartimeouts();
  }

  if($('#fleft').css('height')=='118px'){
    $('#fleft_c').animate({opacity:'hide'}, 1000, function(){
      $('#darker_left').animate({opacity:'hide'}, 1200);
      $('#fleft').animate({height: '0'}, 1200);
    });
  }
  else{
    $('#darker_left').animate({opacity:'show'}, 1200);
    $('#fleft_c').css('display','block');
    $('#fleft').animate({height: '118px'}, 1200);
  }
}
function gsomright(kill){
  if(kill){
    cleartimeouts();
  }
  if($('#fright').css('height')=='118px'){
    $('#fright_c').animate({opacity:'hide'}, 1000, function(){
      $('#darker_right').animate({opacity:'hide'}, 1200);
      $('#fright').animate({height: '0'}, 1200);
    });
  }
  else{
    $('#darker_right').animate({opacity:'show'}, 1200);
    $('#fright_c').css('display','block');
    $('#fright').animate({height: '118px'}, 1200);
  }
}
function gsomcenter(kill){
  if(kill){
    cleartimeouts();
  }
  if($('#fcenter').css('height')=='118px'){
    $('#fcenter_c').animate({opacity:'hide'}, 1000, function(){
      $('#fcenter').animate({height: '0'}, 1200);
    });
  }
  else{
    $('#fcenter_c').css('display','block');
    $('#fcenter').animate({height: '118px'}, 1200);
  }
}



var empty;
var params = {"wmode":"transparent"};

swfobject.embedSWF("/swf/menu_light.swf", "flashmenu", "200", "300", "9.0.0","/img/expressinstall.swf", empty, params, params);
swfobject.embedSWF("/swf/exp.swf", "expflash", "240", "320", "9.0.0","/img/expressinstall.swf", empty, params, params);

