// publickus oldal közös JS

/**
 * flash tlepítettségi ellenőrzés
 */

// IE specifikus HTML[lang=xy] helyett
if ( is.ie ) document.documentElement.className = document.documentElement.getAttribute('lang');

var flashError = false;

var actNum;
function show( num ) {
	document.getElementById("allista_"+actNum).className = "";
	document.getElementById("folista_"+actNum).className = "";
	document.getElementById("allista_"+num).className = "actual";
	document.getElementById("folista_"+num).className = "actual";

	oUL = document.getElementById("allista_"+num);
	oLI = oUL.getElementsByTagName('LI');
	oLI[0].firstChild.className = "actual";
	document.getElementById("termekIFrame").src = oLI[0].firstChild.href;
	for(i=1;i<oLI.length;i++) {
		oLI[i].firstChild.className = "";
	}
	actNum = num;
}

function changeItem( obj ) {
	oUL = obj.parentNode.parentNode;
	oLI = oUL.getElementsByTagName('LI');
	for(i=0;i<oLI.length;i++) {
		if ( oLI[i].firstChild != obj ) {
			oLI[i].firstChild.className = "";
		}
		else {
			oLI[i].firstChild.className = "actual";
		}
	}
}

loadEventBinding( window, function() {
	var aPictureViewerText = [];
	aPictureViewerText['hu'] = 'töltés...';
	aPictureViewerText['en'] = 'loading...';
	aPictureViewerText['de'] = 'loading...';
	var sLang = document.documentElement.getAttribute('lang');
	if (typeof pictureViewer != 'undefined') {
		pictureViewer.init();
		pictureViewer.setConfig( 'window', {
			title : '',
			CSSfileURL : '../ui/skin_2004/_pictureviewer.css',
			showH1 : false,
			resize: false
		} );
		pictureViewer.setConfig( 'pending', {
				className : 'pictureviewer-pending',
				text : aPictureViewerText[sLang],
				show : false
		} )
	};
	
	/*if ( window.location.href.indexOf('browser_error_flash.html') == -1 || window.location.href.indexOf('browser_error_flash.html') === false ) {
		flash.getFlashCheck( 6.49, function() {
			window.location = 'browser_error_flash.html';
		}, function() {} );
	}*/
} );

// termektar osszeallitasa kulso parameter eseten
function createIframe() {
	//var loc = window.location.href;
	//param = loc.substring( ( loc.lastIndexOf( "=", loc ) +1), loc.length );
	sLoc = window.location.href.split("?");
	param = sLoc[1];

	if ( sLoc[1] == null ) {
		//ezzel lehet beállítani hogy a kezdésnél melyik termék jelenjen meg
		if ( 'hu' == document.getElementsByTagName('html')[0].getAttribute( 'lang' ) ) {
			param = "16,0";
		}
		else {
			param = "1,0";
		}
	}
	//alert(param);
	nums = param.split(",");
	
	if ( nums[0] < 1 || nums[0] > 20 || isNaN(nums[0]) ) {
		nums[0] = 1;
	}
	if ( nums[1] == null || nums[1] == "" || isNaN(nums[1]) ) {
		nums[1] = 0;
	}

	//alert(nums[0]+" .... "+nums[1]);

	document.getElementById("allista_"+nums[0]).className = "actual";
	document.getElementById("folista_"+nums[0]).className = "actual";
	actNum = nums[0];

	oUL = document.getElementById("allista_"+nums[0]);
	oLI = oUL.getElementsByTagName('LI');
	
	//alert(oLI.length);
	if ( oLI.length <= nums[1] ) {
		nums[1] = 0;
	}
	
	oLI[nums[1]].firstChild.className = "actual";

	document.write( '<iframe id="termekIFrame" name="termekIFrame" frameborder="0" src="'+oLI[nums[1]].firstChild.href+'"></iframe>' );
}

// taplalekallergia popUp
function popUp(sURL) {
	windowheight = 622;
	windowwidth = 680;
	LeftPosition = (screen.width) ? ( screen.width - windowwidth )/2 : 0;
	TopPosition = (screen.height) ? ( screen.height - windowheight )/2 : 0;
	window.open(sURL,'printWindow','left='+LeftPosition+',top='+TopPosition+',scrollbars=yes,width=670,height=500,menubar=yes,toolbar=no');
}

// pille pulyka popUp
function popUpGeneral(sURL, width, height) {
	windowheight = height;
	windowwidth = width;
	LeftPosition = (screen.width) ? ( screen.width - windowwidth )/2 : 0;
	TopPosition = (screen.height) ? ( screen.height - windowheight )/2 : 0;
	window.open(sURL,'printWindow','left='+LeftPosition+',top='+TopPosition+',scrollbars=no,width='+width+',height='+height+',menubar=no,toolbar=no');
}

// Mives popUp
function popUpGeneral_mives(sURL, width, height) {
	windowheight = height;
	windowwidth = width;
	LeftPosition = (screen.width) ? ( screen.width - windowwidth )/2 : 0;
	TopPosition = (screen.height) ? ( screen.height - windowheight )/2 : 0;
	window.open(sURL,'printWindow','left='+LeftPosition+',top='+TopPosition+',scrollbars=no,width='+width+',height='+height+',menubar=no,toolbar=no,resizeable=0');
}

//mibol mit
var mibolActive = null;
function mibolShow( sName ) {
	//alert(sName);
	if ( mibolActive != null && mibolActive != sName ) {
		document.getElementById(mibolActive).className = "mibolItem";
	}
	if ( sName != "" ) {
		mibolActive = sName;
		document.getElementById(sName).className = "mibolItem-active";
	}
	else {
		mibolActive = null;
	}
}
function popup_scooby(sURL) {
	windowheight = 507;
	windowwidth = 666;
	LeftPosition = (screen.width) ? ( screen.width - windowwidth )/2 : 0;
	TopPosition = (screen.height) ? ( screen.height - windowheight )/2 : 0;
	window.open(sURL,'PICK','left='+LeftPosition+',top='+TopPosition+',scrollbars=no,width=666,height=507,menubar=no,toolbar=no');
}

/*function popup_scooby(mypage){
	 width = 666;
	 height = 507;
	 

	LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-heigth)/2 : 0;
	settings = 'height='+heigth+',width='+width+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	window.open(mypage,'PICK',settings)
}*/
