var lang = new Array();
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

function $$(id) {
	return document.getElementById(id);
}
function doane(event) {
	e = event ? event : window.event;
	if(is_ie) {
		e.returnValue = false;
		e.cancelBubble = true;
	} else if(e) {
		e.stopPropagation();
		e.preventDefault();
	}
}
function loadregion(type,parent_id,val,callback) {
	if (parent_id==null) {
		parent_id = 0;
	}
	$.getJSON(URL_ROOT+'city.php?action=load&parent_id='+parent_id,null,function (json){
		var j=0;
		p = $('#'+type)[0];
		p.options.length=0;
		p.options.length++;
		p.options[j].text='请选择';
		p.options[j].value='';
		j++;
		for (i in json) {
			p.options.length++;
			p.options[j].text=json[i];
			p.options[j].value=i;
			if (val==i) {p.options[j].selected=true;}
			j++;
		}
		if (callback) {
			eval(callback);
		}
	});
}
function openWindow(dialogName, pageUrl, width, height,  resizable) {
	try	{
		screenWidth	= screen.width ;
		screenHeight = screen.height ;
	} catch (e) {
		screenWidth	= 1024 ;
		screenHeight = 768 ;
	}
	var iTop  = (screenHeight - height) / 2 ;
	var iLeft = (screenWidth  - width)  / 2 ;
	
	if (!width) {
		width = screenWidth;
	}
	if (!height) {
		height = screenHeight;
	}
	if (!resizable) {
		resizable = true;
	}


	var sOption  = "location=no,menubar=no,scrollbars=auto,toolbar=no,dependent=yes,'',minimizable=no,modal=yes,alwaysRaised=yes" +
		",resizable="  + ( resizable ? 'yes' : 'no' ) +
		",width="  + width +
		",height=" + height +
		",top="  + iTop +
		",left=" + iLeft ;

	var	parentWindow = window ;
	
	var oWindow = parentWindow.open( pageUrl, 'Dialog_' + dialogName, sOption, true );
	
	if ( !oWindow )
	{
		alert('ڱأرչعߣ');
		return ;
	}
		
	oWindow.moveTo( iLeft, iTop ) ;
	oWindow.resizeTo( width, height ) ;
	oWindow.focus();
}
