

jQuery.noConflict();
jQuery(document).ready(function(jQuery) {
    
    var lockH = 0;
    var lockW = 0;
    var incrsH = 0;
    var incrsW = 0;
    var refreshIdH = null;
    var refreshIdW = null;    
    
    jQuery.fn.callExpandlist = function (id, maxW, minW) {
        
        var elmW = jQuery('#'+id).position().left;
        
        if(elmW < maxW && lockW == 0){                    
            incrsW = (elmW+40);
            if(incrsW > maxW){
                incrsW = maxW
            }
            //writte('lockW:'+lockW+'left:'+elmW+'lockW:'+lockW+'<br/>');
            jQuery('#'+id).css({
                'left':incrsW
            });
        //writte('lockW:'+lockW+'left:'+incrsW+'lockW:'+lockW+'<br/>');
            
        }
        if(elmW > minW && lockW == 1){                    
            incrsW = Math.round((elmW-40));            
            if(incrsW < minW){
                incrsW = minW
            }
            //alert(elmW+':::'+incrsW+':::'+minW+'lock:'+lockW);
            jQuery('#'+id).css({
                'left': Math.round(incrsW)
            });
            
        }                
        if(elmW == maxW && lockW == 0){                    
            lockW = 1;               
            clearInterval(refreshIdW);        
        }
  
        if(lockW == 1 && elmW < (minW+2)){
            lockW = 0;                                
            clearInterval(refreshIdW);        
        }
    }
    //jQuery("#expandlist" ).toggle( 'slide', 500 );

    
    jQuery.fn.slodeDownSwf = function(id, maxH, minH) {                                        
        var elmH = jQuery('#'+id).height();
        if(elmH < maxH && lockH == 0){                    
            incrsH = (elmH+40);
            if(incrsH > maxH){
                incrsH = maxH
            }
            jQuery('#'+id).css({
                'height':incrsH
            });
        }
        if(elmH > minH && lockH == 1){                    
            incrsH = (elmH-60);
            if(incrsH < minH){
                incrsH = minH
            }
            jQuery('#'+id).css({
                'height':incrsH
            });
        }                
        if(elmH == maxH && lockH == 0){                    
            lockH = 1;   
            clearInterval(refreshIdH);        
        }
        if(elmH == minH && lockH == 1){
            lockH = 0;                    
            clearInterval(refreshIdH);        
        }        
    }
    
    jQuery.fn.callFadeOutIntro = function (id) {
        var elmW = jQuery('#'+id);
        var act = jQuery('#'+id).attr('alt');

        if(act == 'active'){
            jQuery(elmW).fadeOut("slow");    
            elmW.attr('alt','inactive');                
        }                

        if(act == 'inactive'){
            jQuery(elmW).fadeIn("slow");
            elmW.attr('alt','active');                        
        }                
    }
    
    var prodlayerissetactScene = null;
            
    jQuery('#expandimg').live('click',function(){        
        refreshIdH = setInterval(function(){
            jQuery().slodeDownSwf('objectholder',550,245);            
        }, 10);
        refreshIdW = setInterval(function(){            
            jQuery().callExpandlist('expandlist',0,-280);            
        }, 2);
        
        jQuery().callFadeOutIntro('introheadtext');            
                
        // ha a termek kep ki van nyitva
        if(prodlayerissetactScene != null){            
            jQuery('#'+prodlayerissetactScene+'reklam').css({'display':'none'});
            prodlayerissetactScene = null;
            jQuery('#animation-holder').fadeTo("slow",1);             
        }
        
    });
    
    
    
    jQuery('.headpocs').live('click',function(){  
        var actScene = jQuery(this).attr('rel');
        prodlayerissetactScene = actScene;
        jQuery('#animation-holder').fadeTo("slow",0.45);
        jQuery("#"+actScene+"reklam").css({'display':'block'});
    });
    
    jQuery('#closetophead').live('click',function(){  
        var actScene = jQuery(this).attr('rel');
        prodlayerissetactScene = null;
        jQuery('#animation-holder').fadeTo("slow",1);
        jQuery("#"+actScene).css({'display':'none'});
    });
    
    var currSwf = "scene1";
    var nextSwf = null;
    var swfDiv = "tart";
    var swfintervalsetId = null;
    var imgintervalsetId = null;
    
    //swfobject.embedSWF("/2011toamna/swf/scene1.swf", "objectreplacer", "981", "551", "9.0.0", "expressInstall.swf", null, null,{wmode:"transparent"}, null);
    
    jQuery('.loadthisswf').live('click',function(){        
        nextSwf = jQuery(this).attr('id');
        if(nextSwf == currSwf){
            return false;
        }else{
            var loadswf = nextSwf.substr(nextSwf.length-1,nextSwf.length);
            loadswfNew = "/2011toamna/swf/"+currSwf+"-"+loadswf;
            jQuery().loadSwf(loadswfNew);
        }        	                
    });        
    
    jQuery.fn.loadSwf = function(loadswf){
        var newdiv = jQuery(document.createElement('div'));
        newdiv.attr('id','objectreplacer');        
        newdiv.css({
            'display':'block'
        });
        //swfobject.removeSWF("objectreplacer");        
        swfobject.embedSWF(loadswf+".swf", "objectreplacer", "980", "550", "9.0.0", "expressInstall.swf", null, null, null, jQuery().outputStatus(nextSwf,newdiv));
    }
    
    jQuery.fn.outputStatus = function(nswf,newdiv) {
        currSwf = nswf;        
        swfobject.removeSWF("objectreplacer");
        jQuery('#objectholder').append(newdiv);
        imgintervalsetId = setInterval(function(){
            jQuery().lodaimggg(currSwf);         
        }, 1000);
        
        swfintervalsetId = setInterval(function(){
            jQuery().loadSwfMain(currSwf);            
        }, 2855);
    }
    
    jQuery.fn.loadSwfMain = function(loadswf){
        clearInterval(swfintervalsetId);        
        swfobject.removeSWF("objectreplacer");        
        
//        var newdiv = jQuery(document.createElement('div'));
//        newdiv.attr('id','objectreplacer');        
//        newdiv.css({
//            'display':'block'
//        });      
//        swfobject.embedSWF("swf/"+loadswf+".swf", "objectreplacer", "980", "550", "9.0.0", "expressInstall.swf", null, null, null, jQuery().outputStatus2(loadswf,newdiv));
//        
        jQuery('.headpocs').attr('rel',currSwf);
		jQuery('.headpocs').attr('class','headpocs '+currSwf);
        
    }
    
    jQuery.fn.outputStatus2 = function(nswf,newdiv) {
        clearInterval(swfintervalsetId);        
        swfobject.removeSWF("objectreplacer");        
        jQuery('#objectholder').append(newdiv);          
    }
    
    jQuery.fn.lodaimggg = function(currSwfd) {
        var nextImg = "url('/2011toamna/img/"+currSwfd+"bg.jpg')";               
        jQuery('#objectholder').css({
            'background':nextImg
        });
        clearInterval(imgintervalsetId);  
    }
            
    
});
