$(document).ready(function(){

	$('.bar').addClass('zero');	
    
});

function AnimateBarFunction()
      {
        $('.boxLine').click(function(){
        var myWidth = $('.bar', this).attr('title') + '%';
        $('.bar', this).animate({width: myWidth}, 2000);
        //$('.bar', this).html(myWidth + '&#160;'); // adds some padding after the text, but doesn't effect the width;
        });
        $('.boxLine').click();
      }

var IsShowPreview = false;

function ShowPreviewTextPoll()
{
    var pollPreviewResultButton = document.getElementById('pollPreviewResultButton');
    
    if (IsShowPreview == true)
    {
        $('span.percent').css({"display":"none"});          
        //$('.bar').css({"width":"0"}); 
        $('div.boxLine').css({"display":"none"});  
                
        $('p.pointsParagraph').css({"display":"none"});  
        
        /*Slider*/
        $(".ui-slider-1 ~ strong").css({"display":"block"});  
        $(".ui-slider-1").css({"display":"block"}); 
        
        $(".ui-slider-2 ~ strong").css({"display":"block"});  
        $(".ui-slider-2").css({"display":"block"}); 
          
        IsShowPreview = false;
              
        if (pollPreviewResultButton != null)
        {
            if(lblPreviewResult !=null && lblHideResult!=null )
            {
                pollPreviewResultButton.value = lblPreviewResult;
            }
        }
                                
    }
    else
    {
        $('span.percent').css({"display":"block"});
        $('div.boxLine').css({"display":"block"});     
        $('p.pointsParagraph').css({"display":"block"});                
        
        /*Slider*/
        $(".ui-slider-1 ~ strong").css({"display":"none"});  
        $(".ui-slider-1").css({"display":"none"});  
        
        $(".ui-slider-2 ~ strong").css({"display":"none"});  
        $(".ui-slider-2").css({"display":"none"}); 
        
        IsShowPreview = true;
        
        $('.boxLine').click(function(){
		var myWidth = $('.bar', this).attr('title') + '%';
		$('.bar', this).animate({width: myWidth}, 2000);
		//$('.bar', this).html(myWidth + '&nbsp;'); // adds some padding after the text, but doesn't effect the width;
		});
        $('.boxLine').click();	
        
        if (pollPreviewResultButton != null)
        {
            if(lblPreviewResult !=null && lblHideResult!=null )
            {
                pollPreviewResultButton.value = lblHideResult;
            }
        }
        
    }
    
}

function OnPollFormSubmit()
{
    var el = document.getElementById('poll_email');
    if (el != null)
    {
        if (IsValidEmail(el.value))
        {
            document.mainform.submit();
        }
         else
        {
           el.style.borderColor= "red";
           el.style.borderWidth = "2px";
           el.style.borderStyle = "solid";           
        }
    }   
}

var oldImageWindow;
function OpenWindow(ttl, pUrl, w, h)
{
    w+=50;
    h+=96;
 	var l= (window.screen.width - w)/2; //getWindowPosition("width")-(w/2);//
	var t= (window.screen.height - h)/2;//getWindowPosition("height")-(h/2);//
		
	if (oldImageWindow !=null)
	{
	    if(false == oldImageWindow.closed) 
        {
           oldImageWindow.close ();
        }
	}
	var win = window.open(pUrl, 'ViewImageWindow', 'width='+w+',height='+h+',left='+l+',top='+t+',resizable=yes');	
	if (win !=null)
	{	
	    win.resizeTo(w, h);    
	    try
	    {
	     if (win.document)
	     {
	        win.document.title = ttl;
	     }
	    }
	    catch(e){}
	    
	    if (window.focus) 
	    {
	        win.focus();	        
	    }
	}
	oldImageWindow = win;
}