var ARVMESSAGE_FOLDERROOT = '';


/********************* BEGIN: MessageButtons  **************************/
var MessageButtons = function(){
	this._init();
	
	this.OK = document.createElement('button');
	this.CANCEL = document.createElement('button');
	
	this.OK.innerHTML = this.texts[this.defaultLang]['OK'];
	this.CANCEL.innerHTML = this.texts[this.defaultLang]['CANCEL'];

}//end class MessageBoxes()

MessageButtons.prototype = {
	
	_init:function(){
		this.defaultLang = 'tr';
		
		//button texts
		this.texts = new Array();
		this.texts['tr'] = new Array();
		this.texts['tr']['OK'] = 'Tamam';
		this.texts['tr']['CANCEL'] = 'İptal';
	}//end method _init()
		
}//prototype

/********************* END: MessageButtons  **************************/

//-------

/********************* BEGIN: AlertBox  **************************/

var AlertBox = function(Message, Title, Type, JScript){
	this._init();
	
	this.message = Message;
	
	
	if(Type == 'ERROR' || Type == 'WARNING' || Type == 'INFO' || Type=='CONFIRM'){
		this.type = Type;
	}
	else{
		this.type = 'DEFAULT';
	}
	
	//başlık yazısı
	if(Title) this.title = Title;
	else this.title = this.texts[this.defaultLang][this.type];
	
	this.parentDiv = document.createElement("div");
	this.parentDiv.className = 'alertBox_parentDiv';
	
	//ana tabloyu yerleştir
	this.tableObj = document.createElement("table");
	this.tableObj.border = 0;
	this.parentDiv.appendChild(this.tableObj);
	
	this.tbodyObj = document.createElement("tbody");
	this.tableObj.className = "alertBox_table";
	
	this.tableObj.appendChild(this.tbodyObj);
	
	this.headerTR = document.createElement("tr");
	this.messageTR = document.createElement("tr");
	this.buttonTR = document.createElement("tr");
	
	//this.headerTR.className = "alertBox_header";
	this.messageTR.className = "alertBox_messagePart";
	this.buttonTR.className = "alertBox_buttonPart";
	
	this.tbodyObj.appendChild(this.headerTR);
	this.tbodyObj.appendChild(this.messageTR);
	this.tbodyObj.appendChild(this.buttonTR);
	
	//başlığı yaz
	this.titleTD = document.createElement('td');
	this.titleTD.className = 'alertBox_header';///////////////header td
	this.titleTD.colSpan = 2;
	this.titleTD.appendChild(document.createTextNode(this.title));
	this.headerTR.appendChild(this.titleTD);
	
	//MESAJ KISMI
	
	if(this.type != 'DEFAULT'){
		//mesaj ikonu
		this.iconTD = document.createElement('td');
		this.iconTD.style.width = '42px';
		
		this.icon = document.createElement('img');
		this.icon.src = this.imagePath + this.typeIcons[this.type];
		this.iconTD.appendChild(this.icon);
		this.messageTR.appendChild(this.iconTD);
	}
	
	
	//mesaj
	this.messageTD = document.createElement('td');
	//this.messageTD.appendChild(document.createTextNode(this.message));
	this.messageTD.innerHTML = this.message;
	
	this.messageTR.appendChild(this.messageTD);
	
	this.buttonTD = document.createElement('td');
	this.buttonTD.colSpan = 2;
	this.buttonTR.appendChild(this.buttonTD);
	
	this.buttonTD.appendChild(this.buttons.OK);//buton ekle
	
	this.buttons.OK.onclick = function(){
		var messageBox = this.parentNode.parentNode.parentNode.parentNode.parentNode; //td, tr, tbody, table, div
		//messageBox.parentNode.removeChild(messageBox);
		
		$(messageBox).hide("slow");
		
		if(JScript){eval(JScript);}
	}
	
	this.parentDiv.OK_button = this.buttons.OK;
	/*this.parentDiv.onclick = function(){
		this.OK_button.focus();
	}*/
}//

AlertBox.prototype = {
	
	_init:function(){
		this.defaultLang = 'tr';
		
		this.buttons = new MessageButtons();
		
		//images
		this.imagePath = ARVMESSAGE_FOLDERROOT + 'images/';
		this.typeIcons = new Array();
		this.typeIcons['ERROR'] = 'error_icon.gif';
		this.typeIcons['WARNING'] = 'warning_icon.gif';
		this.typeIcons['INFO'] = 'info_icon.gif';
		this.typeIcons['CONFIRM'] = 'confirm_icon.gif';
		
		this.texts = new Array();
		this.texts['tr'] = new Array();
		this.texts['tr']['ERROR'] = 'Hata Mesajı';
		this.texts['tr']['WARNING'] = 'Uyarı Mesajı';
		this.texts['tr']['INFO'] = 'Bilgilendirme Mesajı';
		this.texts['tr']['CONFIRM'] = 'Onay Mesajı';
		this.texts['tr']['DEFAULT'] = 'Mesaj Kutusu';
	}//_init
	
	,
	
	show:function(left_diff, top_diff){
		if (self.innerWidth)//netscape
		{
			this.frameWidth = self.innerWidth;
			this.frameHeight = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientWidth)//explorer 6
		{
			this.frameWidth = document.documentElement.clientWidth;
			this.frameHeight = document.documentElement.clientHeight;
		}
		else if (document.body)//other explorers
		{
			this.frameWidth = document.body.clientWidth;
			this.frameHeight = document.body.clientHeight;
		}
		
		
		if(!left_diff) left_diff = 0;
		if(!top_diff) top_diff = 0;
		$(this.parentDiv).hide();
		document.body.appendChild(this.parentDiv);
		
		
		this.parentDiv.style.left = document.body.scrollLeft + document.documentElement.scrollLeft + (this.frameWidth - parseInt(this.parentDiv.offsetWidth))/2 + left_diff + 'px';
		
		this.parentDiv.style.top = document.body.scrollTop + document.documentElement.scrollTop + (this.frameHeight - parseInt(this.parentDiv.offsetHeight))/2 + top_diff + 'px';
		
		$(this.parentDiv).show("slow");
		
		this.buttons.OK.focus();/////////////////////
		
		//document.write((this.frameWidth - parseInt(this.parentDiv.offsetWidth))/2);
	}//end method show();
}//prototype


function alertBox(Message, Type, Title, JScript, left_diff, top_diff){
	var alertBox = new AlertBox(Message, Type, Title, JScript);
	alertBox.show(left_diff, top_diff);
}

/********************* END: AlertBox  **************************/
