var headline_count;
 var headline_interval;
 var old_headline = 0;
 var current_headline = 0;
 
 $(document).ready(function(){
 
   headline_count = $("div.headline").size();
   $("div.headline:eq("+current_headline+")").css('top','5px');
 
   headline_interval = setInterval(headline_rotate,8000); //time in milliseconds
   $('#scrollup').hover(function() {
     clearInterval(headline_interval);
   }, function() {
     headline_interval = setInterval(headline_rotate,8000); //time in milliseconds
     headline_rotate();
   });
 });
 
 function headline_rotate() {
   current_headline = (old_headline + 1) % headline_count; 
   $("div.headline:eq(" + old_headline + ")").animate({top: -205},"slow", function() {
     $(this).css('top','210px');
   });
   $("div.headline:eq(" + current_headline + ")").show().animate({top: 5},"slow");  
   old_headline = current_headline;
 }

///////////////////////////////////////////////////////////////////////



function getLight(_obj){
            _obj.colorBlend([{fromColor:"white", toColor:"#B01B2E", alpha:"100,40", isFade:false, cycles:1, duration: 500}]);
}

function getNormal(_obj){
            _obj.colorBlend([{fromColor:"#B01B2E", toColor:"white", alpha:"40,100", isFade:false, cycles:1, duration: 1000}]);
}
function showDetails(){
    
    var _refcode=$('#indexRefcode').val();
    
    if(_refcode.indexOf("I")==0 || _refcode.indexOf("i")==0){
    	 window.open('detailsInvestment.php?refcode='+_refcode.substr(1));
    }else{
    
   	 window.open('details.php?refCode='+_refcode);
  	}
}

function keyPressed(evt){
    evt=(evt)?evt:event;
    var charCode=(evt.which)?evt.which:evt.keyCode;
    //alert("char="+charCode);
    if(charCode==13){
       showDetails()
    }else if(charCode==27){
    	//reset();
		}
}
function showCredits(){
   // alert('fffff');
     

    var _sir;
    var _duz;

if(window.innerWidth!=undefined) _sir=window.innerWidth;
    else _sir=document.documentElement.clientWidth;    
    if(_sir==0) _sir=document.body.clientWidth;   
    
    
   // alert('siz='+_sir);
    
    var _sirMainBody=$('#mainTable').width();
    //alert(_sirMainBody);
    
    
   /* if(window.innerHeight!=undefined) _duz=window.innerHeight;
    else _duz=document.documentElement.clientHeight;    
    alert('duz11='+_duz);*/
     _duz=document.body.scrollHeight;   
   // alert('duz='+_duz);
    
    
    var _duzMainBody=$('#mainBody').attr('scrollHeight');
    //alert("duzMain="+_duzMainBody);


    
    
    var _sirCredits=$('#credits').width();
   // alert("sirCred="+_sirCredits);

    var _duzCredits=$('#credits').height();
  // alert("duzCred="+_duzCredits);


    var _credHeight='150px';
    var _credWidth='400px';
    
    _credLeft=_sir-(_sir-_sirMainBody)/2-_sirMainBody;
    _credTop=_duzMainBody-_duzCredits-80;
    
    //alert(_credTop);
    
    $('#credits').css('left',_credLeft+'px');
    $('#credits').css('top',_credTop+'px');
   // $('#credits').css('display','block');
    
    //$('#loading').show();


 $(".scalefx").toggle("scale", { 
        origin: ["bottom", "right"] 
    }, 
    1000); 
    
}
