function gyartDigitFormatumok( polc_id, ajId1, ajId2, tipus ){
	var url="index.php?option=com_whp&controller=epub&task=gyartDigitFormatumok&format=raw";
	url += "&polc_id="+polc_id;
	url += "&tipus="+tipus;	
	$j( "#"+ajId1 ).html( "<img src='components/com_whp/assets/images/ajax-loader.gif'>" );
	//alert(ajaxContentId);
	//alert(url);
	$j.ajax({
		url: url,
		type: "POST",
		async: false,
		success: function(response){
			var resp= $j.parseJSON( response );
			if( resp.error == '' ){
				$j( "#"+ajId1 ).html( resp.html );
				$j( "#"+ajId2 ).html( '' );
				download( resp.polc_id, resp.tipus );
			}else{
				alert( resp.error );
			}
		}
	});
}

function download( polc_id, tipus ){
	
	var url="index.php?option=com_whp&controller=epub&task=download&format=raw";
	url += "&polc_id="+polc_id;
	url += "&tipus="+tipus;	
	//alert( url );
	
	$j.ajax({
		url: url,
		type: "POST",
		async: false,
		success: function( response ){
			var resp= $j.parseJSON( response );
			if( resp.error == '' ){
				//alert(resp.html);
				var dwLink = "index.php?option=com_whp&controller=epub&task=downloadFile&format=raw";
				dwLink += "&polc_id=" + polc_id;
				dwLink += "&tipus=" + tipus;			
				//alert(dwLink)	
				window.location = dwLink;	
			}else{
				alert(resp.error);
			}
			getDwLinkek( polc_id );
		}
	});
}

function getDwLinkek( polc_id ){
	var url="index.php?option=com_whp&controller=epub&task=getDwLinkek&format=raw";
	url += "&polc_id="+polc_id;
	var ajaxContent = "ajaxContentDwl"+polc_id;
	$j( "#"+ajaxContent ).html("<img src='components/com_whp/assets/images/ajax-loader.gif'>");
	$j.ajax({
		url: url,
		type: "POST",
		async: false,
		success: function( response ){
			var resp= $j.parseJSON( response );
			if( resp.error == '' ){
				$j( "#"+ajaxContent ).html( resp.html );
			}else{
				alert(resp.error);
			}
		}
	});
}
