
var _nation_name_json = "";
_nation_name_json += "[{";
//아시아
_nation_name_json += "'말레이시아'	:'images/index/country_group1_01.gif',";
_nation_name_json += "'방글라데시'	:'images/index/country_group1_02.gif',";
_nation_name_json += "'베트남'		:'images/index/country_group1_03.gif',";
_nation_name_json += "'인도'			:'images/index/country_group1_04.gif',";
_nation_name_json += "'인도네시아':'images/index/country_group1_05.gif',";
_nation_name_json += "'일본'			:'images/index/country_group1_06.gif',";
_nation_name_json += "'중국'			:'images/index/country_group1_07.gif',";
_nation_name_json += "'태국'			:'images/index/country_group1_08.gif',";
_nation_name_json += "'요르단'		:'images/index/country_group1_09.gif',";
_nation_name_json += "'UAE'			:'images/index/country_group1_10.gif',";
_nation_name_json += "'호주'			:'images/index/country_group1_11.gif',";
_nation_name_json += "'카자흐스탄':'images/index/country_group1_12.gif',";
//아메리카
_nation_name_json += "'미국'			:'images/index/country_group2_01.gif',";
_nation_name_json += "'캐나다'		:'images/index/country_group2_02.gif',";
_nation_name_json += "'브라질'		:'images/index/country_group2_03.gif',";
_nation_name_json += "'아르헨티나'	:'images/index/country_group2_04.gif',";
_nation_name_json += "'칠레'			:'images/index/country_group2_05.gif',";
//유럽
_nation_name_json += "'네덜란드'	:'images/index/country_group3_01.gif',";
_nation_name_json += "'독일'			:'images/index/country_group3_02.gif',";
_nation_name_json += "'벨기에'		:'images/index/country_group3_03.gif',";
_nation_name_json += "'스페인'		:'images/index/country_group3_04.gif',";
_nation_name_json += "'영국'			:'images/index/country_group3_05.gif',";
_nation_name_json += "'터키'			:'images/index/country_group3_06.gif',";
_nation_name_json += "'루마니아'	:'images/index/country_group3_07.gif',";
_nation_name_json += "'체코'			:'images/index/country_group3_08.gif',";
_nation_name_json += "'프랑스'		:'images/index/country_group3_09.gif',";
_nation_name_json += "'우크라이나'	:'images/index/country_group3_10.gif',";
_nation_name_json += "'러시아'		:'images/index/country_group3_11.gif',";
//중동-아프리카
_nation_name_json += "'남아공'		:'images/index/country_group4_01.gif',";
_nation_name_json += "'이집트'		:'images/index/country_group4_02.gif'";
//기타국가
_nation_name_json += "}]";
_nation_name_json += "";

var _nation_name = eval('('+_nation_name_json+')');



var nation_flag_name = [
'<img src="images/index/dt_country_group1_01.gif" alt="말레이시아"/>',
'<img src="images/index/dt_country_group1_02.gif" alt="방글라데시"/>',
'<img src="images/index/dt_country_group1_03.gif" alt="베트남" />',
'<img src="images/index/dt_country_group1_04.gif" alt="인도" />',
'<img src="images/index/dt_country_group1_05.gif" alt="인도네시아" />',
'<img src="images/index/dt_country_group1_06.gif" alt="일본" />',
'<img src="images/index/dt_country_group1_07.gif" alt="중국" />',
'<img src="images/index/dt_country_group1_08.gif" alt="태국" />',
'<img src="images/index/dt_country_group1_09.gif" alt="요르단" />',
'<img src="images/index/dt_country_group1_10.gif" alt="UAE" />',
'<img src="images/index/dt_country_group1_11.gif" alt="호주" />',
'<img src="images/index/dt_country_group1_12.gif" alt="카자흐스탄" />',
'<img src="images/index/dt_country_group2_01.gif" alt="미국" />',
'<img src="images/index/dt_country_group2_02.gif" alt="캐나다" />',
'<img src="images/index/dt_country_group2_03.gif" alt="브라질" />',
'<img src="images/index/dt_country_group2_04.gif" alt="아르헨티나" />',
'<img src="images/index/dt_country_group2_05.gif" alt="칠레" />',
'<img src="images/index/dt_country_group3_01.gif" alt="네덜란드" />',
'<img src="images/index/dt_country_group3_02.gif" alt="독일" />',
'<img src="images/index/dt_country_group3_03.gif" alt="벨기에" />',
'<img src="images/index/dt_country_group3_04.gif" alt="스페인" />',
'<img src="images/index/dt_country_group3_05.gif" alt="영국" />',
'<img src="images/index/dt_country_group3_06.gif" alt="터키" />',
'<img src="images/index/dt_country_group3_07.gif" alt="루마니아" />',
'<img src="images/index/dt_country_group3_08.gif" alt="체코" />',
'<img src="images/index/dt_country_group3_09.gif" alt="프랑스" />',
'<img src="images/index/dt_country_group3_10.gif" alt="우크라이나" />',
'<img src="images/index/dt_country_group3_11.gif" alt="러시아" />',
'<img src="images/index/dt_country_group4_01.gif" alt="남아공" />',
'<img src="images/index/dt_country_group4_02.gif" alt="이집트" />'
];
							
function set_nation(id,w){

		$.ajax({
			url:'/coopers/get_categories/'+id+'/'+w,
			dataType:'json',
			success:function(json){

				$('#nation-desc dt').remove();//나라 상세정보
				$('#nation-desc dd').remove();//나라 상세정보				

				if( w == 2 ){
//					$('#pannel').css({opacity:0.8});
//					$('#pannel').animate({left:275},500);

					for(i =0 ; i < nation_flag_name.length; i++ ){
						var nation_name = $.trim(json['parent'].category_nm);
						if( nation_flag_name[i].indexOf(nation_name) != -1 ){
							$('#nation-desc').append($('<dt class=\"world_list1\">' + nation_flag_name[i] + '</dt>'));							
							break;
						}
					}
//							$('#nation-desc dl').append($('<dd class=\"world_list1\">' + json['parent'].category_nm + '</dd>'));							
//					$('#nation-desc ul').append($('<li class=\"world_list2\"><img src=\"/files/country/' + json['parent'].image + '\" /></li>'));
				}else{

					$('#nationlink li').remove();
					$('#map img.point').remove();
										
					$('#state li').removeAttr('class');		
					$('#'+id).attr('class','on');					
				}

				var _first_nation = null;
				for(i = 0; i < json['categories'].length; i++ ){
					if( w == 1 ){

						var img = $('<img class=\"point\" id=\"' +  json['categories'][i].CooperCategory.id + '\"  />').attr('src','/images/point.png');
						img.css({position:'absolute',left:json['categories'][i].CooperCategory.x,top:json['categories'][i].CooperCategory.y,display:'block'});
						$(img).qtip({style:{zIndex:1999,width:108},content:json['categories'][i].CooperCategory.category_nm+'<br /><img src=\"/files/country/' + json['categories'][i].CooperCategory.image + '\" />'});

						$('#map').append(img);
						
						
						for(nat in _nation_name[0] ){
						
							if( nat == $.trim(json['categories'][i].CooperCategory.category_nm)){
								var _class = 'ndesc';

								if( i == 0 ){
									_first_nation = json['categories'][i].CooperCategory.id;
								 	_class = 'ndsc first';
								}
								$('#nationlink').append($('<li class=\"' + _class + '\"><a href=\"javascript:void(0)\" onclick=\"set_nation(' + json['categories'][i].CooperCategory.id + ',2)\"><img src=\"' + _nation_name[0][nat] + '\" alt=\"'+json['categories'][i].CooperCategory.category_nm + '\" /></a></li>'));							
							
								break;
							}
						}//end of for;						


						
					}else if( w == 2 ){


						switch($.trim(json['categories'][i].CooperCategory.category_nm)){
							case "원자력현황":
								$('#nation-desc').append($('<dd class=\"world_list3\"><a href=\"/redirects/goFromMain/' + json['categories'][i].CooperCategory.id + '\"><img src="images/index/coop_link1.gif" alt="원자력현황"/></a></dd>'));							
								break;
							case "협력현황":
								$('#nation-desc').append($('<dd class=\"world_list3\"><a href=\"/redirects/goFromMain/' + json['categories'][i].CooperCategory.id + '\"><img src="images/index/coop_link2.gif" alt="협력현황"/></a></dd>'));							
								break;
							case "국가개황":
								$('#nation-desc').append($('<dd class=\"world_list3\"><a href=\"/redirects/goFromMain/' + json['categories'][i].CooperCategory.id + '\"><img src="images/index/coop_link3.gif" alt="국가개황"/></a></dd>'));							
								break;
							case "관련기관":
								$('#nation-desc').append($('<dd class=\"world_list3\"><a href=\"/redirects/goFromMain/' + json['categories'][i].CooperCategory.id + '\"><img src="images/index/coop_link4.gif" alt="관련기관"/></a></dd>'));							
								break;
							case "회의정보":
								$('#nation-desc').append($('<dd class=\"world_list3\"><a href=\"/redirects/goFromMain/' + json['categories'][i].CooperCategory.id + '\"><img src="images/index/coop_link5.gif" alt="회의정보"/></a></dd>'));							
								break;																									
						}

					}
				}//end of for;
				set_point_link();
				
				//first init
				if( _first_nation ) set_nation(_first_nation,2);
			}//end of success
		});
	}

function set_point_link(){
	$('.point').unbind('click');
	$('.point').click(function(){

		var _this = $(this);
		_this.css('cursor','pointer');
		set_nation(_this.attr('id'),2);
	});
}


		var nation_title_kr = new Array();
		var nation_title_en = new Array();		
		//아시아=86
		//아메리카=87
		//유럽=88
		//중동.아프리카=89
		//기타국가=510		
		var nation_code = [86,87,88,89,510];
		
		for(i = 0 ; i < nation_code.length;i++){
			var image1 = new Image();
			image1.src = 'images/index/txt_coop_group'+(i+1)+'.gif';
			nation_title_kr[nation_code[i]]= image1;
			
			var image2 = new Image();
			image2.src = 'images/index/eng_coop_group'+(i+1)+'.gif';			
			nation_title_en[nation_code[i]]= image2;			
		}
		
//document.ready
$(function(){

  $("div#slider1").codaSlider(1);
  
	var ar = setInterval(function() { $('#stripNavR1 a').click(); }, 5000);
          $('#update').mouseover(function() {
            clearInterval(ar)
          }).mouseout(function() {
            ar = setInterval(function() { $('#stripNavR1 a').click(); }, 5000);
  });
            
  
	$('#btn-nation-open').click(function(){
		$('#map').slideDown();
	});



		
	$('#state li').click(function(){
//		$('#btn-nclose').show();
		$('dl.link').fadeIn();

		var _id = $(this).attr('id');

		
		$('#nation-kr').attr('src',nation_title_kr[_id].src);		
		$('#nation-en').attr('src',nation_title_en[_id].src);

		set_nation(_id,1);
		

	});



	$('#btn-nclose').click(function(){
		$('#map').slideUp();
		$('#btn-nclose').hide();
	});
	
	//nation initialize
	set_nation(86,1);
	
	
	var iconItemsCount = $('#icon-items li').length;
	var iconDefualtItemCount = 8;
	var iconDefaultWidth = 104;
	var iconMoveCount=0;
	
	$('#icon-prev').click(function(){

		if( iconMoveCount >= 0 ) return;
		iconMoveCount++;
		$('#icon-slider').animate({'left': iconDefaultWidth*iconMoveCount}, 'slow');		
		return false;
	});
	$('#icon-next').click(function(){
		if( iconItemsCount > iconDefualtItemCount ){
			if( Math.abs(iconMoveCount) >= (iconItemsCount-iconDefualtItemCount) ) return;		
			iconMoveCount--;
			$('#icon-slider').animate({'left': iconDefaultWidth*iconMoveCount}, 'slow');
		}
		return false;	
	});	

});
