function Delete_Cookie( name, path, domain )
{
	if ( Get_Cookie( name ) ) document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function Get_Cookie( name )
{
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function showLayer(id)
{
	$('#'+id).show('slow');
}

function hideLayer(id)
{
	$('#'+id).hide('slow');
}

function showInfoLayer(title,info,type)
{
	var d=document.getElementById('inform');
	switch(type)
	{
		case 'del':
			d.className='del';
			break;
		case 'info':
			d.className='info';
			break;
		case 'ok':
			d.className='ok';
			break;
		case 'alert':
			d.className='alert';
			break;
		default: 
			d.className='info';
			break;
	}
	d.innerHTML='<h1>'+title+'</h1>'+'<p>'+info+'</p>';
	$('#inform').show('slow');
	Delete_Cookie('cms_action','','');
	setTimeout("hideInfoLayer()",10000);
}

function hideInfoLayer()
{
	$('#inform').hide('slow');
}

function popupOpen()
{
	var url=document.location+'/mode,print';
	window.open( url, "PrintVersion");
}

function wo(url,width,height)
{
	window.open( url, "PrintVersion", "width="+width+", height="+height);
}

var v_car = 0;
var v_plane = 0;
var v_airball = 0;

$(function () {
	if ( $('#index').length){		
		$('#sun').animate({'bottom': '+=100px'}, 21000);		
		setTimeout("airball()",25000);
		setTimeout("menushow()",2000);
	}
	
	if ( $('.work').length){
		$('#txtscroll').jScrollPane({scrollbarWidth:5, scrollbarMargin:0, showArrows:false});
		$('#txtwrap li').hover(
			function(){$(this).css('background-position','left bottom');},
			function(){$(this).css('background-position','left top');}					   
		);
	}
	else {
		if($('#txtscroll').length){$('#txtscroll').jScrollPane({scrollbarWidth:5, scrollbarMargin:25, showArrows:false});}
	}
	if ( $('.bubbleInfo').length){
		$('.bubbleInfo').each(function () {
       	var distance = 10;
        var time = 10;
        var hideDelay = 10;

        var hideDelayTimer = null;

        var beingShown = false;
        var shown = false;
		var bubble = $(this);
        var trigger = $('.trigger', this);
        var info = $('.popup', this).css('opacity', 0);
		
		$([trigger.get(0), info.get(0)]).mouseover(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            if (beingShown || shown) {
                return;
            } else {
				bubble.addClass('hovered');
                beingShown = true;
                info.css({
                    display: 'block'
                }).animate({
                    right: '-=' + distance + 'px',
                    opacity: 1
                }, time, 'swing', function() {
                    beingShown = false;
                    shown = true;
                });
            }
            return false;
        }).mouseout(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);			
            hideDelayTimer = setTimeout(function () {
                hideDelayTimer = null;
                info.animate({
                    right: '-=' + distance + 'px',
                    opacity: 0
                }, time, 'swing', function () {
                    shown = false;
                    info.css('display', 'none');
                });
            }, hideDelay);
			bubble.removeClass('hovered');
            return false;
        });
		});
	}
	
	if ($('#info').length){
		$('#info .infwrap').jScrollPane({scrollbarWidth:5, scrollbarMargin:25, showArrows:false});	
	}
	/* =sunrise */
	if ( $('.news').length){
		$('#sun').animate({'bottom': '0px'}, 17000);
		setTimeout("big_plane()",20000);
		setTimeout("airball_h()",43000);
		setTimeout("airball_h()",65000);		
		setTimeout("big_plane()",78000);
		setTimeout("big_plane()",95000);
		setTimeout("airball_h()",120000);
		setTimeout("big_plane()",150000);
	}
	if ( $('.about').length){
		$('#sun').animate({'bottom': '-50px'}, 10000);
		setTimeout("vert()",20000);
		
	}
	if ( $('.team').length){
		setTimeout("airball()",1000);
	}
	if ( $('.work').length){
		setTimeout("car()",1000);
		setTimeout("plane_h2()",17000);
		setTimeout("car()",40000);		
		setTimeout("car()",63000);
		setTimeout("car()",78000);
		setTimeout("plane_h2()",95000);
		setTimeout("car()",120000);
		setTimeout("car()",150000);			
	}
	if ( $('.process').length){
		
	}
	
	/* =sunrise */
});

function menushow() {
	/*$('#index #menu a').css('display','block');*/
	$('#m2').animate({'left': '549px', 'top': '114px', 'opacity': '1'}, 1000);
	$('#m3').animate({'left': '202px', 'top': '341px', opacity: '1'}, 1000);
	$('#m4').animate({'left': '313px', 'top': '375px', opacity: '1'}, 1000);
	$('#m5').animate({'left': '345px', 'top': '294px', opacity: '1'}, 1000);
	$('#m6').animate({'left': '674px', 'top': '345px', opacity: '1'}, 1000);
	$('#m1').animate({'left': '177px', 'top': '120px', opacity: '1'}, 1000);
}
function airball() {
	$('#airball').animate({'bottom': '500px'}, 30000);	
}
function airball_v() {
	$('#airball').animate({'bottom': '500px'}, 30000);	
}
function airball_h() {
	if(v_airball == 1) {
		$('#airball').css('bottom','30px');
		$('#airball').css('left','-57px');
	}
	$('#airball').animate({'bottom': '220px', 'left': '1000px'}, 30000);
	v_airball = 1;
}
function big_plane() {
	$('#plane_big').animate({'top': '510px', left: '580px', width: '30px', height: '11px' }, 20000);
}
function mid_plane() {
	$('#plane_mid').animate({'right': '1000px'}, 10000);
}
function plane_h2() {
	if(v_plane == 1) { $('#plane_h2').css('left','-200px'); }
	$('#plane_h2').animate({'left': '1100px'}, 15000);
	v_plane = 1;
}
function vert() {
	$('#vert').animate({'right': '900px'}, 25000);
}
function car() {
	if(v_car == 1) { $('#car').css('right','-80px'); }
	$('#car').animate({'right': '1050px'}, 17000);
	v_car = 1;
}

function PNG(element){
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)){
	var src;
	if (element.tagName=='IMG'){
			if (/\.png$/.test(element.src)){
				src = element.src;
				element.src = "/web/themes/default/img/t.gif";
			}
		}
		else {
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
			if(src){
				src = src[1];
				element.runtimeStyle.backgroundImage="none";
			}
		}
	if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	}
}