
// JavaScript Document
$(function(){
	if ($("#sys-dialog").length == 0 ) $("<div></div>").attr("id","sys-dialog").css("display","none").appendTo($("body"));
	//全局ajax
	$(document).ajaxStart(function(){
		$.loading({align:"top-center",text: $SystemLanguage.tip_sending_data ,mask:true,delay:50,max:100000});
	}).ajaxComplete(function(){
		$.loading(false);
	}); 	
});

$.fn.alert = function(msg ,fun){
	if (!fun) fun = function(){ $(this).dialog("close"); }
	$(this).attr("title", $SystemLanguage.tit_message).html(msg);
	var customButton = {};	
	customButton[$SystemLanguage.btn_close] = fun;
	
	
	$("#sys-dialog").dialog("destroy").dialog({
		background: "black",
		resizable: false,
		width :360,
		height:150,
		modal: true,
		buttons: customButton
	});	
}

$.fn.prox = function(msg ,fun){
		
		if (!fun) fun = function(){ $(this).dialog("close"); }
		$(this).attr("title", $SystemLanguage.tit_message).html(msg);
		var customButton = {};	
		customButton[$SystemLanguage.btn_close] = fun;
		$("#sys-dialog").dialog("destroy").dialog({
			background: "black",
			resizable: false,
			width :600,
			height:400,
			modal: true,
			buttons: customButton
		});	
}



$.fn.confirm = function(msg, fun){
	if (!fun) fun = function(){ $(this).dialog("close"); }
	$(this).attr("title",$SystemLanguage.tit_confirm).html(msg);
		var customButton = {};
		customButton[$SystemLanguage.btn_close] = function() {
			$(this).dialog("close");
		};
		customButton[$SystemLanguage.btn_ok] = fun;
		$("#sys-dialog").dialog("destroy").dialog({
			resizable: false,
			width :360,
			height:150,
			modal: true,
			buttons: customButton
		});	
}
	



Array.prototype.in_array = function(e) 
{ 
	for(i=0;i<this.length && this[i]!=e;i++); 
	return !(i==this.length); 
}

var local_domains = new Array('com.cn','co.kr','com.au');
var hosts = window.location.host.split('.');
window.DOMAIN = hosts[(hosts.length-2)]+'.'+hosts[(hosts.length-1)];
if (local_domains.in_array(window.DOMAIN)) window.DOMAIN = hosts[(hosts.length-3)]+'.'+hosts[(hosts.length-2)]+'.'+hosts[(hosts.length-1)];
window.COOKIE_DOMAIN  = '.' + window.DOMAIN;

Array.prototype.unique = array_unique;
function array_unique()
{
 var o = new Object();
 for (var i=0,j=0; i<this.length; i++)
 {
  if (typeof o[this[i]] == 'undefined')
  {
   o[this[i]] = j++;
  }
 }
 this.length = 0;
 for (var key in o)
 {
  this[o[key]] = key;
 }
 return this;
}

