﻿window.onload = function()
{
	var allTextAreas = document.getElementsByTagName("textarea");
    for (var i=0; i < allTextAreas.length; i++)
	{
       	var oFCKeditor = new FCKeditor( allTextAreas[i].name ) ;
        oFCKeditor.BasePath = "js/fckeditor/" ;
		oFCKeditor.ToolbarSet = "pnsa";
    	oFCKeditor.ReplaceTextarea() ;
    }
}

$(document).ready(function(){

	$('a[rel=external]').click(function(){
		window.open(this.href);
		
		return false;
	});
	
    $('form').submit( function( event )
    {
        for(var i=1; i <= 7; i++ )
            FCKeditorAPI.GetInstance('data[Vote][comment' + i + ']').UpdateLinkedField();        
    });

	$("#VoteAddForm").validate({
	
		rules: {
			'data[Vote][vote1]': {
				required: true,
				minlength: 1,
				number: true,
				min: 0,
				max: 100
			},
			'data[Vote][vote2]': {
				required: true,
				minlength: 1,
				number: true,
				min: 0,
				max: 100
			},
			'data[Vote][vote3]': {
				required: true,
				minlength: 1,
				number: true,
				min: 0,
				max: 100
			},
			'data[Vote][vote4]': {
				required: true,
				minlength: 1,
				number: true,
				min: 0,
				max: 100
			},
			'data[Vote][vote5]': {
				required: true,
				minlength: 1,
				number: true,
				min: 0,
				max: 100
			},
			'data[Vote][vote6]': {
				required: true,
				minlength: 1,
				number: true,
				min: 0,
				max: 100
			},
			'data[Vote][vote7]': {
				required: true,
				minlength: 1,
				number: true,
				min: 0,
				max: 100
			},
            'data[Vote][comment1]': {
				required: true,
				minlength: 1				
			},
            'data[Vote][comment2]': {
				required: true,
				minlength: 1
			},
            'data[Vote][comment3]': {
				required: true,
				minlength: 1
			},
            'data[Vote][comment4]': {
				required: true,
				minlength: 1
			},
            'data[Vote][comment5]': {
				required: true,
				minlength: 1
			},
            'data[Vote][comment6]': {
				required: true,
				minlength: 1
			},
            'data[Vote][comment7]': {
				required: true,
				minlength: 1
			},            
		},
		messages: {
			'data[Vote][vote1]': {
				required: "Wypełnij pole",
				minlength: "Wypełnij pole",
				number: "Wprowadź liczbę",
				min: "Minimalna 0",
				max: "Maksymalna 100"
			},
			'data[Vote][vote2]': {
				required: "Wypełnij pole",
				minlength: "Wypełnij pole",
				number: "Wprowadź liczbę",
				min: "Minimalna 0",
				max: "Maksymalna 100"
			},
			'data[Vote][vote3]': {
				required: "Wypełnij pole",
				minlength: "Wypełnij pole",
				number: "Wprowadź liczbę",
				min: "Minimalna 0",
				max: "Maksymalna 100"
			},
			'data[Vote][vote4]': {
				required: "Wypełnij pole",
				minlength: "Wypełnij pole",
				number: "Wprowadź liczbę",
				min: "Minimalna 0",
				max: "Maksymalna 100"
			},
			'data[Vote][vote5]': {
				required: "Wypełnij pole",
				minlength: "Wypełnij pole",
				number: "Wprowadź liczbę",
				min: "Minimalna 0",
				max: "Maksymalna 100"
			},
			'data[Vote][vote6]': {
				required: "Wypełnij pole",
				minlength: "Wypełnij pole",
				number: "Wprowadź liczbę",
				min: "Minimalna 0",
				max: "Maksymalna 100"
			},
			'data[Vote][vote7]': {
				required: "Wypełnij pole",
				minlength: "Wypełnij pole",
				number: "Wprowadź liczbę",
				min: "Minimalna 0",
				max: "Maksymalna 100"
			},
            'data[Vote][comment1]': {
				required: "Wypełnij pole",
				minlength: "Wypełnij pole"
			},
            'data[Vote][comment2]': {
				required: "Wypełnij pole",
				minlength: "Wypełnij pole"
			},
            'data[Vote][comment3]': {
				required: "Wypełnij pole",
				minlength: "Wypełnij pole"
			},
            'data[Vote][comment4]': {
				required: "Wypełnij pole",
				minlength: "Wypełnij pole"
			},
            'data[Vote][comment5]': {
				required: "Wypełnij pole",
				minlength: "Wypełnij pole"
			},
            'data[Vote][comment6]': {
				required: "Wypełnij pole",
				minlength: "Wypełnij pole"
			},
            'data[Vote][comment7]': {
				required: "Wypełnij pole",
				minlength: "Wypełnij pole"
			},            
		}

	
	});
	
	
	});
