var hakijat = 0;

// JavaScript Document
$(document).ready(function()
{
	$('#add_people').bind("click",function()
	{
		var row = $('#newpeople').clone();

		$('#application_peoples').append(row.html());

		hakijat++;
		
		binds();
	});
});

function binds()
{
	$('.add_people').bind("click",function()
	{
		var row = $('#newpeople').clone();

		$('#application_peoples').append(row.html());
		
		hakijat++;
		
		binds();
	});
}

function checkHak()
{
	if(hakijat > 0)
	{
		return true;
	}
	else
	{
		alert("Et ole lisännyt hakemukseen yhtään hakijaa. Tallennus epäonnistui!");
		
		return false;
	}
}

function CheckIsIE()
{
	if (navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER') { return true;}
	else { return false; }
}


function PrintThisPage()
{
	$.post(ROOTURL + 'applications/print_application',function(response)
	{
		//$('#printcontent').html(response);
		
		var oContent = response;
		
		try
		{
			var oIframe = document.getElementById('application_print');
			//var oContent = document.getElementById('printcontent').innerHTML;
			var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
			if (oDoc.document) oDoc = oDoc.document;
			oDoc.write("<html><head><title>asuntohakemus</title>");
			oDoc.write("</head><body onload='this.focus(); this.print();'>");
			oDoc.write(oContent + "</body></html>");
			oDoc.close();
		}
		catch(e)
		{
			self.print();
		}
	
	});
}



	
