function getNews( num ) {
	var moduleObj = new module();
	moduleObj.setServer("eu");
	moduleObj.bDebug = true;

	moduleObj.newsList(0, 10, num, 30);
}

function news( data ){
	var x = $('#notice_entry_box');
	var y = $('#event_entry_box');
	var updates = $('#update_entry_box');
	x.html('');
	y.html('');
	updates.html('');
	
	var j=0;
	var k=0;
	var h=0;
	
	$.each(data.List, function(i,item){
		var idx = item.Idx;
		var boardType = item.BoardID;
		var subject = item.Subject;
		var content = item.Content;
		var smallContent = item.SmallContent; //Event Only (Notice needs to cut first 200)
		var re = /<\/?.*?>/gi;
		
		var month = new String(item.PostedDate);
		var date = month.slice(8, 10);
		month = month.slice(5, 7);
		if( month == "01")month = "JAN";
		else if(month == "02")month = "FEB";
		else if(month == "03")month = "MAR";
		else if(month == "04")month = "APR";
		else if(month == "05")month = "MAY";
		else if(month == "06")month = "JUN";
		else if(month == "07")month = "JUL";
		else if(month == "08")month = "AUG";
		else if(month == "09")month = "SEP";
		else if(month == "10")month = "OCT";
		else if(month == "11")month = "NOV";
		else if(month == "12")month = "DEC";
		
		if (boardType == 1 && j <  6){
			if(smallContent.length == 0 || smallContent == '1') {
				smallContent = content;
			}
			
			var NoticeSmallContent = smallContent.replace(re, '' );
			if(NoticeSmallContent.length > 300) NoticeSmallContent = NoticeSmallContent.substring(0, 300) + "...";
			
			if (j == 0){
			x.append('<div class="notice_entry">'
					+'<div class="calendar first">'
					+'<span class="month">'+month+'</span><br/>'
					+'<span class="date">'+date+'</span>'
					+'</div>'
					+'<div class="contents">'
					+'<p class="title"><a href="./NEWS/NOTICES_VIEW.html?'+idx+'">'+subject+'</a></p>'
					+'<p class="inside">'+NoticeSmallContent+'</p></div></div>');
			}else{
			x.append('<div class="notice_entry">'
					+'<div class="calendar">'
					+'<span class="month">'+month+'</span><br/>'
					+'<span class="date">'+date+'</span>'
					+'</div>'
					+'<div class="contents">'
					+'<p class="title"><a href="./NEWS/NOTICES_VIEW.html?'+idx+'">'+subject+'</a></p>'
					+'<p class="inside">'+NoticeSmallContent+'</p></div></div>');
			}

			j=j+1;

		}else if(boardType ==2 && k < 6){
			smallContent = smallContent.replace(re, '' );
			if(smallContent.length > 200) smallContent = smallContent.substring(0, 200) + "...";
			
			if (k ==0){
			y.append('<div class="events_entry"><div class="calendar first">'
						+'<span class="month">'+month+'</span><br/>'
						+'<span class="date">'+date+'</span>'
						+'</div><div class="contents">'
						+'<p class="title"><a href="./NEWS/EVENTS_VIEW.html?'+idx+'">'+subject+'</a></p>'
						+'<p class="inside">'+smallContent+'</p></div></div>');
			}else{
			y.append('<div class="events_entry"><div class="calendar">'
						+'<span class="month">'+month+'</span><br/>'
						+'<span class="date">'+date+'</span>'
						+'</div><div class="contents">'
						+'<p class="title"><a href="./NEWS/EVENTS_VIEW.html?'+idx+'">'+subject+'</a></p>'
						+'<p class="inside">'+smallContent+'</p></div></div>');
			}
			
			k=k+1;
		} else if(boardType ==3 && h < 6){
			if(smallContent.length == 0){
				
				smallContent = content.replace(re, '' );
				if(smallContent.length > 200) smallContent = smallContent.substring(0, 200) + "...";
			}
			
			if (h ==0){ 
			updates.append('<div class="updates_entry"><div class="calendar first">'
						+'<span class="month">'+month+'</span><br/>'
						+'<span class="date">'+date+'</span>'
						+'</div><div class="contents">'
						+'<p class="title"><a href="./NEWS/UPDATES_VIEW.html?'+idx+'">'+subject+'</a></p>'
						+'<p class="inside">'+smallContent+'</p></div></div>');
			}else{
			updates.append('<div class="updates_entry"><div class="calendar">'
						+'<span class="month">'+month+'</span><br/>'
						+'<span class="date">'+date+'</span>'
						+'</div><div class="contents">'
						+'<p class="title"><a href="./NEWS/UPDATES_VIEW.html?'+idx+'">'+subject+'</a></p>'
						+'<p class="inside">'+smallContent+'</p></div></div>');
			}
			
			h=h+1;
		} // if we add Update use following :: else if(boardType ==3) and so on...
		

	});
}


function getMPoll() {
	var moduleObj2 = new module();
	moduleObj2.setServer("eu");
	moduleObj2.bDebug = true;
	moduleObj2.mainpollList("lunia");
}

function MPoll( data ){	
	$('#poll_question').html(data.View.Subject);	
	var aa = new Array();	
	for(var j=1; j<=5; j++) {
		if(eval('data.View.Txt'+j).replace(' ', '').length == 0) break;
		
		b = '<p><input type="radio" value="'+j+'" name="answer"/><span id="txt'+j+'">'+eval('data.View.Txt'+j)+'</span></p>';
		aa.push(b);
	}
	$('#poll_a').prepend(aa.join(""));
	$('#poll_a').append('<input type="hidden" name="num" value="'+data.View.Idx+'"/>');
}

function getPollResult(){
	var rad_val=0;
	for (var i=0; i < document.poll_a.answer.length; i++)
   	{
   		if (document.poll_a.answer[i].checked)
      	{
      		rad_val = document.poll_a.answer[i].value;
      	}
   	}
	var moduleObj5 = new module();
	moduleObj5.setServer("eu");
	moduleObj5.bDebug = true;
	if (rad_val == 0)
	{
		alert("Please select an option before submit."); 
	}
	else{
	moduleObj5.pollSubmit( document.poll_a.num.value , rad_val);}
}

function pollSubmit(){
	window.location="./COMMUNITY/POLL_VIEW.html?" + document.poll_a.num.value;
}

$(function() {
    function calculateWidth() {
            var browserWidth = parseInt($(window).width());
            if (browserWidth < 1150){
			$("#facebook").css({"left": "715px", "margin-left": "0"});
			$("#wrapper_main").css({"width": "1150px"});
            }else
		{
			$("#facebook").css({"left": "50%", "margin-left": "460px"});
			$("#wrapper_main").css({"width": "auto"});
		}
	
    }  
    var resizeTimer = null;
        $(window).bind('resize load', function() {
			if (resizeTimer) {clearTimeout(resizeTimer);}
            	resizeTimer = setTimeout(calculateWidth, 2);
    });
	
});

