var sipPos = 0;
$(document).ready(function() {
	$("#panel-tab").click(function(e) {
		e.preventDefault();
		$("#panel").animate({ top: sipPos }, 300, 'easeOutCubic', function() {
			if(sipPos == 0) { sipPos = -140; }
			else { sipPos = 0; }
		});
	});
});


// check if we are at the home page for the first time or not.
var fromsite = getUrlVars()["acc"];

function InstaStart(){
	$("#panel").css({ top: '-140px' });
	$("#panel").css({ opacity: 1 });
	$(".NavItem1").css({ opacity: 1 });
	$(".NavItem2").css({ opacity: 1 });
	$(".NavItem3").css({ opacity: 1 });
	$(".NavItem4").css({ opacity: 1 });
	
}

$(window).bind("load", function() {
	if(fromsite == "true"){
		InstaStart();
		
	}
});

$(window).bind("load", function() {
	CHECKFLASH();
});



function AnimStart() {
	
	if(fromsite == "true"){
		return
	}
	
	$("#panel").animate({ top: '-140px', opacity: 1}, 300, 'easeOutCubic');
	setTimeout("sidebarA()", 500);
};

function sidebarA() {
	$(".NavItem1").animate({opacity: 1}, 2000, 'linear');
	setTimeout("sidebarB()", 500);
	
};
function sidebarB() {
	$(".NavItem2").animate({opacity: 1}, 2000, 'linear');
	setTimeout("sidebarC()", 500);
};

function sidebarC() {
	$(".NavItem3").animate({opacity: 1}, 2000, 'linear');
	setTimeout("sidebarD()", 500);
};

function sidebarD() {
	$(".NavItem4").animate({opacity: 1}, 2000, 'linear');	
};

// Read a page's GET URL variables and return them as an associative array.
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}


function getFlashVersion(){
  // ie
  try {
    try {
      // avoid fp6 minor version lookup issues
      // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
      var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
      try { axo.AllowScriptAccess = 'always'; }
      catch(e) { return '6,0,0'; }
    } catch(e) {}
    return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
  // other browsers
  } catch(e) {
    try {
      if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
        return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
      }
    } catch(e) {}
  }
  return '0,0,0';
}
 
function CHECKFLASH(){ 
var version = getFlashVersion().split(',').shift();
if(version < 9){
	if(version == 0){
		InstaStart();
	}
	  
}else{
  //alert("10 or higher");
}
}
