
Index = function( )
{

    
    this.init = function( sBaseUrl )
    {
    	
    	this.self = this;
    	this.bReady = false;
    	this.iScrollCount1 = 0;
    	this.iScrollCount2 = 0;
    	this.rTimer1 = 0;
    	this.rTimer2 = 0;
    	this.nextCat = 1;
    	this.ajaxId = 0;
    	this.ajaxObj = 0;
    	
    	this.sBaseUrl  = sBaseUrl;
        this.bReady    = true;
    	$('#magazin').cycle({
		    fx:     'scrollRight',
		    speed:  'slow',
		    timeout: 10000,
		    pager:  '#nav3',
		    next:   '#next3', 
			prev:   '#prev3',
			pause:   1  
		});
        this.searchWidth = $("#search_string").css("width");
        IndexObject.getIcqStatus();
        
        
		
     
    
    }
    
    this.initEffects = function(  )
    {
         
         $('#statistic_1').cycle({
		    fx:     'fade',
		    speed:  'slow',
		    timeout: 5000,
		    pager:  '#nav1',
		    next:   '#next1', 
			prev:   '#prev1',
			pause:   1  
		});
		
		var t = setTimeout(function() {
			 
										$('#statistic_2').cycle({
										    fx:     'fade',
										    speed:  'slow',
										    timeout: 5000,
										    pager:  '#nav2',
										    next:   '#next2', 
											prev:   '#prev2',
											pause:   1  
										});
										
										}, 1000);
										
		
		
		 this.bAdsRedy = true;
         this.AdsTimer = setInterval("IndexObject.AdsNext()",3000);

         $("div#smallScroller").smoothDivScroll({mouseDownSpeedBooster: 2, scrollingSpeed: 7});
    
    }
    
    this.stopAds = function()
    {
    	 this.bAdsRedy = false;
    }
    
    this.startAds = function()
    {
    	this.bAdsRedy = true;
    }
    
    this.AdsNext = function( )
    {
    	if( this.bAdsRedy )
    	{
    		var obj = $('#news-ticker div:first');
    		$(obj).slideToggle("slow");
    		var t = setTimeout(function() { $(obj).appendTo('#news-ticker');$(obj).show("slow"); }, 1000);
    	}
	
    }
    
    this.searchFieldBlur = function( sDefaultString, obj )
    {
        if(!this.bReady) return;
        if( obj.value == '' ) obj.value = sDefaultString;
        $(obj).css({"position":"",'top':'','left':''});
        $(obj).css("width",this.searchWidth);
    }
    
    this.searchFieldFocus = function( sDefaultString, obj )
    {
        if(!this.bReady) return;
        if( obj.value == sDefaultString ) obj.value = '';
        
        var position = $(obj).offset();
        var width = position.left -  4*(position.left/5) ;
        $(obj).css({"position":"absolute",'top':position.top+"px",'left':position.left-width+'px'});
        $(obj).css("width",$(obj).width()+width+'px');
    }
    
    this.startPreload = function( id, bgcolor )
    {    
        if( !this.bReady ) return;
        $("#ajaxPreloader").css("background-color",bgcolor);
        var oAjaxPreloader = document.getElementById( 'ajaxPreloader' );
        oAjaxPreloader.style.height  = document.getElementById( id ).clientHeight + 'px';
        oAjaxPreloader.style.width   = document.getElementById( id ).clientWidth + 'px';
        var el = document.getElementById( id );
        var offset = getAbsolutePosition(el); 
        oAjaxPreloader.style.top     = offset.y +'px';  
        oAjaxPreloader.style.left    = offset.x +'px';
        oAjaxPreloader.style.display = 'block';
    }
    
    this.endPreload = function( )
    {
        if( !this.bReady ) return;
        var oAjaxPreloader = document.getElementById( 'ajaxPreloader' );
        oAjaxPreloader.style.display = 'none';
    }
    
    this.ajaxLoad = function( sPath )
    {
        if( !this.bReady ) return;
        IndexObject.startPreload('calendar','#fff');
        sUrl = this.sBaseUrl + "Events/get/" + sPath; 
       $("#calendar").load(sUrl, {}, function (responseText, textStatus, XMLHttpRequest) { 


			IndexObject.endPreload();

											} );   
    } 
    
        
    this.getText = function (id) 
    {
        return $("#"+id).text();
    }
    
    
    
    this.SelectCat = function ( obj )
    {
 
    	if( !this.bReady ) return;
        this.ajaxId = $(obj).attr("id");
        var Id = $(obj).attr("rid");
        this.ajaxObj = obj;
        sUrl = this.sBaseUrl + "Technic/ajax/"+ this.nextCat +"/" + Id;
        
       this.startPreload("technic"+this.nextCat, '#F2F2F2');
       
       $("#technic"+this.nextCat).load(sUrl, {}, function (responseText, textStatus, XMLHttpRequest) { 

							    if(textStatus == 'success')
							    {
	    	   						if(IndexObject.nextCat == 1)
	    	   						{
	    	   							$('#scrollmenu > img').filter('.border_red').attr( 'class', 'border_gray' );

	    	   							$(IndexObject.ajaxObj).attr( 'class', 'border_red' );
	    	   						}
	    	   						else
	    	   						{
	    	   							$('#scrollmenu > img').filter('.border_green').attr( 'class', 'border_gray' );
	    	   							$(IndexObject.ajaxObj).attr( 'class', 'border_green' );
	    	   						}
								   	IndexObject.nextCat++;
									if(IndexObject.nextCat == 3) 
									{
										IndexObject.nextCat = 1;
									}
							    }
								
								IndexObject.endPreload();

       														} );
							    	
    	
    }
    
    this.getIcqStatus = function (  )
    {
    	var sUrl ="http://status.icq.com/online.gif?icq=569130385&img=5";
    	$("#icq").attr('src',sUrl);      	
    }
    
    
    
}

IndexObject = new Index(  );

function iendPreload( )
{
    IndexObject.endPreload( );    
}

function getAbsolutePosition(el) {
    var r = { x: el.offsetLeft, y: el.offsetTop };
    if (el.offsetParent) {
        var tmp = getAbsolutePosition(el.offsetParent);
        r.x += tmp.x;
        r.y += tmp.y;
    }
    return r;
}




function popup_s( id )
{
	$( '#popup_s'+ id ).slideToggle("slow");
}





