function change_class(id,id2,counter,klasa) {
	for(var i = 1; i <= counter; i++){
		if(window.document.getElementById(id+i)){
			window.document.getElementById(id+i).className = '';
		}
	}
	window.document.getElementById(id+id2).className = klasa;
}

/*function get_root(){
	// alert(document.location.hostname);
	if(location.host == 'localhost') {
		var loc = "http://localhost/Auto-info";
	} else {
		var loc = "http://www.auto-info.com";
	}
	return loc;
}*/

//var root = location.protocol + '//' + location.host+'/Auto-info/';
var root = location.protocol + '//' + location.host+'/';

function switch_image(id,id2){
	if(id == 'like'){
		window.document.getElementById('like_img'+id2).src = ""+root+"/images/like_n.gif";
	} else {
		window.document.getElementById('dislike_img'+id2).src = ""+root+"/images/dislike_n.gif";
	}
}

function komentiraj_clanak(id1, id2, id3, id4){
	//if(id1 != ''){
		id3 = document.getElementById(id3).value;
		id4 = document.getElementById(id4).value;
		//id3 = id3.trim();
		//alert(id4);
		/*if(id4 == '') {
			alert("Niste unijeli kod sa slike.");
		} else*/ if(id3 != '') {
			//alert(encodeURIComponent(id3).length);
			//if(encodeURIComponent(id3).length <= 500){
    			makerequest(''+root+'/ajax/komentari_clanci.php?korisnik_id='+id1+'&clanak_id='+id2+'&komentar='+encodeURIComponent(id3)+'&6_letters_code='+encodeURIComponent(id4)+'', 'komentari_upis');
    			document.forma.komentar_area.value = '';
    			//alert("Uspješno ste upisali poruku");
    			//window.setTimeout("sakrij_poruku()", 5000);
			/*} else {
				alert('<?php echo DULJINA_KOMENTARA_PORUKA;?>');
			}*/
		} else {
			alert("Niste unijeli poruku.");
		}
	/*} else {
		alert("Niste logirani.");
	}*/
}


function addBookmark(title, url) {
	if (window.sidebar) { // firefox
	window.sidebar.addPanel(title, url,"");
	} else if( document.all ) { //MSIE
	window.external.AddFavorite( url, title);
	} else {
	alert("Vaš browser ne podržava ovu opciju");
	}
}





	function slide_left()
	{
		var a = $('#slide_holder');
		var w = a.width();
		
		var leftstop = 560 - w;
		
		var p = a.position();
		
		a.stop().animate({
			left:'-=112'
		}, 500, function(){
			var p = a.position();
			
			if(p.left <= leftstop)
			{
				a.animate({
					left:leftstop
				}, 100);
			}
		});
	}
	
	function slide_right()
	{
		var a = $('#slide_holder');
		
		var p = a.position();
	
		if(p.left <= 0)
		{
			a.stop().animate({
				left:'+=112'
			},500, function(){
				var p = a.position();
				
				if(p.left > 1)
					a.animate({
						left:0
					}, 100);
			});
		}
	}
