﻿/* XML POLLY GETTER
 ***********************************/
$(function() {
	$.ajax( {
		url: "/vote/vote_return.php?type=1",
		type: 'GET',
		success: function(xml) { parseXml(xml);}
	});
	
	
	// form setting
	$('#frm').ajaxForm(function() { 
		//alert("Thank you for your comment!");
		$('#polLists').animate({
			opacity: '0'
		},280,function(){
			$('#polLists').html('<img src="/img/ranking/txt_ranking_01.gif" style="margin:' + myTxtHeight +'px auto" />');
			$('#polLists').css('opacity','1');
		});
		
		$('.pollEnd input').fadeOut('fast');
	});
	//*/
	
	
	// send controle
	$('.btn_pollVote').css('display','none');
	$('.btn_pollVote').hover(
			 function(){
				 $(this).attr('src','/atsugilovers/img/ranking/btn_list-voting_2.gif');
			},function(){
				$(this).attr('src','/atsugilovers/img/ranking/btn_list-voting_1.gif');
			});
	//*/
});
var myTxtHeight = 0;
var test_id = '';
function parseXml(xml)
{
	$(xml).find('vote').find('title').each(function()
	{
		var title_str = $(this).text();
        $('#top_poll .pollQ').html(title_str);
	});
	$(xml).find('vote').find('id').each(function()
	{
		var id_str = $(this).text();
        $('#pollId').attr('value',id_str);//v009 
		$('#frm').attr('action','/cgi-bin/vote/vote.cgi?theme_id='+id_str);
	});
	var selectItem = new Object;
	var listStr = '<ul>';
	var count = 1;
	var chLogo = new Array('','a','b','c','d','e','f');
	$(xml).find('vote').find('select').find('item').each(function()
	{
		var selectItem = $(this).text();
		listStr += '<li><input type="radio" value="' + count + '" id="pol_' + count + '" class="radio" name="q0" /><label for="pol_' + count + '"> ' + selectItem + '</label></li>';
		// <img src="/atsugilovers/img/ranking/input_mark-' + chLogo[count] + '.gif" alt="' + '" />
		count ++;
	});
	listStr += '</ul>';
	$('#polLists').html(listStr);
	$('#polLists ul input').click(function(){
		var myHeight = $('#polLists').height();
		myTxtHeight = myHeight / 2 - 20;
		$('#polLists').css('height',myHeight);
		$('.btn_pollVote').css('display','block');
	});
	
}

