$(document).ready(function(){
       form_fizyczna();
	   adres_konto();
	   $('div #registerForm').ajaxForm({ 
		target: '#registerComment'
    	});
	   $('div #newsletterForm').ajaxForm({ 
		target: '#newsletterComment'
    	});	
}); 

function roll(where, what)
{
	document.getElementById(where).src = 'templates/image/logos/'+what+'.gif';
}

function form_prawna()
{
	$("#nazwa").show();
	$("#nip").show();
}

function form_fizyczna()
{
	$("#nazwa").hide();
	$("#nip").hide();
}

function doSearch(lang)
{
	document.location.href = lang+'_search_query_'+document.getElementById('query').value+'.html';
}

function handleEnter (lang, field, event)
{
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13)
	{
		var i;
		for (i = 0; i < field.form.elements.length; i++)
			if (field == field.form.elements[i])
				break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			field.form.elements[i].click();
		return false;
	}
	else
		return true;
}

function adres_konto()
{
	$("#konto_ulica").show();
	$("#konto_nr_dom").show();
	$("#konto_nr_mieszkanie").show();
	$("#konto_miasto").show();
	$("#konto_kod_pocztowy").show();
	
	$("#inny_ulica").hide();
	$("#inny_nr_dom").hide();
	$("#inny_nr_mieszkanie").hide();
	$("#inny_miasto").hide();
	$("#inny_kod_pocztowy").hide();
}

function adres_inny()
{
	$("#konto_ulica").hide();
	$("#konto_nr_dom").hide();
	$("#konto_nr_mieszkanie").hide();
	$("#konto_miasto").hide();
	$("#konto_kod_pocztowy").hide();
	
	$("#inny_ulica").show();
	$("#inny_nr_dom").show();
	$("#inny_nr_mieszkanie").show();
	$("#inny_miasto").show();
	$("#inny_kod_pocztowy").show();
}

function openDiv(div, filePath, fileName)
{
    var content = document.getElementById(div).innerHTML;
	var filePath = filePath.substring(0, filePath.length-1);
	
    NewWindow=window.open("", "","width=500,height=150,toolbar=no,directories=no,menubar=no,locations=no,status=no,scrollbars=yes,resizable=no,fullscreen=no");
    NewWindow.document.open();
    NewWindow.document.writeln(content);
	NewWindow.document.getElementById('file').innerHTML = fileName;
	NewWindow.document.getElementById('Path').value = filePath;
	NewWindow.document.getElementById('Name').value = fileName;
	NewWindow.document.getElementById('newName').value = fileName;
    NewWindow.document.close();
    NewWindow.focus();

}

function putPath(co)
{
	document.getElementById('filePath').value = 'media/'+co;
}

function redirectResponse()
{
	document.location.href = 'pl_sessionphotoadd.html';
}

function jumpTo(gdzie)
{
	document.location.href = gdzie;
}

function showRules()
{
	$("#regulamin").toggle();
}

function confirmDelUsr()
{
	if (confirm('Czy na pewno chcesz usunąć swoje konto?')){
	window.location.href = 'pl_delusr.html' }
	else {
	//window.location.href = 'exit.html' 
	} 
}

function setKroki(count)
{
	document.getElementById('krokLast').innerHTML = count;
}

function loadGM()
{
	if(GBrowserIsCompatible())
	{
		baseIcon = new GIcon();  
		baseIcon.iconSize = new GSize(32,32);  
		baseIcon.shadowSize = new GSize(56,32);  
		baseIcon.iconAnchor = new GPoint(16,32);  
		baseIcon.infoWindowAnchor = new GPoint(16,0);

		var map = new GMap2(document.getElementById("mapa"));
		var ikona = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon7.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon7s.png');
		
		map.addControl(new GSmallZoomControl());
		map.setCenter(new GLatLng(54.1800266, 19.4051044), 16);
		
		var info = '<div style="background#fff; width:250px; height:140px; text-align:center;">';
		info += '<img src="templates/image/fb.gif" alt="" /><br />';
		info += '<b>Fotoboard - obrazy na płótnie</b>';
		info += '<hr style="height:1px; border:0; color:#ccc; background:#ccc;" />';
		info += 'ul. Płk. Dąbka 138/1, 82-300 Elbląg<br />tel. (55) 236-16-07<br /><a href="http://www.fotoboard.com.pl/">www.fotoboard.com.pl</a>';
		info += '<hr style="height:1px; border:0; color:#ccc; background:#ccc;" />';
		info += '</div>';
		
		var point = new GLatLng(54.18014810965086, 19.405299425125122);
		var marker = new GMarker(point, ikona)  
		map.addOverlay(marker);
		
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(info);
		});
		marker.openInfoWindowHtml(info);
	}
}

function flash(w, h, path)

{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'">'
	+'<param name="movie" value="'+path+'" />'
	+'<param name="quality" value="high" />'
	+'<param name="menu" value="0" />'
	+'<param name="wmode" value="transparent" />'
	+'<embed src="'+path+'" width="'+w+'" height="'+h+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="0" wmode="transparent"></embed>'
	+'</object>');
}