﻿
$(function(){
	$('#columnList').ready(function (){
		$.ajax({
			url: '/profile/list.xml',
			type: 'GET',
			dataType: 'xml',
			cache: false,
			timeout: 10000,
			error: function(){
			},
			success: function(xml){
				$('ul#columnList li p').each(function(){
					htmlTag = $(this);
					htmlName = $(this).text();
					profiles = $(xml).find('profile');
			    	profiles.each(function(){
						xmlName = $(this).attr('name');
						if(htmlName == xmlName){
							imgURL = $(this).find('img').find('a').attr('href');
							htmlTag.css('visibility','visible').html('<img src="' + imgURL + '" width="54" height="58" />');
						}
			    	});				
				});
			}
		});
	});
	
	/*
	$('ul#columnList li:odd').css('border-right','none');
	$('ul#columnList li:even').css('clear','both');
	$('ul#columnList li:eq(0)').css('border-top','none');
	$('ul#columnList li:eq(1)').css('border-top','none');
	*/
	if($('ul#columnList li')){
		liSize = $('ul#columnList li').size();
		newList = '';
		for(i=0; i<liSize; i++){
			if(i%2 == 0){
				newList += '<ul class="columnList"><li>' + $('ul#columnList li').eq(i).html() +'</li>';
			}else if(i%2 == 1){
				newList += '<li>' + $('ul#columnList li').eq(i).html() + '</li></ul>';
			}
			
		}
		$('ul#columnList').empty().html(newList).fadeIn(500);
		$('ul.columnList').eq(0).css('border-top','none');
		$('ul.columnList li:odd').css('border-right','none');
	}
	
	magImg = $('#magazine p a').attr('href');
	$('#magazine p').html('<img src="' +magImg+ '" width="96" height="127" alt="" />');
	
	$('table#headlineList a.clickCount').click(function(){
		//alert($(this).attr('id'));
		
		urchinTracker('/' +$(this).attr('id')+ '/');
	});


	//if($('dl#newsList').html().indexOf("dd") == -1) $('#comuBox').css('display','none');

	if($('.thumb_txt02 td.thumb')){
		$('.thumb_txt02 td.thumb').each(function(){
			thumbSrc = $(this).find('a').attr('href');
			$(this).html('<img src="' +thumbSrc+ '" width="50" height="50" alt="" />');
		});
	}
	
	if($('#pickUpList th')){
		$('#pickUpList th').each(function(){
			thumbSrc = $(this).find('a').attr('href');
			$(this).html('<img src="' +thumbSrc+ '" width="60" height="60" alt="" />');
		});
	}
	
	thumbSrc = $('#cooperation th').find('a').attr('href');
	$('#cooperation th').html('<img src="' +thumbSrc+ '" width="50" height="50" alt="" />');
});
