function makeTall(){
	if (!shown) {
		shown = true
		popup = $('.b-auth_top')
		popup.show()
		popup.animate({"top": '77px'}, 700, function(){
			shown = false
		})
	}				
}
function closeWindow(){
	popup = $('.b-auth_top')
	popup.animate({'top': '37px'}, 700)
	popup.fadeOut()	
}

$(document).ready(function(){
	$('.b-subscribe .input-text').focus(function(){
		$(this).siblings('label').hide()
	})
	$('.b-subscribe .input-text').blur(function(){
		if( $(this).val() == '' ){
			$(this).siblings('label').show()
		}
	})
	$('blockquote').append('<i class="bg"></i>')
	$('table.table').wrap('<div class="table_wrap"></div>')
	$('.table_wrap').append('<i class="bg"></i>')
	shown = false
	$('.b-enter').click(makeTall)
	$('.b-auth_top .close').click(closeWindow)
	
	$('.b-form label ins').each(function(){
		$(this).parent().prepend('<i class="q" title="' + $(this).text() + '"></i>')
	})
	
	jQuery('form select option').each(function(){
		jQuery(this).html(jQuery(this).text().replace(/^(\s*)\d+\s/,"$1").replace(/^\s+/,"&nbsp;&nbsp;"));
	})
});

function mod_cms_vote_postDo(formName, inputName, nstext) {
	var fObjColl = document.getElementsByName(formName);

	var fObj = '';
	if (fObjColl) {
		fObj = fObjColl[fObjColl.length-1];
	}

	if(typeof(fObj) !== "object") return false;
	
	iObj = fObj.elements[inputName];
	
	if(typeof(iObj) === "undefined") return false;

	res = "_";
	for(i = 0; i < iObj.length; i++)
		if(iObj[i].checked)
			res += iObj[i].value + "_";


	if(res.length > 1) {
		sc = document.createElement("script");
		sc.src = "/vote/mod_post/" + res + "/?m=" + new Date().getTime();
		oTemplate = fObj.elements['system_template'];
		if((oTemplate instanceof Object) && (oTemplate.value.length)) {		
			sc.src = sc.src + "&template="+oTemplate.value;			
		}

		fObj.appendChild(sc);
	} else {
		if(nstext) {
			alert(nstext);
		}
	}
}
