var s_interval = 4500;
var s_last_num = 8;

var s_cur_num = 1;
var s_t;
var anim = false;

function PicturesSlideShowInit()
{
	$("#CG" + s_cur_num).fadeIn('slow', function() {
		StartTimer();
	});
}

function StartTimer()
{
	s_t = self.setInterval("ShowTitlePic()", s_interval);	
}

function ShowTitlePic(direction)
{
	//if ( anim ) {alert(anim);return;}
	
	
	$("#CG" + s_cur_num).stop().fadeOut('slow', function() {
		// hiding complete, start showing new pic
		anim = true;
		
		if ( direction == 'next' ) {
			if ( s_cur_num == s_last_num ) {
				s_cur_num = 1;
			} else {
				s_cur_num++;
			}
		} else if ( direction == 'prev' ) {
			if ( s_cur_num == 1 ) {
				s_cur_num = s_last_num;	
			} else {
				s_cur_num--;
			}
		} else {
			// If no direction argument, then just add one index to picture
			if ( s_cur_num == s_last_num ) {
				s_cur_num = 1;
			} else {
				s_cur_num++;
			}
		}
		
		if ( direction ) {
			window.clearInterval(s_t);
			$("#CG" + s_cur_num).stop().fadeIn('slow', function() {
				anim = false;
				StartTimer();
			});
		} else {
			$("#CG" + s_cur_num).fadeIn('slow', function() {
				anim = false;
			});
		}
	});
	
	
}

function ToggleHiddenText(obj, id)
{
	obj.style.display = "none";
	$("#" + id).show("slow");	
}

function HomepageHiddenTextInit()
{
	if ( !document.getElementById("Hellips") ) { 
		return;
	}
	
	var id;
	var idx;
	

	$("#HomepageCroppedBlock1").hover(function() {
		$("#HT1").stop().show();
		$("#HellipToHide1").hide();
	});
	
	$("#HomepageCroppedBlock1").mouseleave(function() {
		$("#HT1").stop().hide();
		$("#HellipToHide1").show();
	});	
	
	$("#HomepageCroppedBlock2").hover(function() {
		$("#HT2").stop().show();
		$("#HellipToHide2").hide();
	});
	
	$("#HomepageCroppedBlock2").mouseleave(function() {
		$("#HT2").stop().hide();
		$("#HellipToHide2").show();
	});	
	
	$("#HomepageCroppedBlock3").hover(function() {
		$("#HT3").stop().show();
		$("#HellipToHide3").hide();
	});
	
	$("#HomepageCroppedBlock3").mouseleave(function() {
		$("#HT3").stop().hide();
		$("#HellipToHide3").show();
	});	
	
		
	
}

// Статус консультанта и его отображение with custom images
function ShowPresidentSkypeStatus()
{
	 var username = 'marshalkin.miroslav';
	 var reservename = 'alexwilson2011';
     var skypeUrl = '/serverside/getskypestatus.php';

     $.get(skypeUrl, "{username:alexwilson2011}", function(data){
       var data = parseInt(data);
       var offlines = [0,6,1];
	   var a;
	   var isOffline = false;
	   
	   if ( data == 77 ) {
	   	   a = $('<a>').attr('href', 'skype:'+reservename+'?chat');
       	   img = $('<img>').attr('src','/i/skype/'+data+'.png').attr('border','0');
	   } else {
		   a = $('<a>').attr('href', 'skype:'+username+'?chat');
		   img = $('<img>').attr('src','/i/skype/'+data+'.png').attr('border','0');
	   }

       for(var i=0;i<offlines.length;i++){if(parseInt(data)==offlines[i])isOffline=true;};
       //!isOffline ? $('#SkypeStatus').append(a.append(img)).fadeIn(1000) : $('#SkypeStatus').append(img).fadeIn(1000)
	   if ( !isOffline ) {
	       $('#SkypeStatus').append(a.append(img)).fadeIn(1000) 
	   }
		
		
     });
}















