function Vote(id, module, mode, div){
	httpObject = getHTTPObject();
	
	if (httpObject != null) {
		
		httpObject.open("GET", path + "/modules/video/vote.php?id=" +id + "&module=" + module + "&mode=" + mode, true);
		httpObject.send(null);
		httpObject.onreadystatechange = function(){
		
			if(httpObject.readyState == 4){
				document.getElementById(div).innerHTML =  httpObject.responseText;
			}
		}

	}

}

var rotate = new Array();

function Rotate(file, id, i, duration, width){
	if ( width == null ){ width = 128; }

	if (  rotate[id] == true ){
		i++;
		if ( i > 3 ){ i = 1; }
		
		document.getElementById(id).src = path + "/image.php?imageFile=http://www.budalizacija.hr/download/" + file + "/thumb-" + i + ".jpg&newWidth=" + width + "&player=" + duration;
		setTimeout("Rotate('" + file  + "','" + id + "'," + i +",'" + duration + "','" + width + "')", 1000);
		
	}
			
}

function StartRotating(file, id, duration, width){
	if ( width == null ){ width = 128; }
	
	rotate[id] = true;
	setTimeout("Rotate('" + file + "','" + id + "',1,'" + duration + "','" + width + "')",500);
			
}


function RestoreImage(file, id, duration, width){
	if ( width == null ){ width = 128; }

	rotate[id] = false;
	document.getElementById(id).src = path + "/image.php?imageFile=http://www.budalizacija.hr/download/" + file + "/thumb-1.jpg&newWidth=" + width + "&player=" + duration;
	
}


function AddToFavorites(id){
	
	httpObject = getHTTPObject();
	
	if (httpObject != null) {
		
		httpObject.open("GET", path + "/modules/video/add_to_favorites.php?id=" +id , true);
		httpObject.send(null);
		httpObject.onreadystatechange = function(){
		
			if(httpObject.readyState == 4){
					document.getElementById('favorite_img').src = httpObject.responseText;
			
		}

		}
	
	}
	
	active = document.getElementById("favorite").innerHTML;
	new_active = document.getElementById("favorite2").value;
	 
	document.getElementById("favorite").innerHTML = new_active;
	document.getElementById("favorite2").value = active;

}


function SendToFriend(id){
	
	httpObject = getHTTPObject();
	

	var url = path + "/modules/video/send_to_friend.php";
	var params = "id=" + id + "&name=" + document.getElementById('your_name').value + "&mail=" + document.getElementById('friends_mail').value;
	httpObject.open("POST", url, true);

	httpObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	httpObject.setRequestHeader("Content-length", params.length);
	httpObject.setRequestHeader("Connection", "close");

	httpObject.onreadystatechange = function() {
		if(httpObject.readyState == 4 && httpObject.status == 200) {
			ShowHideDiv('send_to_friend');
		}
	}
	httpObject.send(params);

}


function SetOnWebsiteCode(template, id){
	httpObject = getHTTPObject();
	
	if (httpObject != null) {
		
		httpObject.open("GET", path + "/modules/video/set_on_website.php?id=" + id + "&file=" +template , true);
		httpObject.send(null);
		httpObject.onreadystatechange = function(){
		
			if(httpObject.readyState == 4){
				document.getElementById('set_on_website_code').innerHTML = httpObject.responseText;
			}
		}

	}
	
}


function ShowLastVideo(num){

	var x= null;
	
	for ( i = 0; i <= 5; ++i ){
		
		 x = (i == num) ? 'block' : 'none'; 
			
		document.getElementById('last_videos_description_' + i).style.display = x;
	}
	
}




var httpObject = null;
