window.onunload = function() {
	if (document.getElementById("WebGalery2SWF") && document.getElementById("WebGalery2SWF").SetVariable) {
		document.getElementById("WebGalery2SWF").SetVariable("htmlPageState",
				"unloading");
	}
}
function evWiz1Click(){
		OverPageBrowser.instance.createSwfPlayer('/modules/layout/VisualizationsGalery.swf',[884,460],{debug:'true',stage:'etap I'},null,{id:'Wiz2Player',wmode:'transparent'})
		return false
}
function evWiz2Click(){
	OverPageBrowser.instance.createSwfPlayer('/modules/layout/VisualizationsGalery.swf',[884,460],{debug:'true',stage:'etap II'},null,{id:'Wiz2Player',wmode:'transparent'})
	return false
}
function assignWizualizacjeStarter(){
	document.getElementById('galeria.wizualizacje.mieszkan').onclick=function(){
		$('#divMenu261').fadeIn()
		return false
	}
	document.getElementById('wizualizacje1').onclick=evWiz1Click
	document.getElementById('wizualizacje2').onclick=evWiz2Click
}
onLoadQueue.appendOnLoad(assignWizualizacjeStarter)
function communicatePromotions(flat, building, promotions,price) {
	var p = {}
	p.success = function(data) {
		var ar = data.content
		var html = ''
		html += '<div class="overBlock">'
		html += '<div class="promoHeader">'
		html += '<div class="promoHeaderLabels">'
		html += '</div>'
		html += '<div class="promoHeaderValues">'
		html += flat
		html += '<br/>' + building
		html += '</div>'
		html += '</div>'
		for ( var i = 0; i < ar.length; i++) {
			html += '<div class="promoPortion">'
			html += '<h5>' + ar[i].data.field_values.title.field_value + '</h5>'
			html += '<div>' + ar[i].data.field_values.short.field_value + '</div>'
			var isSuggest = String(ar[i].data.field_values.id.field_value)
					.indexOf('suggestPrice') > -1
			html += '<table><tr><td>';
			if (isSuggest) {
				html += '<a'
				html += ' href="#" onclick="evAtalPriceClick(\''
						+ flat + ', bud. ' + building + '\',\''+price+'\');return false"'
				html += '>'
				html += 'zaproponuj swoją cenę'
				html += '</a>'
			}
			html += '</td><td class="td2">';
			html += '<a'
				html += ' href="'
				html += isSuggest?'/cms_id/zaproponuj_cene"':'/cms_id/promocje#' + ar[i].data.field_values.id.field_value + '"'
				html += '>'
				html += 'zobacz szczegóły promocji'
				html += '</a>'
			html += '</td></tr></table>';
			html += '</div>'
		}
		html += '</div>'
		OverPageBrowser.instance.showHTML(html, [ 500, (i + 1) * 200 + 150 ],
				true)
		$('#outerOverDocument').append(
				$('<img src="/modules/layout/x.png"/>').css('position',
						'absolute').css('left', '515px').css('top', '0px').css(
						'cursor', 'pointer').click(function() {
					OverPageBrowser.instance.hide()
				}))
	}
	p.url = "/modules/amfphp2/json.php?service=cms2.SiteService.publicGetPage"
	p.type = 'POST'
	p.data = 'k0={"_explicitType":"cms2.site.vo.PageRequestVO","daoClassName":"DAO","daoMethodName":"getPromotionsByIds","ids":"' + promotions + '"}'
	p.dataType = 'json'
	$.ajax(p)
}
function evAtalPriceClick(selectedFlat,priceActual) {
	var params = {}
	params.selectedFlat = selectedFlat
	params.priceActual=priceActual
	OverPageBrowser.instance
			.createSwfPlayer(
					String(location).indexOf('debug') > -1 ? '/build/AtalSign/AtalPrice.swf'
							: '/modules/FlexForms/AtalPriceYellow.swf', [ 690,
							428 ], params, null, {
						wmode : 'window'
					})
	return false
}
// test
function evAtalPriceClickTest() {
	evAtalPriceClick('b2, mieszkanie B45')
}
// onLoadQueue.appendOnLoad(evAtalPriceClickTest)
function communicateSignForm(selectedNumbers,selectedStage){
	evAtalSignClick(selectedNumbers,selectedStage)
}
function evAtalSignClick(selectedNumbers,selectedStage){
	var params={types:'etap I:trzypokojowe jednopoziomowe 69-79 m2,trzypokojowe dwupoziomowe 81-99 m2,czteropokojowe 103 m2,mieszkania w promocji|etap II:trzypokojowe,dwupokojowe,jednopokojowe'}
		if(selectedNumbers){
			params.selectedNumbers=selectedNumbers
		}
	if(selectedStage){
		params.selectedStage=selectedStage
	}
	OverPageBrowser.instance.createSwfPlayer(String(location).indexOf('debug')>-1?'/build/AtalSign/AtalSign.swf':'/modules/FlexForms/AtalSignBrown.swf',[690,428],params,null,{wmode:'window'})
		return false
}
//test
//onLoadQueue.appendOnLoad(evAtalSignClick)
function startMenu(){
	var emb=new PluginEmbeder()
	emb.detectVersion=[9,0,0]
	emb.addAttribute("file",String(location).indexOf('debugNavi')>-1?"/build/test/BronowiceNavigation.swf":'/modules/layout/BronowiceNavigation.swf')
	emb.addAttribute("width",980)
	emb.addAttribute("id",'topMenuSwf')
	emb.addAttribute("height",300)
	emb.addAttribute("wmode","opaque")
	var cookiesLib=new jslt.CokiesLib()
	emb.addVariable("wasVisited",cookiesLib.readCookie("wasVisited")!=null?"true":"")
	cookiesLib.setCookie("wasVisited",true,3600)
	emb.addVariable("isHTML","true")
	emb.addVariable("l0Hrefs",l0Hrefs)
	emb.addVariable("activeItemIndex",activeIndexes[0])
	emb.addVariable("channel_link",channel_link)
	emb.addVariable("lang",lang)
	emb.addVariable("parallelHref", parallelHref)
	emb.addVariable("promotionsVisible",'true')//czy widoczny klawisz promocje
//emb.addVariable("mourningMode", true)
	emb.assignToElement("tdMenu")
tracker.instance.trackEvent('initialization','includeSwfCode')
}
onLoadQueue.appendOnLoad(startMenu)
setActiveItems=function(){
	for(var i=0;i<activeMenuIds.length;i++){
		switch(i){
			case 0:
			document.getElementById("divMenu2"+activeIndexes[i]).style.display="block"
			break;
			case 1:
			document.getElementById(activeMenuIds[i]).className="menu2current"
			var elDiv2=document.getElementById("divMenu2"+activeIndexes[0]+""+activeIndexes[1])
			if(elDiv2){
				elDiv2.style.display="block"
			}
			break;
			case 2:
			document.getElementById(activeMenuIds[i]).className="menu2subcurrent"
			break;
			}
		}
}
onLoadQueue.appendOnLoad(setActiveItems)
function socialBookmarksConfigure(){
    var links = []
    links.push(['facebook', 'http://www.facebook.com/pages/manage/#!/pages/Bronowice-Krakow-Apartamenty/108338012535113', "facebook_2.gif"]);
    for (var i = 0; i < links.length; i++) {
        var curId = 'soc-link-' + i
        document.getElementById("soc-links").innerHTML+='<a  id="' + curId + '" href="' + links[i][1] + '" target="_blank" onclick=\'tracker.instance.trackEvent("Społecznościowe","Klik","' + links[i][0] + '");\'><img src="/modules/content/' + links[i][2] + '"/></a>';
    }
}


onLoadQueue.appendOnLoad(socialBookmarksConfigure);
function getMicroblogEntries(){
	return cms2.microblogEntries
}
/**
 * 
 * @param {Array}
 *            ar
 */
function visualizationShow(building,flat) {
	OverPageBrowser.instance.createSwfPlayer('/modules/layout/VisualizationsGalery.swf',[884,460],{debug:'true',building:building,flat:flat},null,{id:'Wiz2Player',wmode:'transparent'})
}