var changeColors=1;
function addClick(radio) {
	$.ajax( {
		url : '/act.php?act=1',
		type : 'POST',
		timeout : 30000,
		data : {
			'radio' : parseInt(radio)
		},
		error : function() {
			//alert('Error none');
		},
		success : function(xml) {
			$('#clicks' + radio).html(xml);
			//location.reload();
		}
	});
}
function iLikeit(radio) {
	$.ajax( {
		url : '/act.php?act=2',
		type : 'POST',
		timeout : 30000,
		data : {
			'radio' : parseInt(radio)
		},
		error : function() {
			//alert('Error none');
		},
		success : function(xml) {
			if (parseInt(xml) > 0) {
				$('#myplaylist').html(xml);
				$('#myplaylist2').html(xml);
			}
		}
	});
}
function iNotLikeit(radio) {
	var answer = confirm("Išbraukti stotį iš grojaraščio?");
	if (answer) {
		$.ajax( {
			url : '/act.php?act=3',
			type : 'POST',
			timeout : 30000,
			data : {
				'radio' : parseInt(radio)
			},
			error : function() {
				//alert('Error none');
			},
			success : function(xml) {
				$('#span' + radio).html(xml);
				location.reload();
			}
		});
	}
}
function trackLink(radio) {
	$.ajax( {
		url : '/act.php?act=4',
		type : 'POST',
		timeout : 30000,
		data : {
			'radio' : parseInt(radio)
		},
		error : function() {
			//alert('Error none');
		},
		success : function(xml) {
		}
	});
}
function showHelp(obj) {
	var pos = $(obj).offset();
	var width = $(obj).width();
	var height = $('#helpdiv').height;
	var height2 = $(obj).height;
	$('#helpdiv').css( {
		"left" : (pos.left - width * 2) + "px",
		"top" : pos.top - 169 + "px"
	});
	$('#helpdiv').show();
	changeColors = 1;
	changeColor(1,0);
}
function changeColor(col,count) {
	if (changeColors == 1 && count<100) {
		setTimeout(function() {
			if (col == 0) {
				changeTo = 1;
				colors = 'red';
				decoration = 'underline';
			} else {
				changeTo = 0;
				colors = 'white';
				decoration = 'none';
			}

			$('.PATINKA').css( {
				color : colors
			});
			$('.PATINKA').css( {
				"text-decoration" : decoration
			});
			changeColor(changeTo,++count);
		}, 400);
	} else {
		changeTo = 0;
		colors = 'white';
		decoration = 'underline';
		$('.PATINKA').css( {
			color : colors
		});
		$('.PATINKA').css( {
			"text-decoration" : decoration
		});
	}
}
function hideHelp() {
	changeColors = 0;
	$('#helpdiv').hide();
	colors = 'white';
	decoration = 'underline';
	$('.PATINKA').css( {
		color : colors
	});
	$('.PATINKA').css( {
		"text-decoration" : decoration
	});
}


function changeColorById(col,count,id) {
	if (changeColors == 1 && count<100) {
		setTimeout(function() {
			if (col == 0) {
				changeTo = 1;
				colors = 'red';
				decoration = 'underline';
			} else {
				changeTo = 0;
				colors = 'white';
				decoration = 'none';
			}

			$('#'+id).css( {
				color : colors
			});
			$('#'+id).css( {
				"text-decoration" : decoration
			});
			changeColorById(changeTo,++count,id);
		}, 400);
	} else {
		changeTo = 0;
		colors = 'white';
		decoration = 'underline';
		$('#'+id).css( {
			color : colors
		});
		$('#'+id).css( {
			"text-decoration" : decoration
		});
	}
}

$(document).ready(function() {
	changeColorById(1,0,'chat')
});
