/*

	Banco ABN AMRO Real - Arquivo Genérico de Criação do Menu

*/

function class__Menu(){
	var str_tmp_page_id 			= self.location.href.replace(/(http:\/\/)/gi, '');
	this.AddItem					= [];
	this.Data						= [];
	this.Self						= {UID: '', Label: {MenuItem: '', BreadCrumb: '', SiteMap: '', ImageALT: '', ActionButton: ''}, Image: {MenuItem: '', ActionButton: ''}, Link: {MenuItem: {URL: '', Target: ''}, ActionButton: {URL: '', Target: ''}}, Display: {MenuItem: '', SiteMap: '', ActionButton: ''}};
	this.pageID						= str_tmp_page_id.substring(str_tmp_page_id.indexOf('/'), ((str_tmp_page_id.indexOf('?') !== -1 || str_tmp_page_id.indexOf('#') !== -1) ? ((str_tmp_page_id.indexOf('#') !== -1) ? str_tmp_page_id.indexOf('#') : str_tmp_page_id.indexOf('?')) : str_tmp_page_id.length)).replace(/\/iw-mount\/.*.\/Editoria/gi, '');
	this.Get							= {BreadCrumb: null, MenuItens: null, SiteMap: null, ActionButton: null};
	this.defaultActionButton 	= null;
	this.isHP						= false;
	this.Title						= null;

	this.Add = function(str_uid, arr_label, arr_image, arr_link, arr_link_ac, arr_display, int_type){
		int_type = int_type || 1;
		this.Data[str_uid] = {UID: str_uid, Lines: int_type, Type: 'B', Label: {MenuItem: arr_label[0], BreadCrumb: ((arr_label[1] != '') ? arr_label[1] : arr_label[0]), SiteMap: ((arr_label[2] != '') ? arr_label[2] : arr_label[0]), ImageALT: ((arr_label[3] != '') ? arr_label[3] : arr_label[0]), ActionButton: ((arr_label[4] != '') ? arr_label[4] : arr_label[0])}, Image: {MenuItem: arr_image[0], ActionButton: arr_image[1]}, Link: {MenuItem: {URL: arr_link[0], Target: arr_link[1]}, ActionButton: {URL: arr_link_ac[0], Target: arr_link_ac[1]}}, Display: {MenuItem: arr_display[0], SiteMap: arr_display[1], ActionButton: arr_display[2]}};
		return str_uid;
	}

	this.AddMasterItem = function(str_uid, arr_label, str_image, arr_link, arr_icon, bln_section_father){
		this.Data[str_uid] = {UID: str_uid, Type: 'A', Label: {BreadCrumb: arr_label[0], SiteMap: ((arr_label[2] != '') ? arr_label[2] : arr_label[0])}, Image: {SRC: str_image}, Link: {BreadCrumb: {URL: arr_link[0], Target: arr_link[1]}}, Icon: {SRC: arr_icon[0], OnlyIcon: arr_icon[1]}, SectionFather: bln_section_father};
		return str_uid;
	}

	this.AddDefaultActionButton = function(arr_inf){
		this.defaultActionButton = {Label: arr_inf[0], Image: arr_inf[1], Link: {URL: arr_inf[2], Target: ((arr_inf[3] != '') ? arr_inf[3] : '_self')}, Display: arr_inf[4]};
	}

	this.Clone = function(arr_uid, arr_link, arr_action_button){
		if(this.Data[arr_uid[1]].Type != 'A'){
			this.Data[arr_uid[0]] = {UID: arr_uid[0], Type: 'B', Label: {MenuItem: this.Data[arr_uid[1]].Label.MenuItem, BreadCrumb: this.Data[arr_uid[1]].Label.BreadCrumb, SiteMap: this.Data[arr_uid[1]].Label.SiteMap, ImageALT: this.Data[arr_uid[1]].Label.ImageALT, ActionButton: this.Data[arr_uid[1]].Label.ActionButton}, Image: {MenuItem: this.Data[arr_uid[1]].Image.MenuItem, ActionButton: this.Data[arr_uid[1]].Image.ActionButton}, Link: {MenuItem: {URL: this.Data[arr_uid[1]].Link.MenuItem.URL, Target: this.Data[arr_uid[1]].Link.MenuItem.Target}, ActionButton: {URL: this.Data[arr_uid[1]].Link.ActionButton.URL, Target: this.Data[arr_uid[1]].Link.ActionButton.Target}}, Display: {MenuItem: this.Data[arr_uid[1]].Display.MenuItem, SiteMap: this.Data[arr_uid[1]].Display.SiteMap, ActionButton: this.Data[arr_uid[1]].Display.ActionButton}};
			return arr_uid[0];
		}else{
			return false;
		}
	}

	this.getSelf = function(str_uid){
		this.pageID = ((str_uid != '' && typeof(str_uid) != 'undefined') ? str_uid : this.pageID)

		for(Looper in this.Data){
			if(this.Data[Looper].Type != 'A'){
				var str_tmp_lid = this.Data[Looper].Link.MenuItem.URL.replace(/(http:\/\/)/gi, '');
				var str_id = str_tmp_lid.substring(str_tmp_lid.indexOf('/'), ((str_tmp_lid.indexOf('?') !== -1 || str_tmp_lid.indexOf('#') !== -1) ? ((str_tmp_lid.indexOf('?') !== -1) ? str_tmp_lid.indexOf('?') : str_tmp_lid.indexOf('#')) : str_tmp_lid.length)).replace(/\/iw-mount\/.*.\/Editoria/gi, '');
				if(typeof(str_uid) != 'undefined'){
					if(str_tmp_lid == this.pageID){
						this.Self = {UID: this.Data[Looper].UID, Type: this.Data[Looper].Type, Label: {MenuItem: this.Data[Looper].Label.MenuItem, BreadCrumb: this.Data[Looper].Label.BreadCrumb, SiteMap: this.Data[Looper].Label.SiteMap, ImageALT: this.Data[Looper].Label.ImageALT, ActionButton: this.Data[Looper].Label.ActionButton}, Image: {MenuItem: this.Data[Looper].Image.MenuItem, ActionButton: this.Data[Looper].Image.ActionButton}, Link: {MenuItem: {URL: this.Data[Looper].Link.MenuItem.URL, Target: this.Data[Looper].Link.MenuItem.Target}, ActionButton: {URL: this.Data[Looper].Link.ActionButton.URL, Target: this.Data[Looper].Link.ActionButton.Target}}, Display: {MenuItem: this.Data[Looper].Display.MenuItem, SiteMap: this.Data[Looper].Display.SiteMap, ActionButton: this.Data[Looper].Display.ActionButton}};
					}
				}else{
					if(str_id == this.pageID){
						this.Self = {UID: this.Data[Looper].UID, Type: this.Data[Looper].Type, Label: {MenuItem: this.Data[Looper].Label.MenuItem, BreadCrumb: this.Data[Looper].Label.BreadCrumb, SiteMap: this.Data[Looper].Label.SiteMap, ImageALT: this.Data[Looper].Label.ImageALT, ActionButton: this.Data[Looper].Label.ActionButton}, Image: {MenuItem: this.Data[Looper].Image.MenuItem, ActionButton: this.Data[Looper].Image.ActionButton}, Link: {MenuItem: {URL: this.Data[Looper].Link.MenuItem.URL, Target: this.Data[Looper].Link.MenuItem.Target}, ActionButton: {URL: this.Data[Looper].Link.ActionButton.URL, Target: this.Data[Looper].Link.ActionButton.Target}}, Display: {MenuItem: this.Data[Looper].Display.MenuItem, SiteMap: this.Data[Looper].Display.SiteMap, ActionButton: this.Data[Looper].Display.ActionButton}};
					}
				}

				delete str_tmp_lid, str_id;
			}
		}
	}

	this.Init = function(){
		this.getSelf();
	}

	delete str_tmp_page_id;
}

var Menu = new class__Menu;