$(function() {
	var img_cnt_pg = 1;
	var img_cnt_es = 1;
	
	while( $('a[rel*="lightbox-pg-' + img_cnt_pg + '"]').size() != 0 ){
		$('a[rel*="lightbox-pg-' + img_cnt_pg + '"]').lightBox(); // photo gallery
		img_cnt_pg++;
	}

	while( $('a[rel*="lightbox-es-' + img_cnt_es + '"]').size() != 0 ){
		$('a[rel*="lightbox-es-' + img_cnt_es + '"]').lightBox(); // e-store
		img_cnt_es++;
	}

	try {
		// Safari allows interdomain access, so we need to catch it
		if(top.window.usersite) return false;
	} catch (err) {
		return false;
	}
	
	if(player_active != true) return false;

	try {
		if(top.window.mainFrame != null){
			top.document.title = top.window.frames['mainFrame'].document.title; // update frame title
			return false;
		}
	} catch (err) {
		return false;
	}

	if(!$.browser.opera){
		$('body').remove();

	    $(window).resize(function(){
	        $("#mainFrame").css('height', $(window).height() - 31);
	    });
	
		$('html').append( 
			$('<frameset>').attr({
				'frameborder': '0',
				'framespacing': '0',
				'id': 'fset',
				'rows': '*,31',
				'cols': '*'
		}) );
	
		$('#fset').append($('<frame />').attr({	'src': mainframe_url, 'scrolling': (($.browser.msie) ? 'yes' : 'auto'), 'name': 'mainFrame', 'id': 'mainFrame' }).css('height', $(window).height() - 31));
		$('#fset').append($('<frame />').attr({	'src': player_url, 'scrolling': 'no', 'name': 'playerFrame', 'id': 'playerFrame' }));
		
		top.window.frames['mainFrame'].document.location = mainframe_url;
	}else{
		var data = 	'<frameset frameborder="0" framespacing="0" id="fset" rows="*,31" cols="*">'
				+ 	'<frame src="' + mainframe_url + '" name="mainFrame" id="mainFrame" />'
				+	'<frame src="' + player_url + '" name="playerFrame" id="playerFrame" />'
				+	'</frameset>';
		
		document.write(data);
	}
});
