function clean(a){var p=a.previousSibling;if(p){a.onblur=function(){if(!a.value){p.style.top=""}};p.style.top="-9999px";}}

function init(){
	var old_width = $(document).width();
onResize();
$(window).resize(function(){
	onResize();
	if (old_width>$(document).width()) {
		setNewHeight(window.frames[Planetoid.new_ifr].getIfrHeight());
	}
	old_width = $(document).width();
});
//$('input:checkbox.ts_chkbox').checkbox({cls:'checkbox'});
}

function onResize(){
	
	var ml = $('#menu_left').height();
	var mr = $('#menu_right').height();
	var cc = $('#content_center').height();
	var minHeight = (ml > mr) ? ml : mr;
	minHeight = (minHeight > cc) ? minHeight : cc;
	minHeight += 130;
	
	if($('body').height() <= minHeight){
		$('#page').height(minHeight);
	}
	else{
		$('#page').height('100%');
	}

	if(map) {
		map.checkResize();
		//var curZoom = map.getZoom();
		//genNewBounds(curZoom);
		checkBounds();
	}
	
/*	if($('body').width() < 1150){$('#content_center').css('margin-left','256px').css('margin-right','256px');}
	else{$('#content_center').css('margin-left','266px').css('margin-right','266px');}
*/	
}

function dynamicResize(){
	
	var ml = $('#menu_left').height();
	var mr = $('#menu_right').height();
	var cc = $('#content_center').height();
	var minHeight = (ml > mr) ? ml : mr;
	minHeight = (minHeight > cc) ? minHeight : cc;
	minHeight += 130;
	
	if($('body').height() <= minHeight){
		$('#page').height(minHeight+10);
		setTimeout(dynamicResize,300);
	}
	else{
		$('#page').height('100%');
	}

	if(map) {
		map.checkResize();
		//var curZoom = map.getZoom();
		//genNewBounds(curZoom);
		checkBounds();
	}
}

function closePopup(id){
	$('#lightbox_bg').hide();
	$('#lb_select_type_travel').hide();
}

function openPopup(id){
	allignPopup(id);
	$('#'+id).show();
	$('#lightbox_bg').show();
	$(window).resize(function(){allignPopup(id);});

}

function allignPopup(id){
	$('#'+id).css('left',parseInt(($('body').width() / 2) - ($('#'+id).width() / 2)) + 'px');
	var top1 = parseInt(($('body').height() / 2) - ($('#'+id).height() / 2));
	var top = (top1 >= 0) ? top1 : 10;
	$('#'+id).css('top', top + 'px');
}





function mnrSwitch(id1,id2){
	$('#mnr_it_1_, #mnr_it_2_, #mnr_it_3_, #mnr_it_4_, #mnr_it_5_').removeClass('show').addClass('hide');
	$('#mnr_it_1, #mnr_it_2, #mnr_it_3, #mnr_it_4, #mnr_it_5').removeClass('hide').addClass('show');
	$('#'+id1).removeClass('show').addClass('hide');
	$('#'+id2).removeClass('hide').addClass('show');
	onResize();
}

function mnlrToggle(lr,flag){
	if(lr=='left'){
			$('#menu_left_exp')[ (flag) ? 'show' : 'hide' ]();
			$('#menu_left_col')[ (flag) ? 'hide' : 'show' ]();
	}
	if(lr=='right'){
			$('#menu_right_exp')[ (flag) ? 'show' : 'hide' ]();
			$('#menu_right_col')[ (flag) ? 'hide' : 'show' ]();
	}
}

function console1(text){
	$('#console1').show();
	$('#console1').append(text+'<br/>');
}

function initRadiob(id){
	$('#' + id + ' > .item').click(function(){
		$('#' + id + ' > .item').removeClass('selected');
		$(this).removeClass('hover');
		$(this).addClass('selected');
	});	
	$('#' + id + ' > .item').hover(function(){if(!$(this).hasClass('selected')) $(this).addClass('hover');},function(){$(this).removeClass('hover');});
}

