$(document).ready(function(){

	//tb_show("esfsdfs","<div>test</div>"); 
loc = ""+document.location; locs =  loc.split('/'); blog_name = locs[3]; ajax_serv = $('#template_dir').text()+"/";if(window.navigator.appVersion.indexOf("IE")!=-1){}else{window.onresize=reloadme;}
setWindowDim();
picto_visible = true;

$('.grouped_questions').click(function(){
	$(this).children('div').toggle();
	$('#content').jScrollPane({scrollbarWidth:00,maintainPosition:true});
});

initScroll_content=function(){
	$('#content').jScrollPane({scrollbarWidth:00,maintainPosition:true});
};

initScroll_r_sidebar = function() {
      $('#r-sidebar').jScrollPane({scrollbarWidth : 00, maintainPosition : true});
}; 

initScroll_l_sidebar=function(){
	 $('#l-sidebar').jScrollPane({scrollbarWidth:00, animateTo:true, animateInterval:10});
	 $('#l-sidebar_inner').children('ul').children('li').each(function(){
	 	$(this).children('ul').children('.current_page_item').attr('id', 'scrollto');
	 	if($('#l-sidebar').parent().children('div:eq(1)').hasClass('jScrollPaneTrack')){
	 		 $('#l-sidebar')[0].scrollTo('#scrollto');
	 	}
	 });
};

retrieve_cookie_datas("user_voted_pages");set_l_sidebar();loc=window.location+"";expression=/page_id/g;if(expression.test(loc)==false){

	FixCookie('anim_status','shown',null,"/");
	$('#r-sidebar').children('div').prepend("<div id='hide_div_attente'></div>");
	$('#hide_div_attente').click(function(){hide_r_sidebar(300);});
	if($('.forum_closed').length > 0){
		hide_r_sidebar(300, function(){
			$('#r-sidebar').hide();
		});
	}
	
	}else{page_id=$('#hidden_page_id').text();show_media_title(page_id);hide_r_sidebar(1);}
init_header_elements();
	setTimeout(function(){
		if(!jQuery('#iframed_banner').hasClass('closed')){
			hide_rsr_banner();
		}
	}, 4000);		
	
	jQuery('#banner_rsr_button').click(function(){ // modifiy with the id of rsr picto containing div
		if(jQuery('#iframed_banner').hasClass('closed')){
			show_rsr_banner();
		}else{
			hide_rsr_banner();
		}
	});
	if(getCookie('banner_status') != 'true'){
		var expdate = new Date ();
		DateExpiration (expdate);
		expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000)); 
		FixCookie('banner_status', 'true', expdate);	
	}	
});

function show_rsr_banner(){
	jQuery('#iframed_banner').slideDown('slow', function(){
		jQuery('#iframed_banner').removeClass('closed');
		button_src = jQuery('#banner_rsr_button').children('img').attr('src');
		new_button_src = button_src.replace("close", "open");
		jQuery('#banner_rsr_button').children('img').attr('src', new_button_src);
	});
}
function hide_rsr_banner(){
	jQuery('#iframed_banner').slideUp('slow', function(){
		jQuery('#iframed_banner').addClass('closed');
		button_src = jQuery('#banner_rsr_button').children('img').attr('src');
		new_button_src = button_src.replace("open", "close");
		jQuery('#banner_rsr_button').children('img').attr('src', new_button_src);
	});
}

function reloadme(){setTimeout("window.location.reload()",1);}
function show_media_title(page_id){data_string="id_post_blog="+blog_name+"&page_id="+page_id;$.ajax({type:'POST',url:ajax_serv+'get_media_title.php',data:data_string,success:function(msg){$('#inner_content').append("<div id='media_handling' style='display:none'></div>");$('#media_handling').append(msg);count=0;$('#media_handling').children('a').each(function(){ext=$(this).attr('href');ext=ext.substr((ext.length-3),ext.length);if(ext=='mp3'){$(".audioplayer_container:eq("+count+")").prepend("<div class='media_title'>"+$(this).text()+"<div>");count++;}});}});}
function scroll_up(element){eq=0;if(element=="content"){eq=0;}else if(element=="l-sidebar"){eq=1;}else if(element=="r-sidebar"){eq=2;}
element=$("#"+element);element[0].scrollBy(-30);if(element.css('top')=='0px'){$(".jcarousel-prev-vertical:eq("+eq+")").attr('style','display:none');}else{$(".jcarousel-prev-vertical:eq("+eq+")").attr('style','display:block');}
window_height=pageHeight()-150;bar_height=element.height()*(1);scroll_position_string=element.css('top');scroll_position=scroll_position_string.substr(0,(scroll_position_string.length-2))*(-1);if(scroll_position==(bar_height-window_height)){$(".jcarousel-next-vertical:eq("+eq+")").attr('style','display:none');}else{$(".jcarousel-next-vertical:eq("+eq+")").attr('style','display:block');}}
function scroll_down(element){eq=0;if(element=="content"){eq=0;}else if(element=="l-sidebar"){eq=1;}else if(element=="r-sidebar"){eq=2;}
element=$("#"+element);element[0].scrollBy(30);if(element.css('top')=='0px'){$(".jcarousel-prev-vertical:eq("+eq+")").attr('style','display:none');}else{$(".jcarousel-prev-vertical:eq("+eq+")").attr('style','display:block');}
window_height=pageHeight()-150;bar_height=element.height()*(1);scroll_position_string=element.css('top');scroll_position=scroll_position_string.substr(0,(scroll_position_string.length-2))*(-1);if(scroll_position==(bar_height-window_height)){$(".jcarousel-next-vertical:eq("+eq+")").attr('style','display:none');}else{$(".jcarousel-next-vertical:eq("+eq+")").attr('style','display:block');}}
function init_header_elements(){
	data_string = 'blog_name='+blog_name;
	jQuery.ajax({
	   type: 'POST',
	   url: ajax_serv+'is_archived.php',
	   data: data_string,
	   success: function(msg){
	   	if(msg == 'not_closed'){
		   FixCookie('menu_status', "off", null, "/");
		   jQuery('#ask_question').click(function() {
			if(getCookie('menu_status') == "off") {
			   FixCookie('menu_status', "on", null, "/"); if(jQuery("#headers2").text() == "") {
				show_question_form(); }
			   jQuery('body').attr('style', 'overflow:hidden'); jQuery('#header').fadeOut('fast'); jQuery("#headers").animate( {
				"height" : "+=195"}
			   , "medium", function() {
				}
			   ); }
			}
		   );	   		   	
	   	}else{
	   		jQuery('#ask_question').empty();
	   		jQuery('#ask_question').html("<div class='forum_closed'>"+msg+"</div>"); // TODO 
	   		if(getCookie('anim_status')=="shown"){
	   			hide_r_sidebar(1);
	   			picto_visible = false;
	   		}else{
	   			$('#show_div_attente').hide();
	   		}
	   		//
	   		
	   	}
	   }
	 });
}
function show_question_form(){data_string='id_post_blog='+blog_name+'&server='+ajax_serv;$.ajax({type:'POST',url:ajax_serv+'static_question_form.php',data:data_string,success:function(msg){$('#header2').empty();$('#header2').append(msg);$("#question_form").after("<div id=\"riffly_button_window\" ><a style=\"font-weight: bold;font-size: 14px;\" href=\"javascript:void(0);\" onclick=\"rifflyShowRecorder('riffly_recorder_window', 'comment', 'video');\"> Enregistrer une vid&eacute;o</a> | <a style=\"font-weight: bold;font-size: 14px;\" href=\"javascript:void(0);\" onclick=\"rifflyShowRecorder('riffly_recorder_window', 'comment', 'audio');\"> Enregistrer un son</a><br /></div><div id=\"riffly_recorder_window\" style=\"display: none;position: relative;z-index: 2000;\">\ntest\n</div>");init_form();}});}
function init_form(){
   	img = document.getElementById('imgCaptcha'); 
	img.src = ajax_serv+'create_image.php?' + Math.random();
	$('#imgCaptcha').click(function(){
	   	img = document.getElementById('imgCaptcha'); 
   		img.src = ajax_serv+'create_image.php?' + Math.random();   			
	});	

$('#question_text, #question_user_mail, .question_answer').addClass("field_error");$('#question_user_mail').keyup(function(){if(!echeck($(this).val())){$(this).addClass("field_error");}else{if($(this).hasClass("field_error")){$(this).removeClass("field_error");}}});

$('#question_text').keyup(function(){if($(this).val()==""){$(this).addClass("field_error");}else{if($(this).hasClass("field_error")){$(this).removeClass("field_error");}}});$('.question_answer').keyup(function(){validate_antispam_answer($(this));});

   $('#txtcaptcha').keyup(function(){
   		data_string = "txtcaptcha="+jQuery(this).val();
		 $.ajax( {
		    type : 'POST', 
		    url : ajax_serv + 'validate_captcha.php', 
		    data : data_string, 
		    success : function(msg) {
		       if(msg == "success"){
		       	$('#txtcaptcha').removeClass("field_error");
		       }else{
		       	$('#txtcaptcha').addClass("field_error");
		       }
		    }
		 });   	
   });

$('#header2').fadeIn('slow').attr('style','display:block');}



function hide_question_form(){$('#question_sent').remove();$('#header2').fadeOut('fast');$("#headers").animate({"height":"-=195"},"medium",function(){$('#header').fadeIn('fast');FixCookie('menu_status',"off",null,"/");});}
function validate_antispam_answer(element){img_loader_url=ajax_serv+"i/ajax-loader.gif";element.attr("style","background-image:url('"+img_loader_url+"');background-repeat:no-repeat;background-position:right center");field_id=element.attr('id');antispam_question_id=field_id.substr(16,field_id.length);antispam_response=element.val();data_string='id_post_blog='+blog_name+'&antispam_question_id='+antispam_question_id+"&antispam_response="+antispam_response;$.ajax({type:'POST',url:ajax_serv+'validate_antispam_answer.php',data:data_string,success:function(msg){element.attr("style","");if(msg=='valid'){img_url=ajax_serv+"i/tick.png";element.attr("style","background-image:url('"+img_url+"');background-repeat:no-repeat;background-position:right center");if(element.hasClass("field_error")){element.removeClass("field_error");}}else{img_url=ajax_serv+"i/cross.png";element.attr("style","background-image:url('"+img_url+"');background-repeat:no-repeat;background-position:right center");if(!element.hasClass("field_error")){element.addClass("field_error");}}}});}
function urlencode(ch) {
ch = ch.replace(/[ ]/g,"+")
return escape(ch)
}
function rload(){
	window.location.reload();
}
function add_new_question(){

	if($('.field_error').length==0){
		user_login=getCookie("current_user_login");
      if(document.getElementById('question_user_name').value == "Votre nom ou pseudonyme" || document.getElementById('question_user_name').value == ""){
      	user_name = "anonyme";
      }else{
      	user_name = document.getElementById('question_user_name').value;
      }
		data_string='id_post_blog='+blog_name+'&question_text='+urlencode(document.getElementById('question_text').value)+"&question_category="+document.getElementById('question_cat').value+"&question_user_name="+user_name+"&question_user_mail="+document.getElementById('question_user_mail').value+"&question_user_num="+document.getElementById('question_user_num').value+"&content="+document.getElementById('comment').value+"&user_login=";
		
		$.ajax({
			type:'POST',
			url:ajax_serv+'add_new_question.php',
			contentType: "application/x-www-form-urlencoded",
			data:data_string,
			success:function(msg){
				$('#header2').fadeOut('fast');
				$("#headers").append("<div id='question_sent'>La question a été envoyée avec succès!</div>");
				setTimeout("hide_question_form()",3000);
				setTimeout("rload()",4000);
			}
		});
	}else{
		alert_text="Veuillez vérifier les champs suivants :";
		$('.field_error').each(function(){
			field_id=$(this).attr('id');
			text_to_append="";
			if(field_id=="question_text"){
				text_to_append="\n- Question";
			}else if(field_id=="question_user_name"){
				text_to_append="\n- Nom";
			}else if(field_id=="question_user_mail"){
				text_to_append="\n- Email";
			}else if(field_id=="question_user_num"){
				text_to_append="\n- N° de tél";
			}else{
				text_to_append="\n- code de sécurité";
			}
			alert_text += text_to_append; 
			img = document.getElementById('imgCaptcha'); 
			img.src = ajax_serv+'create_image.php?' + Math.random(); 
		});
	alert(alert_text);
	}
	FixCookie('send_button_click',"unclicked",null,"/");
}
function getCookie(nom){deb=document.cookie.indexOf(nom+"=");if(deb>=0){deb+=nom.length+1;fin=document.cookie.indexOf(";",deb);if(fin<0)fin=document.cookie.length;return unescape(document.cookie.substring(deb,fin));}
return"";}
function FixCookie(nom,valeur,expire,path,domaine,securise){document.cookie=nom+"="+escape(valeur)+((expire)?"; expires="+expire.toGMTString():"")+((path)?"; path="+path:"")+((domaine)?"; domain="+domaine:"")+((securise)?"; secure":"");}
function hide_r_sidebar(speed){
$('#r-sidebar').children('div').children('div').remove();FixCookie('anim_status','hidden',null,"/");$('#r-sidebar').parent().fadeOut(speed,function(){$('#sidebars').animate({"width":"-=260px"},speed,function(){


if(!picto_visible){
}else{
	$('#l-sidebar').children('div').prepend("<div id='show_div_attente'></div>");
}

$('#show_div_attente').click(function(){show_r_sidebar(300);});});$("#content").animate({"width":"+=260"},speed);

//$("#before_footer").animate({"left":"+=250"},speed);
$("#content").parent().animate({"width":"+=260"},speed);$("#inner_content").animate({"width":"+=260"},speed,function(){setTimeout('initScroll_content()',200);});$('#r-sidebar').parent().attr("style","display:none");});}
function show_r_sidebar(speed){
			style = $('#l-sidebar').parent().attr('style');
			$('#r-sidebar').parent().attr('style', style);
$('#l-sidebar').children('div').children('div').remove();FixCookie('anim_status','shown',null,"/");$("#content").animate({"width":"-=260"});$("#content").parent().animate({"width":"-=260"},speed,function(){$('#l-sidebar').children('div').children('div').remove();$('#r-sidebar').parent().fadeIn(speed);$('#r-sidebar').children('div').prepend("<div id='hide_div_attente'></div>");$('#hide_div_attente').click(function(){hide_r_sidebar(300);});setTimeout('initScroll_content()',200);});$("#inner_content").animate({"width":"-=260"},speed);

//$("#before_footer").animate({"left":"-=250"},speed);
$('#sidebars').animate({"width":"+=260px"},speed);}
function setWindowDim(){windowHeight=pageHeight();windowHeight_normal=windowHeight-200;windowHeight_string="height:"+windowHeight_normal+"px";$("#l-sidebar, #r-sidebar, #content").attr("style",windowHeight_string);}
function set_sidebars_status(){if(getCookie('anim_status')=="shown"){$('#r-sidebar').children('div').prepend("<div id='hide_div_attente'></div>");$('#hide_div_attente').click(function(){setTimeout('hide_r_sidebar()',500);});}else if(getCookie('anim_status')=="hidden"){hide_r_sidebar();}else{$('#r-sidebar').children('div').prepend("<div id='hide_div_attente'></div>");$('#hide_div_attente').click(function(){setTimeout('hide_r_sidebar()',500);});FixCookie('anim_status','hidden',null,"/");}}
function retrieve_cookie_datas(cookie_name){data_string='id_post_blog='+blog_name+'&cookie_name='+cookie_name;$.ajax({type:'POST',url:ajax_serv+'get_cookie_val.php',data:data_string,success:function(msg){if(msg=="no items"){set_r_sidebar();}else{voted_pages=msg.split(',');for(i=0;i<voted_pages.length;i++){if(i<((voted_pages.length)-1)){get_vote_result(voted_pages[i],0);}else{get_vote_result(voted_pages[i],1);}}}}});}
function get_vote_result(page_id,indicator){data_string='id_post_blog='+blog_name+'&page_id='+page_id;$.ajax({type:'POST',url:ajax_serv+'get_vote_result.php',data:data_string,success:function(msg){element_class="page-item-"+page_id;$('.'+element_class).addClass("voted");$('.'+element_class).append(msg);$('.'+element_class).children('div').attr('style','display:none');if(indicator==1){set_r_sidebar();}}});}
function set_l_sidebar(){$("#l-sidebar").children('div').children("ul").children("li").children('b').children('a').each(function(){if(!$(this).parent().parent().children('ul').children('li').hasClass('current_page_item')){$(this).parent().parent().children('ul').children('li').attr("style","display:none");}else{$(this).addClass('activ');}
$(this).click(function(){if($(this).hasClass('activ')){$(this).removeClass('activ');$(this).parent().parent().children('ul').children('li').slideUp('fast');}else{$("#l-sidebar").children('div').children("ul").children("li").children('b').children('a').each(function(){$(this).removeClass('activ');$(this).parent().parent().children('ul').children('li').slideUp('fast');});$(this).parent().parent().children('ul').children('li').slideDown("fast");$(this).addClass('activ');}
setTimeout('initScroll_l_sidebar()',500);});});setTimeout('initScroll_l_sidebar()',500);initScroll_content();}
function shadow_box(page_id,long_question){
	$('body').prepend('<div style="display:none" id="page_hidden_content_'+page_id+'"></div>');
	$('#page_hidden_content_'+page_id+'').append("<div id='shadowbox_content'><div class='shadowbox_vote_for_me' id='id_'"+page_id+"' style='display:block'><div class='shadowbox_vote_for_me_top'></div><div class='shadowbox_vote_for_me_middle'><div class='shadowbox_vote_for_me_thumbs'>On en parle?<br /><img onclick=\"shadow_box_save_vote("+page_id+", 'oui');\" class='yes_clicked' src='"+ajax_serv+"i/shadow_thumb_up.gif'><img class='no_clicked' onclick=\"shadow_box_save_vote("+page_id+", 'non');\" src='"+ajax_serv+"i/shadow_thumb_down.gif'></div><div class='shadowbox_vote_for_me_text'>"+long_question+"</div></div><div class='shadowbox_vote_for_me_bottom'></div></div></div>");
	
	tb_show("","#TB_inline?height=350&width=300&inlineId=page_hidden_content_"+page_id+"");
}


function shadow_box_result(page_id,yes_percent,no_percent){
	$('body').prepend('<div style="display:none" id="page_hidden_voted_content_'+page_id+'"></div>');
	long_question=$("#shadowbox_question_long_"+page_id+"").text()
	$('#page_hidden_voted_content_'+page_id+'').append("<div id='shadowbox_content'><div class='shadowbox_vote_for_me' style='display:block'><div class='shadowbox_vote_for_me_top'></div><div class='shadowbox_vote_for_me_middle'><div class='shadowbox_vote_result_thumbs'>On en parle?<br /><div class='shadowbox_yes_votes'>Oui : "+yes_percent+" %</div><div class='shadowbox_no_votes'>Non : "+no_percent+" %</div></div><div class='shadowbox_vote_for_me_text'>"+long_question+"</div></div><div class='shadowbox_vote_for_me_bottom'></div></div></div>");
	tb_show("","#TB_inline?height=350&width=300&inlineId=page_hidden_voted_content_"+page_id+"");
}

function shadow_box_save_vote(page_id,response){
	element="question_"+page_id;
	save_vote(element,response);
	data_string='id_post_blog='+blog_name+'&page_id='+page_id;
	$.ajax({
		type:'POST',
		url:ajax_serv+'get_vote_result_shadowbox.php',
		data:data_string,
		success:function(msg){
			$('#shadowbox_content').empty();
			$('#shadowbox_content').append(msg);
		}
	});
}
function addslashes( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ates Goral (http://magnetiq.com)
    // +   improved by: marrtins
    // +   improved by: Nate
    // +   improved by: Onno Marsman
    // *     example 1: addslashes("kevin's birthday");
    // *     returns 1: 'kevin\'s birthday'
 
    return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");
}

function set_r_sidebar(){
	$("#r-sidebar").children('div').children("ul").children("li").children('b').children('a').each(function(){
		$(this).parent().parent().children('ul').children('li').each(function(){
			long_question=$(this).children('a').text();
			page_id=$(this).attr('id');
			page_id=page_id.substr(9,page_id.length);
			if(long_question.length>120){
				long_question_100=long_question.substr(0,120);
				var reg=new RegExp("(\n)","g");
				long_question=long_question.replace(reg," ");
				long_question = addslashes(long_question)
				click_string="shadow_box("+page_id+", \""+long_question+"\");";long_question_100+=" ...<br /><span>[<a class='question_box' id='question_box"+page_id+"' onclick='"+click_string+"'>suite</a>]</span>";
			}else{
				long_question_100=long_question;
			}
			if(long_question.length>65){
				$(this).children('a').text($(this).children('a').text().substr(0,74)+" ...");
			}
			if(!$(this).hasClass('voted')){
				$(this).addClass("not_voted");
				$(this).append("<div class='vote_for_me' style='display:none'><div class='vote_for_me_top'></div><div class='vote_for_me_middle'><div class='vote_for_me_thumbs'>On en parle?<br /><img class='yes_clicked' src='"+ajax_serv+"i/thumb_up.gif'><img class='no_clicked' src='"+ajax_serv+"i/thumb_down.gif'></div><div class='vote_for_me_text'>"+long_question_100+" </div></div><div class='vote_for_me_bottom'></div></div>");
			}
		});
		$(this).parent().parent().children('ul').children('li').attr("style","display:none");
		$(this).click(function(){
			if($(this).hasClass('activ')){
				$(this).removeClass('activ');
				$(this).parent().parent().children('ul').children('li').slideUp('fast');
			}else{
				$("#r-sidebar").children('div').children("ul").children("li").children('b').children('a').each(function(){
					$(this).removeClass('activ');
					$(this).parent().parent().children('ul').children('li').slideUp('fast');
				});
				$(this).parent().parent().children('ul').children('li').slideDown("fast",function(){
					
				});
				$(this).addClass('activ');
			}
			style = $('#l-sidebar').parent().attr('style');
			$('#r-sidebar').parent().attr('style', style);
			setTimeout('initScroll_r_sidebar()',400);
		});
	});
	$('.yes_clicked').click(function(){
		element = $(this).parent().parent().parent().parent().attr('id');
		if(!$('#'+element).hasClass('voted')){
			save_vote($(this).parent().parent().parent().parent().attr('id'),'oui');
			$('#'+element).addClass('voted')
		}
	});
	$('.no_clicked').click(function(){
		element = $(this).parent().parent().parent().parent().attr('id');
		if(!$('#'+element).hasClass('voted')){
			save_vote($(this).parent().parent().parent().parent().attr('id'),'non');
			$('#'+element).addClass('voted')
		}
	});
	setTimeout('initScroll_r_sidebar()',400);
	set_r_sidebar_events();
}
function set_r_sidebar_events(){$("#r-sidebar").children('div').children("ul").children("li").children('ul').children('li').each(function(){$(this).hover(function(){extend_question($(this));},function(){unextend_question($(this));});});}

function extend_question(element){
	element.children('div').children('div:eq(1)').children('div:eq(1)').children('a').remove();
	element.children('a').attr("style","display:none");
	element_id=element.attr('id');
	element_id=element_id.substr(9,element_id.length);
	data_string="id_post_blog="+blog_name+"&page_id="+element_id;
	$.ajax({
		type:'POST',
		url:ajax_serv+'get_media_title.php',
		data:data_string,
		success:function(msg){
			if(msg==""){
			}else{
				msgTokens = msg.split('|');
				type = msgTokens[0];
				riffly_id = msgTokens[1];
				
				$('body').append('<div id="hidden_riff_content_'+element_id+'" style="display:none;" ></div>');
				rifflyShowPlayer("hidden_riff_content_"+element_id, riffly_id, type);
				
				if(type == 'video' ){
					if($("#play_vid_"+element_id+"").length == 0){
						element.children('div').children('div:eq(1)').children('div:eq(1)').append("<a class='play_vid' id='play_vid_"+element_id+"' >Lire la vidéo</a>");
					}
					$('#play_vid_'+element_id).click(function(){
						tb_show("","#TB_inline?height=330&width=410&inlineId=hidden_riff_content_"+element_id+"");
					});
				}else if(type == 'audio' ){
					if($("#play_vid_"+element_id+"").length == 0){
						element.children('div').children('div:eq(1)').children('div:eq(1)').append("<a class='play_vid' id='play_vid_"+element_id+"' >Lire l'audio</a>");
					}
					$('#play_vid_'+element_id).click(function(){
						tb_show("","#TB_inline?height=50&width=410&inlineId=hidden_riff_content_"+element_id+"");
					});
				}
				//Shadowbox.setup(document.getElementById("play_vid_"+element_id+""));
			}
		}
	});
	element.children('div').attr("style","display:block");
}
function unextend_question(element){element.children('div').attr("style","display:none");element.children('a').attr("style","display:block");}
function save_vote(element,response){
	element_classes=$('#'+element).attr('class').split(" ");
	element_page_class=element_classes[1];
	page_id=element_page_class.substr(10,element_page_class.length);
	data_string='id_post_blog='+blog_name+'&page_id='+page_id+'&response='+response;
	
	$.ajax({
		type:'POST',
		url:ajax_serv+'save_vote.php',
		data:data_string,
		success:function(msg){
			$('#'+element).children('div').empty();
			$('#'+element).children('div').append(msg);
		}
	});
}
function echeck(str){var at="@";var dot=".";var lat=str.indexOf(at);var lstr=str.length;var ldot=str.indexOf(dot);if(str.indexOf(at)==-1){return false;}
if(str.indexOf(at)==-1||str.indexOf(at)==0||str.indexOf(at)==lstr){return false;}
if(str.indexOf(dot)==-1||str.indexOf(dot)==0||str.indexOf(dot)==lstr){return false;}
if(str.indexOf(at,(lat+1))!=-1){return false;}
if(str.substring(lat-1,lat)==dot||str.substring(lat+1,lat+2)==dot){return false;}
if(str.indexOf(dot,(lat+2))==-1){return false;}
if(str.indexOf(" ")!=-1){return false;}
return true;}
