var pMaxItem = 6;
var pItemPerRow = 3;

//--------------------------------------------//
//class faq
function FAQ(){
	this.xmlPath = gHost + "xml";
	
	this.createFaq = createFaq;
	this.importXML = importXML;
	
	function createFaq(cType,divObj,parentObj){
		if(cType.indexOf('http') < 0)	{	var fileName = this.xmlPath + "/" + cType.toLowerCase() + ".xml";	}
		else							{	var fileName = cType.toLowerCase() + ".xml";						}
		this.importXML(fileName,divObj,parentObj);
	}
							   
	function importXML(fileName,divObj,parentObj)
	{
		$("#" + divObj).text("Loading...");
		$.ajax({
                 type: "GET",
                 url: fileName,
                 dataType: "xml",
                 success: function(xmlDoc) {
					 //faq
					 if(divObj){
                     	createLink(xmlDoc,divObj,parentObj);
					 }
                 }
        }); //close $.ajax(

	}
	
	function createLink(xmlDoc,objName,parentName){
		$("#" + objName).empty();
						
		//Title
		$("#" + objName).append($('<h2></h2>').text('FAQ'));
		
		//UL
		var useClass = true;
		var newUl = $(document.createElement('UL'));
		$(xmlDoc).find('item').each(function(){
			if(useClass == true) {useClass = false;} else {useClass = true;}
			$(newUl).append(createNode(this,useClass));
		 });
		$("#" + objName).append(newUl);
		
		//Close button		
		$("#" + objName).append($('<a></a>').attr({href:'javascript:void(0)',id:'closeFaq'})
											.append($('<img></img>').attr('src','/img-tpl/dd-close.jpg'))
									    );
		$('#closeFaq').bind('click',function(){
			hideDiv(parentName);
		});
		
	}
	
	function createNode(itemNode,useClass){
		var theImg = "/img-tpl/dd_bullet.gif";
		var theName = $(itemNode).find('name').text();
		var theTitle = $(itemNode).find('title').text();
		var theUrl = $(itemNode).find('url').text();
		var theTarget = $(itemNode).find('target').text();
		
		if(useClass){
			var newLi = $(document.createElement('LI')).attr('className','dd_alt');
		}
		else{
			var newLi = $(document.createElement('LI'));
		}
		
		newLi.append($('<img></img>').attr({src:theImg, border:'0'}));
		
		var newH = $('<h3></h3>');
		var newLink = $('<a></a>').text(theName);
		if(isPopup(theTarget)){
			newLink.attr({href:'javascript:void(0)'});
			newLink.click(function(){
				popupWindow(theUrl,"node",theTarget);
			});
		}
		else{
			newLink.attr({href: theUrl, target: theTarget});
		}
		newLi.append(newH.append(newLink));
		newLi.append($('<p></p>').text(theTitle)
					 );
		
		return newLi;
	}
	
}//end faq
