// JavaScript Document

function iconNotes(){
	this.childMenus=null;
	this.depth=0
}
iconNotes.prototype={
	getDefaultValues : function(containerId,xmlPath){
		this.xmlUrl=xmlPath;
		this.container=DOS.$(containerId)
		this.iconArray=this.container.getElementsByTagName('li')
		this.request=null;
	},
	createTextNode : function(){
		this.txtTitle=document.createTextNode('')
		this.txtContent=document.createTextNode('')
	},
	getSelfObject : function(){
		var selfObject=this;
		return selfObject
	},
	getCode : function(){
		var selfObject=this.getSelfObject();
		this.request=DOS.creatAjaxRequest();
		this.request.open('GET',this.xmlUrl,true)
		this.request.onreadystatechange =function(){selfObject.updatePage(selfObject.request,selfObject)}
		this.request.send(null);
	},
	
	createNoteContainer : function(){
		var noteContianer=document.createElement('div');
		noteContianer.className='noteContianerBottom';
		noteContianer.style.display='none'
		var noteContianerTopInner=document.createElement('div');
		noteContianerTopInner.className='noteContianer';
		var noteContianerBottomInner=document.createElement('div');
		noteContianerBottomInner.className='noteContianerTop';
		var noteContianerTitle=document.createElement('h6');
		var noteContianerContent=document.createElement('p');
		noteContianer.appendChild(noteContianerTopInner);
		noteContianerTopInner.appendChild(noteContianerBottomInner);
		noteContianerBottomInner.appendChild(noteContianerTitle)
		noteContianerTitle.appendChild(this.txtTitle)
		noteContianerBottomInner.appendChild(noteContianerContent)
		noteContianerContent.appendChild(this.txtContent)
		document.getElementById('iconLists').appendChild(noteContianer)
		return noteContianer;
		},
		
	updatePage : function(request,selfObject){
		if (request.readyState == 4){
		   if (request.status == 200){
					selfObject.xmlObj=request.responseXML;
					selfObject.xmlTitleArray=selfObject.xmlObj.getElementsByTagName('title');
					for(var i=0;i<selfObject.iconArray.length;i++){
						selfObject.addMouseEvent(selfObject.iconArray[i],selfObject)
						}
		   	}
		}
	},
	addMouseEvent : function(element,selfObject){
		var elementImg=element.getElementsByTagName('img')[0]
		var imgAlt=elementImg.getAttribute('alt')
		var contentTxt=selfObject.getContent(imgAlt)
		DOS.addEvent(element,'mouseover',function(){
			selfObject.txtTitle.nodeValue=imgAlt
			selfObject.txtContent.nodeValue=contentTxt;
			element.appendChild(selfObject.noteContainer)
			selfObject.noteContainer.style.display='block'
			selfObject.noteContainer.style.top=-(selfObject.noteContainer.offsetHeight+2)+'px'
			})
		DOS.addEvent(element,'mouseout',function(){
			selfObject.noteContainer.style.display='none'
			})
		},
	getContent : function(title){
		for(var i=0;i<this.xmlTitleArray.length;i++){
			if(this.xmlTitleArray[i].firstChild.data===title){
				var content=this.xmlTitleArray[i].parentNode.getElementsByTagName('description')[0].firstChild.data
				break;
				}
			}
		return content
		},	
	doOrder : function(containerId,xmlPath){
		if(!document.getElementById(containerId)){return false}
		this.createTextNode()
		this.getDefaultValues(containerId,xmlPath);
		this.noteContainer=this.createNoteContainer()
		this.getCode()
	}
}

var iconNote=new iconNotes;
DOS.addOnload(function(){
	iconNote.doOrder('iconLists','/products/house-split/iconNote.xml')
	})
