$(document).ready(function() {
	if (location.href.indexOf("compatibility.html") == -1) $("div.phone").css('opacity','0');
	
	$("#blackberry").css('opacity','1');
	var width = 105;
	var count = $('#blackberry a').length;
	$('#container').css('width', count*width);

	$('#bb').click(function(){
		$("div.phone").animate({
			opacity: '0'
		}, 500);
		$("div#container").animate({
			left: '0'
		}, 600);
		var count = $('#blackberry a').length;
		$('#container').css('width', count*width);
		$("#blackberry").animate({
			opacity: '1'
		}, 500);

	});
	
	$('#andr').click(function(){
		$("div.phone").animate({
			opacity: '0'
		}, 500);
        $('#android img[src="/images/no-image.gif"]').each(function(){
            $(this).attr('src',$(this).attr('title'));
            $(this).attr('title',$(this).attr('alt'));
        });
		$("div#container").animate({
			left: '0'
		}, 600);
		var count = $('#android a').length;
		$('#container').css('width', count*width);
		$("#android").animate({
			opacity: '1'
		}, 500);

	});

	$('#iphn').click(function(){
		$("div.phone").animate({
			opacity: '0'
		}, 500);
        $('#iphone img[src="/images/no-image.gif"]').each(function(){
            $(this).attr('src',$(this).attr('title'));
            $(this).attr('title',$(this).attr('alt'));
        });
		$("div#container").animate({
			left: '0'
		}, 600);
		var count = $('#iphone a').length;
		$('#container').css('width', count*width);
		$("#iphone").animate({
			opacity: '1'
		}, 500);

	});

	$('#winmob').click(function(){
		$("div.phone").animate({
			opacity: '0'
		}, 500);
        $('#windows img[src="/images/no-image.gif"]').each(function(){
            $(this).attr('src',$(this).attr('title'));
            $(this).attr('title',$(this).attr('alt'));
        });
		$("div#container").animate({
			left: '0'
		}, 600);
		var count = $('#windows a').length;
		$('#container').css('width', count*width);
		$("#windows").animate({
			opacity: '1'
		}, 500);

	});

	$('#symb').click(function(){
		$("div.phone").animate({
			opacity: '0'
		}, 500);
        $('#symbian img[src="/images/no-image.gif"]').each(function(){
            $(this).attr('src',$(this).attr('title'));
            $(this).attr('title',$(this).attr('alt'));
        });
		$("div#container").animate({
			left: '0'
		}, 600);
		var count = $('#symbian a').length;
		$('#container').css('width', count*width);
		$("#symbian").animate({
			opacity: '1'
		}, 500);

	});
	
	$('a#next').click(function(){
		var pos = parseInt($('#container').css('width'))+parseInt($('#container').css('left'));
		if(pos > 700 ){
			$('#container').animate({
				left: '-=700px'
			}, 500);
		}else{
			$('#container').animate({
				left: '0px'
			}, 500);

		}
	});
	
	$('a#prev').click(function(){
		if ($('#container').css('left') < '0px'){
			$('#container').animate({
				left: '+=700px'
			}, 500);
		}
	});
	var st = 0;
	$('a#down').click(function(){
		st++;
		var poss = parseInt($('#text_scroll').css('height'))+parseInt($('#text_scroll').css('top'));

		if ((st % 3) == 0) 
		{
			$(this).parents('.miniBlock').children('.redText').html('Roberta');
			$(this).parents('.miniBlock').children('em').html('Chicago, USA');
		}
		if ((st % 3) == 1)
		{
			$(this).parents('.miniBlock').children('.redText').html('Adam');
			$(this).parents('.miniBlock').children('em').html('Sydney, Australia');
		}
		if ((st % 3) == 2)
		{
			$(this).parents('.miniBlock').children('.redText').html('Barry');
			$(this).parents('.miniBlock').children('em').html('London, UK');
		}
		
		if(st < 3){
			$('#text_scroll').animate({
				top: '-=190px'
			}, 500);
		}else{
			$('#text_scroll').animate({
				top: '0px'
			}, 500);
			st = 0;
			$(this).parents('.miniBlock').children('.redText').html('Roberta');
			$(this).parents('.miniBlock').children('em').html('Chicago, USA');
		}

	});

	
	
});
