
haloComments = {

	loadedobjects     : "",
	username          : "oguzkaradeniz",
	loadpath          : "http://www.haloscan.com/load/",
	viewpath          : "http://www.haloscan.com/comments/",
	id                : "",
	initdone          : 0,
	
	loadObjects : function( file) {
		if (!document.getElementById)
		return
		if (haloComments.loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding

			if (file.indexOf(".css")!=-1){ //If object is a css file
				fileref=document.createElement("link")
				fileref.setAttribute("rel", "stylesheet");
				fileref.setAttribute("type", "text/css");
				fileref.setAttribute("href", file);
				if( file.indexOf("print")!=-1) {
					fileref.setAttribute("media", "print");
				}
			}
			else { //otherwise assume js always
				fileref=document.createElement('script')
				fileref.setAttribute("type","text/javascript");
				fileref.setAttribute("src", file);
			}			
		}
		if (fileref!=""){
			document.getElementsByTagName("head").item(0).appendChild(fileref)
			haloComments.loadedobjects+=file+" " //Remember this object as being already added to page
		}
	},
	
	total : function (id){
		if ( haloComments.initdone == 1 ) {
			var hs_search = new RegExp('\\W','gi');
			var hs_id = id.replace(hs_search,"_");
			id = hs_id;
			var rtrnVal=0;
			if (hs[id]) {
				var rtrnVal=hs[id];
			}
			return rtrnVal;
		}
		else {
			return 0;
		}
	},
	
	show: function() {
		alert('xx');	
		if ((haloComments.id=="") || (haloComments.initdone == 0)) {
			return 0;
		}
		alert('xx');
		var CommentNum=haloComments.total(haloComments.id);
		var outp="";
		
		if (CommentNum) {
			var frameH=550+(60*CommentNum);
			var maxH=1200;
			if (frameH > maxH) frameH=maxH;
			outp += "<iframe id='comments' style='border:none; overflow: hidden;' frameBorder=0 scrolling='no'";
			outp += "src='"+haloComments.viewpath;
			outp += haloComments.username+"/"+haloComments.id+"/' width='100%' ";
			outp += "onload='haloComments.loadReady()' ";
			outp += "height='"+frameH+"'></";
			outp += "iframe>";
			alert(outp);
			$("div#comments-wrap-"+haloComments.id).html( outp);
		}		
	},

	loadReady: function () {
	},
	
	links: function(id) {
		if ((id=="") || (haloComments.initdone == 0)) {
			return 0;
		}
		document.write ( "<a href=\"javascript:HaloScan('"+id+"');\" ");
		document.write ( "target=\"_self\"><script type=\"text/javascript\">postCount('"+id+"');</script></a>");
		document.write ( " | ");
		document.write ( "<a href=\"javascript:HaloScanTB('start');\" ");
		document.write ( "target=\"_self\"><script type=\"text/javascript\">postCountTB('"+id+"'); </script></a>");
		
	},
	
	init: function() {
		// first check for DOM compatibility
		if(!document.getElementById || !document.createTextNode){return;}
		
		//haloComments.loadObjects( haloComments.loadpath + haloComments.username);
		haloComments.initdone = 1;
	}
};	

