function foto(obr,idp,prip) {
	asirka = 600; //screen.availWidth;
	avyska = screen.height * 0.92; //screen.availHeight * 0.92;
	x = screen.width - asirka * 1.02;
	y = 0; // screen.height * 0.15;

	window.open("/foto.php?obrazok="+obr+"&produkt="+idp+"&prip="+prip, "", "left="+x+",top="+y+",width="+asirka+",height="+avyska+",scrollbars=yes,resizable=yes");
}
function foto2(obr,idp,prip) {
	asirka = 600; //screen.availWidth;
	avyska = screen.height * 0.92; //screen.availHeight * 0.92;
	x = screen.width - asirka * 1.02;
	y = 0; // screen.height * 0.15;

	window.open("/foto2.php?obrazok="+obr+"&aktualita="+idp+"&prip="+prip, "", "left="+x+",top="+y+",width="+asirka+",height="+avyska+",scrollbars=yes,resizable=yes");
}
function foto_partner(obr,idp,prip) {
	asirka = 1024; //screen.availWidth;
	avyska = screen.height * 0.92; //screen.availHeight * 0.92;
	x = screen.width - asirka * 1.02;
	y = 0; // screen.height * 0.15;

	window.open("/foto_partner.php?obrazok="+obr+"&partner="+idp+"&prip="+prip, "", "left="+x+",top="+y+",width="+asirka+",height="+avyska+",scrollbars=yes,resizable=yes");
}
function print(idp) {

	asirka = 600; //screen.availWidth;
	avyska = screen.availHeight * 0.92;
	x = screen.width - asirka * 1.02
	y = 0; // screen.height * 0.15;

	window.open("/print.php?idp="+idp, "", "left="+x+",top="+y+",width="+asirka+",height="+avyska+",scrollbars=yes,resizable=yes");
}
function cert(obr) {
	sirka = screen.width;
	vyska = screen.height;
	asirka = 625; //screen.availWidth;
	avyska = screen.availHeight * 0.92;

	x = screen.width - asirka * 1.02
	y = 0; // screen.height * 0.15;
	window.open("/image.php?url="+obr, "",  "left="+x+",top="+y+",width="+asirka+",height="+avyska+",scrollbars=yes,resizable=no");
	// window.open("/image.php?url="+obr, "", "scrollbars=yes,resizable=no");
}
function mapa(url) {

	asirka = 600; //screen.availWidth;
	avyska = screen.availHeight * 0.92;
	x = screen.width - asirka * 1.02;
	y = 0; // screen.height * 0.15;
	
	window.open("/mapa.php?url="+url, "", "left="+x+",top="+y+",width="+asirka+",height="+avyska+",scrollbars=yes,resizable=yes");
}
function zoom(id,zoomw,zoomh,zoompath,zoomtitle,text){ 

	asirka = 625; //screen.availWidth;
	avyska = screen.availHeight * 0.92;

	x = screen.width - asirka * 1.02;
	y = 0; // screen.height * 0.15;
	
	zoom_console = window.open("",id,"left="+x+",top="+y+",width="+asirka+",height="+avyska+",scrollbars=auto,resizable=yes"); 
	zoom_console.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><title>foto</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link rel="stylesheet" type="text/css" href="/css.css"><body class="okno">'); 
	zoom_console.document.write('<div class="oknoimg"><img onclick="window.close()" style="cursor:hand" src="'+zoompath+'" width="'+zoomw+'" height="'+zoomh+'" alt="'+zoomtitle +"\n \n"+'  Klikni a zavrieš okno" border="0"></div>'); 
	zoom_console.document.write('<a class="oknoclose" href="javascript:window.close()" title="'+text+'">'+text+'</a>'); 
	zoom_console.document.write("</body></html>"); 
	zoom_console.document.close(); 
	return true; 
}
function flip(cislo, akcia) {
	var obj

	if (akcia == 1) {
		obj = document.getElementById('katobr')
		obj.style.display = 'block';
		obj = document.getElementById('katobrimg')
		obj.src = cast + 'kategorie/' + cislo + '.jpg'

	} else {
		obj = document.getElementById('katobr')
		obj.style.display = 'none'

		
	}

}


/**
 * KONTAKT - dealers
 */
function updateDealerDetails( arjIDs) {
	// Declarations
	var nRegionID = arjIDs[0];
	var nShireID = arjIDs[1];
	var strShireName = m_arjRegions[nRegionID]['shires'][nShireID][0];
	var strEmail = m_arjRegions[nRegionID]['shires'][nShireID][1]['email'];
      		
	// Update dealers data
	$(".region_name").text( "Zástupca pre : "+ strShireName);
	$(".dealer_name").text( m_arjRegions[nRegionID]['shires'][nShireID][1]['name']);
	$(".dealer_phone").text( "tel. : "+ m_arjRegions[nRegionID]['shires'][nShireID][1]['phone']);
	$(".dealer_email").html( "e-mail : <a href='mailto:"+ strEmail +"'>"+ strEmail +"</a>");
}

$(document).ready(function() {	
	/** Preaload banner pictures
         */

	// Declarations
	var cacheImage = document.createElement('img');
	var imagesCache = new Array();
	
	// Add "banner"
	cacheImage.src = '/img/banner.jpg';
	imagesCache.push(cacheImage);

	// Add "banner:hover"
	cacheImage.src = '/img/banner_WhenMouseOn.jpg';
	imagesCache.push(cacheImage);
	    
	// Add all regions to "SELECT" component
	for ( i=0;i<m_arjRegions.length;i++) {
		// Add all shires of particular region
		for ( a=0;a<m_arjRegions[i]['shires'].length;a++) {
			// Declarations
			var nOptionVal = i +"."+ a;

			// Add particular shire
			$("#regions").append( "<option class='shire' value='"+ nOptionVal +"'>"+ m_arjRegions[i]['shires'][a][0] +"</option>");					
		}
	}

	// Select by default first shire
	updateDealerDetails( new Array( 0, 0));
			
	// Event: When some regions was selected
	$("#regions").change(function () {
		// Declarations
		var arjIDs = $(this).attr("value").split(".");
       		
		// Update dealers data
		updateDealerDetails( arjIDs);
	});
});

