function replacePNG(){
	$('img').each(function(){
		pngSRC = $(this).attr('src').split('.png');
		pngHeight = $(this).height();
		pngWidth = $(this).width();
		if(pngSRC.length > 1){
			$(this).css('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + $(this).attr('src') + "', sizingMethod='crop')")
			$(this).attr('src', '/static/images/blank.gif').attr('width', pngWidth).attr('height', pngHeight);
		}
	});
}

function faqInit(){
	$('.faqType li div').hide();
    $('.faqType li').each(function(e){
        $(this).hover(
            function(){
                $(this).css('background','#F2F2F2');
            },
            function(){
                if($(this).attr('class') != 'faqOn'){
                    $(this).css('background','none');
                }
            }
        );
        $(this).find('span:first').click(function(){
            var theFAG = $('.faqOn div:visible'); 
            $('.faqOn div:first').hide(400);
            $('.faqOn').css('background','none');
            $('.faqOn').removeClass('faqOn');
            $(this).parent().css('background','#F2F2F2');
            //$(this).css('background','url(images/arrows_small.png) 0 -79px no-repeat');
            $(this).parent().addClass('faqOn');
            $(this).next('div:first').not($(theFAG)).show(400);
        })
    });
}

function createScroll(){
	if($('#mainContents').height() >= 540){
		$('#mainContents').removeClass('scroll1').addClass('scroll2');
		//isSafari3 = false;
		//if(window.devicePixelRatio){
			//isSafari3 = true;
		//}
		//if(isSafari3 == false){
			$('.scroll-pane').jScrollPane({dragMaxHeight:30, scrollbarWidth:24, scrollbarMargin:10, reinitialiseOnImageLoad:false});
		//}
	}
	if($('#w2b #mainContents').height() >= 160){
		$('#mainContents').removeClass('scroll1').addClass('scroll2');
		//isSafari3 = false;
		//if(window.devicePixelRatio){
			//isSafari3 = true;
		//}
		//if(isSafari3 == false){
			$('.scroll-pane').jScrollPane({dragMaxHeight:46, scrollbarWidth:43, scrollbarMargin:10, reinitialiseOnImageLoad:false});
		//}
	}
}

function wwifr(){
	replaceText('h1', 'ellas', '/static/flash/', '', '', '', '', '', '-3', '1.4');
	replaceText('h2', 'ellas', '/static/flash/', '', '', '', '', '', '-3', '1.4');
	replaceText('h3', 'ellas', '/static/flash/', '', '', '', '', '', '-3', '1.4');
}

$(document).ready(function(){
	if((document.location.href.indexOf('/uae') > -1) && document.location.href.indexOf('dev') < 1){
		$('#topNav ul').remove();
	}
	bubbleHeight = $('#bubble div').height() + 42 + 'px';
	$('#bubble img').height(bubbleHeight);
	$('#bubble').height(bubbleHeight);
	createScroll();
	$('#background').flash({swf:'/static/flash/clouds.swf', width:'100%', height:'768', hasVersion:8, expressInstaller:'/static/flash/expressInstall.swf', flashvars:{sun:sun}, params:{wmode:'transparent'}});
	$('#girl').flash({swf:'/static/flash/ellas_body.swf', width:134, height:208, hasVersion:8, expressInstaller:'/static/flash/expressInstall.swf', flashvars:{colour:dressColour, waving:ellaWaving}, params:{wmode:'transparent'}});
	$('#girl2').flash({swf:'/static/flash/ellas_body.swf', width:134, height:208, hasVersion:8, expressInstaller:'/static/flash/expressInstall.swf', flashvars:{colour:dressColour, waving:ellaWaving}, params:{wmode:'transparent'}});
	$('#girl3').flash({swf:'/static/flash/ellas_body.swf', width:134, height:208, hasVersion:8, expressInstaller:'/static/flash/expressInstall.swf', flashvars:{colour:dressColour, waving:ellaWaving}, params:{wmode:'transparent'}});
	$('#girl4').flash({swf:'/static/flash/ellas_body.swf', width:134, height:208, hasVersion:8, expressInstaller:'/static/flash/expressInstall.swf', flashvars:{colour:dressColour, waving:ellaWaving}, params:{wmode:'transparent'}});
	$('#danmark').flash({swf:'/static/flash/danmark.swf', width:35, height:30, hasVersion:8, expressInstaller:'/static/flash/expressInstall.swf', flashvars:{}, params:{wmode:'transparent'}});
	$('#norge').flash({swf:'/static/flash/norge.swf', width:35, height:30, hasVersion:8, expressInstaller:'/static/flash/expressInstall.swf', flashvars:{}, params:{wmode:'transparent'}});
	$('#sverige').flash({swf:'/static/flash/sverige.swf', width:35, height:30, hasVersion:8, expressInstaller:'/static/flash/expressInstall.swf', flashvars:{}, params:{wmode:'transparent'}});
	$('#uae').flash({swf:'/static/flash/uae.swf', width:35, height:30, hasVersion:8, expressInstaller:'/static/flash/expressInstall.swf', flashvars:{}, params:{wmode:'transparent'}});
	$('#uk').flash({swf:'/static/flash/uk.swf', width:35, height:30, hasVersion:8, expressInstaller:'/static/flash/expressInstall.swf', flashvars:{}, params:{wmode:'transparent'}});
	$('#usa').flash({swf:'/static/flash/us.swf', width:35, height:30, hasVersion:8, expressInstaller:'/static/flash/expressInstall.swf', flashvars:{}, params:{wmode:'transparent'}});
	faqInit();
	if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
        var ieversion=new Number(RegExp.$1)
        if(ieversion < 7){
            replacePNG();
        }
    }
});

window.onload=function(){
	wwifr();
}