var slideCount = 0;
var status = 'play';
var cnt = 0;
var flash = true;
var flajax = '';

function closepp() {
    $('#plogo').fadeOut('slow');
}

function showpp(){
    $('#plogo').fadeIn('slow');
}

$(document).ready(function(){
    $('#plogo').css('height',$(document).height()+'px');
    $('#plogo img').css('margin-top',Math.round(($(window).height()-203)/2)+'px');
    if ( slide_gallery.length > 0 ) {
       /* var p = new Array();
        for(var i=0;i!=(slide_gallery.length);i++){
            p[i] = new Image();
            p[i].src = slide_gallery[i][3];
            //alert(i);
            
        }*/
        showSlideShow();
    }
    if(!FlashDetect.installed){
        flash = false;
        flajax = '&flash=n';
    }
    if ( flash == true ) {
    	$('#jP').jPlayer({
    		swfPath: doc_root+'swf/',
    		volume: 20,
    		solution: "flash",
    		customCssIds: true
    	});

    	var t = setTimeout(function(){play();},2500);
    }
   else {
	   $('#jP').jPlayer({
   		swfPath: doc_root+'swf/',
   		volume: 20,
   		solution: "html",
   		customCssIds: true
   	});
   }
   setFooterHeight();
});

function showContent(site){
        
	$('.loader').css('visibility','visible');
        
	$.ajax({
		type: "POST",
		url: doc_root+"a.php",
		contentType: "application/x-www-form-urlencoded;charset=utf-8",
		data: "site="+site+flajax,
		success: function(msg){
                        
			var a = new Array();
			a = msg.split('{||}');
                        if ( navigator.appVersion.indexOf('MSIE') == -1 ) {
                            
                            $('title').html(a[0]);
                        }
                       
                        // menü szín
                        $('#mm').attr('class','').attr('class',a[1]);
                        
                        $('#slide').attr('class','').attr('class','slide '+a[1]);
                        
			$('.site').html(a[2]);
                        
			$('.loader').css('visibility','hidden');
                        setFooterHeight();
                        
		}
	});
        
	return false;
}

function showSlideShow() {
    if ( slideCount == slide_gallery.length ) slideCount = 0;
    
    $('#simage2').html('<img src="'+slide_gallery[slideCount][3]+'" alt="'+slide_gallery[slideCount][0]+'" />');
    slideOutSlider();
    $('#simage1').fadeOut('slow',function(){
        $('#simage1').html('<img src="'+slide_gallery[slideCount][3]+'" alt="'+slide_gallery[slideCount][0]+'" />').css('display','block');
        $('#simage2').html('');
         changeSliderText(slide_gallery[slideCount][1],slide_gallery[slideCount][2]);
    });
}

function slideOutSlider(){
    $('.slideText').fadeOut('slow');
}

function slideInSlider(){
    $('.slideText').fadeIn('slow',function(){
        slideCount++;
        var t = setTimeout(function(){showSlideShow();},10000);
    });
}

function changeSliderText(text,text2){
    $('#art_name').html(text);
    $('#art_type').html(text2);
    $('.slideText').css('margin-left',875-16-$('.slideText').width()+'px');
    slideInSlider();
}

function play(){
	if ( status == 'pause'){
		status = 'play';
		$('#jP').jPlayer( "play" );
		// play button
		$('#m').attr('src',img+'pause.png');
	}
	else if ( $('#m').attr('src') == img+'pause.png' && status == 'play' ) {
		$('#jP').jPlayer( "pause" );
		status = 'pause';
		// play gomb
		$('#m').attr('src',img+'play.png');
	}
	else {
		status = 'play';
		$('#jP').jPlayer("setFile",playList[cnt][3]);
		$('#jP').jPlayer( "play" );
		$("#jP").jPlayer("onSoundComplete", function() {
			  //next();
			var t = setTimeout(function(){next();},500);
		});
		
		$('.a_art').html(playList[cnt][1]);
                $('.a_name').html(playList[cnt][2]);
		// pause button
		$('#m').attr('src',img+'pause.png');
	}

}

function next(){
	status = 'next';
	$('#jP').jPlayer( "stop" );
	$("#jP").jPlayer( "clearFile" );
	cnt++;
	if ( playList[cnt] == undefined ) cnt = 0;
	
	var t = setTimeout(function(){play();},500);

}

function prev(){
	status = 'prev';
	$('#jP').jPlayer( "stop" );
	$("#jP").jPlayer( "clearFile" );
	if ( cnt == 0 ) cnt = (playList.length)-1;
	else cnt--;
	
	var t = setTimeout(function(){play();},500);
}

function stop(){
	$('#jP').jPlayer( "stop" );
	$("#jP").jPlayer( "clearFile" );
	status = 'stop';
	cnt = 0;
	// play button
        $('.a_art').html('&nbsp;');
        $('.a_name').html('&nbsp;');
	$('#m').attr('src',img+'play.png');
	
}

function callMusic(id){
        for(var i= 0;i!=playList.length;i++){
            if ( playList[i][0] == id ) break;
        }
    
	cnt = i;
	status = 'next';
	$('#jP').jPlayer( "stop" );
	$("#jP").jPlayer( "clearFile" );
	var t = setTimeout(function(){play();},500);
	
}

function setFooterHeight(){
    $('.site').css('margin-bottom','0px');
    var mainHeight = 278+30+43+$('.site').height();
    var windowHeight = $(window).height();
    
    if ( windowHeight >= mainHeight ) {
        $('.site').css('margin-bottom',(windowHeight-mainHeight-10)+'px');
    }
    else {
        $('.site').css('margin-bottom','60px');
    }
    
}


var FlashDetect=new function(){var self=this;self.installed=false;self.raw="";self.major=-1;self.minor=-1;self.revision=-1;self.revisionStr="";var activeXDetectRules=[{"name":"ShockwaveFlash.ShockwaveFlash.7","version":function(obj){return getActiveXVersion(obj);}},{"name":"ShockwaveFlash.ShockwaveFlash.6","version":function(obj){var version="6,0,21";try{obj.AllowScriptAccess="always";version=getActiveXVersion(obj);}catch(err){}
return version;}},{"name":"ShockwaveFlash.ShockwaveFlash","version":function(obj){return getActiveXVersion(obj);}}];var getActiveXVersion=function(activeXObj){var version=-1;try{version=activeXObj.GetVariable("$version");}catch(err){}
return version;};var getActiveXObject=function(name){var obj=-1;try{obj=new ActiveXObject(name);}catch(err){obj={activeXError:true};}
return obj;};var parseActiveXVersion=function(str){var versionArray=str.split(",");return{"raw":str,"major":parseInt(versionArray[0].split(" ")[1],10),"minor":parseInt(versionArray[1],10),"revision":parseInt(versionArray[2],10),"revisionStr":versionArray[2]};};var parseStandardVersion=function(str){var descParts=str.split(/ +/);var majorMinor=descParts[2].split(/\./);var revisionStr=descParts[3];return{"raw":str,"major":parseInt(majorMinor[0],10),"minor":parseInt(majorMinor[1],10),"revisionStr":revisionStr,"revision":parseRevisionStrToInt(revisionStr)};};var parseRevisionStrToInt=function(str){return parseInt(str.replace(/[a-zA-Z]/g,""),10)||self.revision;};self.majorAtLeast=function(version){return self.major>=version;};self.minorAtLeast=function(version){return self.minor>=version;};self.revisionAtLeast=function(version){return self.revision>=version;};self.versionAtLeast=function(major){var properties=[self.major,self.minor,self.revision];var len=Math.min(properties.length,arguments.length);for(i=0;i<len;i++){if(properties[i]>=arguments[i]){if(i+1<len&&properties[i]==arguments[i]){continue;}else{return true;}}else{return false;}}};self.FlashDetect=function(){if(navigator.plugins&&navigator.plugins.length>0){var type='application/x-shockwave-flash';var mimeTypes=navigator.mimeTypes;if(mimeTypes&&mimeTypes[type]&&mimeTypes[type].enabledPlugin&&mimeTypes[type].enabledPlugin.description){var version=mimeTypes[type].enabledPlugin.description;var versionObj=parseStandardVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revisionStr=versionObj.revisionStr;self.revision=versionObj.revision;self.installed=true;}}else if(navigator.appVersion.indexOf("Mac")==-1&&window.execScript){var version=-1;for(var i=0;i<activeXDetectRules.length&&version==-1;i++){var obj=getActiveXObject(activeXDetectRules[i].name);if(!obj.activeXError){self.installed=true;version=activeXDetectRules[i].version(obj);if(version!=-1){var versionObj=parseActiveXVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revision=versionObj.revision;self.revisionStr=versionObj.revisionStr;}}}}}();};FlashDetect.JS_RELEASE="1.0.4";
