var selectOptionsShopNames = [];
var shopNamesStyled;
var selectOptionsShops = [];
var shopsStyled;
var childSelect;
var shopImageMaxWidth = 295;

var onLoadArr = [];

var openedCateg = 0;

var galleryThumbHeight = 70;
var galleryThumbCalcWidth = 0;

function showMenu(menuId) {
	$('#main_menu_bottom .menu_low').hide();
	$('#submenu_'+menuId).show();
}
function open3DWindow() {
	window.open('/3d_tura/westend.html','window','width=800,height=600,left='+(screen.availWidth/2-400)+',top='+(screen.availHeight/2-330)+'');
	return;
}
function openIkon() {
	window.open('/magazin/index.html','ikon','width=800,height=600,left='+(screen.availWidth/2-400)+',top='+(screen.availHeight/2-300)+',scrollbar=0,resizable=1,location=0');
	return;
}
function openIkonDefault(path) {
	window.open('/'+path+'/index.html','ikon','width=800,height=600,left='+(screen.availWidth/2-400)+',top='+(screen.availHeight/2-300)+',scrollbar=0,resizable=1,location=0');
	return;
}
function openIkonNyar() {
	window.open('/ikon_2009_nyar/index.html','ikon','width=800,height=600,left='+(screen.availWidth/2-400)+',top='+(screen.availHeight/2-300)+',scrollbar=0,resizable=1,location=0');
	return;
}
function openIkon2010Nyar() {
	window.open('/ikon_2010_nyar/index.html','ikon','width=800,height=600,left='+(screen.availWidth/2-400)+',top='+(screen.availHeight/2-300)+',scrollbar=0,resizable=1,location=0');
	return;
}
function openIkonOsz() {
	window.open('/ikon_2009_osz/index.html','ikon','width=800,height=600,left='+(screen.availWidth/2-400)+',top='+(screen.availHeight/2-300)+',scrollbar=0,resizable=1,location=0');
	return;
}
function openIkonTel() {
	window.open('/ikon_2009_tel/index.html','ikon','width=800,height=600,left='+(screen.availWidth/2-400)+',top='+(screen.availHeight/2-300)+',scrollbar=0,resizable=1,location=0');
	return;
}
function openIkonTavasz() {
	window.open('/ikon_2010_tavasz/index.html','ikon','width=800,height=600,left='+(screen.availWidth/2-400)+',top='+(screen.availHeight/2-300)+',scrollbar=0,resizable=1,location=0');
	return;
}
function switchImage(src, aElement) {
	$('img', aElement.parentNode).attr('src', src);
}
function childSelected(obj, selectName, parentSelect) {
	type = $('#'+parentSelect)[0][$('#'+parentSelect)[0].selectedIndex].value;
}
function searchGo(parentSelect,url) {
	var type = $('#'+parentSelect)[0][$('#'+parentSelect)[0].selectedIndex].value;
    var loc
    var target
	if (type == 'shopname') {
		targetSelect = $('#select_2')[0][$('#select_2')[0].selectedIndex].value;			
		loc = url+'?shop_id='+targetSelect;
	} else {
		targetSelect = $('#select_3')[0][$('#select_3')[0].selectedIndex].value;		
		loc = url+'?rand='+Math.random()+'#type_'+targetSelect;
	}
	if (loc) {
		window.location.href=loc;
	}		
}

function typeChanged(event, selectName, targetSelect) {
	type = $('#'+selectName)[0][$('#'+selectName)[0].selectedIndex].value;
}
function fillDefaultType(selectName,targetSelect,deftype) {
	if (deftype == 'shopname'){
		options = selectOptionsShopNames;		
	} else {
		options = selectOptionsShops;		
	}
	for (i=0;i<options.length;i++) {
		$('#'+targetSelect)[0].options[i] = options[i];		
	}	
	//$('#childSelectTD .legordulo_tarto').remove();	
	childSelect = new Legordulo('select_2', {szelesseg: 175, maxelem: 8});
	shopNamesStyled = childSelect;
}
function openPopup(pURL,name,w,h,scrollbars,resizable)
{
	if (resizable==null) resizable=1;
	if (scrollbars==null) scrollbars=1;
	var top  = ((screen.availHeight-h)/2);
	var left = ((screen.availWidth-w)/2);
	var nyit = window.open(pURL,name,'toolbar=0,location=0,directories=0,status=0,\
		menubar=0,scrollbars='+scrollbars+',resizable='+resizable+',width='+w+',height='+h+',top='+top+',left='+left);
	nyit.focus();
	return nyit;
}
function pageLoaded() {
	for (var i in onLoadArr) {
		onLoadArr[i]();
	}
}
function registerOnLoad(callback) {
	onLoadArr.push(callback);
}
function onMusic() {
	setCookie('music','1',30);
}
function offMusic() {
	setCookie('music','0',30);
}
function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
	    { 
	    c_start=c_start + c_name.length+1; 
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    	return unescape(document.cookie.substring(c_start,c_end));
	  } 
	}
	return "";
}
function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+"; path=/";
}

function shopDataImageResize() {
	imgs = $("#uzlet_image img");
	for (j=0;j<imgs.length;j++) {
		if (imgs[j].width>shopImageMaxWidth)
		{
			imgs[j].width = shopImageMaxWidth;
			$('#link_table').height = imgs[j].height;
		}
	}	
}
function hideDiv(id) {
	$('#'+id).hide();	
}

function setShopSearchSelects() {
	if ($('#select_1').val() == 'profile') {
		$('#select_2').hide();
		$('#select_3').show();
	} else {
		$('#select_2').show();
		$('#select_3').hide();
	}
}

function initShopSearchSelects() {
	$('#select_1').change(setShopSearchSelects);
	setShopSearchSelects();
}

function showGallery() {
    $('#gallery').overlay({
        top: 260,
        mask: {
            color: '#fff',
            loadSpeed: 200
        },
        load: true,
        target: '#gallery'
    });
//    $('#gallery .ad-gallery').overlay();
}

$(document).ready(initShopSearchSelects);

