jQuery.noConflict();
jQuery(document).ready(function() {

    //select all the a tag with name equal to modal
    jQuery('a[name=modal]').click(function(e) {
        //Cancel the link behavior
        e.preventDefault();

        //Get the A tag
        var id = jQuery(this).attr('href');

        //Get the screen height and width
        var maskHeight = jQuery(document).height();
        var maskWidth = jQuery(window).width();

        //Set heigth and width to mask to fill up the whole screen
        jQuery('#mask').css({
            'width':maskWidth,
            'height':maskHeight
        });

        //transition effect
        //jQuery('#mask').fadeIn(1000);
        jQuery('#mask').fadeTo("slow",0.75);

        //Get the window height and width
        var winH = jQuery(window).height();
        var winW = jQuery(window).width();

        //Set the popup window to center
        jQuery(id).css('top',  winH/2-jQuery(id).height()/2);
        jQuery(id).css('left', winW/2-jQuery(id).width()/2);

        //transition effect
        jQuery(id).fadeIn(2000);

    });

    //if close button is clicked
    jQuery('.window .close').click(function (e) {
        //Cancel the link behavior
        e.preventDefault();

        jQuery('#mask').hide();
        jQuery('.window').hide();
    });

    //if close button is clicked
    jQuery('.windowpdf .close').click(function (e) {
        //Cancel the link behavior
        e.preventDefault();

        jQuery('#mask').hide();
        jQuery('.windowpdf').hide();
    });

    //if mask is clicked
    jQuery('#mask').click(function () {
        jQuery(this).hide();
        jQuery('.windowpdf').hide();
    });

});



jQuery(document).ready(function(){
	/* The following code is executed once the DOM is loaded */

	/* This flag will prevent multiple comment submits: */
	var working = false;

	/* Listening for the submit event of the form: */
	jQuery('#abonareForm').submit(function(e){

 		e.preventDefault();
		if(working) return false;

		working = true;
		jQuery('#submit').val('Working..');
		jQuery('span.error').remove();
		
		jQuery.post('/2011toamna/process.php',jQuery(this).serialize(),function(msg){

			working = false;
			jQuery('#submit').val('Submit');
                        
			if(msg.status){
                            
                                //hide the form
                                //jQuery('.form').fadeOut('slow');
				
                                //show the success message
                                jQuery('.form').html(msg.html);
                                jQuery('.form').fadeIn('slow');
                                                                
			}else {

				/*
				/	If there were errors, loop through the
				/	msg.errors object and display them on the page
				/*/

				jQuery.each(msg.errors,function(k,v){                                    
					//jQuery('label[for='+k+']').append('<span class="error">'+v+'</span>');
                                        jQuery('input[name='+k+'_]').addClass('hightlight');
                                        jQuery('input[name='+k+'_]').val(v);
                                        
				});
			}
		},'json');

	});

});





/*
jQuery(document).ready(function() {

    //if submit button is clicked
    jQuery('#submit').click(function () {

        //Get the data from all the fields
        var name = jQuery('input[name=name]');
        var email = jQuery('input[name=email]');
        var website = jQuery('input[name=website]');
        var comment = jQuery('textarea[name=comment]');

        //Simple validation to make sure user entered something
        //If error found, add hightlight class to the text field
        if (name.val()=='') {
            name.addClass('hightlight');
            return false;
        } else name.removeClass('hightlight');

        if (email.val()=='') {
            email.addClass('hightlight');
            return false;
        } else email.removeClass('hightlight');

        if (comment.val()=='') {
            comment.addClass('hightlight');
            return false;
        } else comment.removeClass('hightlight');

        //organize the data properly
        var data = 'name=' + name.val() + '&email=' + email.val() + '&website='
        + website.val() + '&comment='  + encodeURIComponent(comment.val());

        //disabled all the text fields
        jQuery('.text').attr('disabled','true');

        //show the loading sign
        jQuery('.loading').show();

        //start the ajax
        $.ajax({
            //this is the php file that processes the data and send mail
            url: "process.php",

            //GET method is used
            type: "GET",

            //pass the data
            data: data,

            //Do not cache the page
            cache: false,

            //success
            success: function (html) {
                //if process.php returned 1/true (send mail success)
                if (html==1) {
                    //hide the form
                    jQuery('.form').fadeOut('slow');

                    //show the success message
                    jQuery('.done').fadeIn('slow');

                //if process.php returned 0/false (send mail failed)
                } else alert('Sorry, unexpected error. Please try again later.');
            }
        });

        //cancel the submit button default behaviours
        return false;
    });
}); */
