/**
 * @author ADMIN
 */
		$(document).ready(function () {
    		$("#question_form").submit(function() {
		    	if ($.trim($("#username").val()) == "" || $("#username").val() == "Your Name..." ||
					$.trim($("#useremail").val()) == "" || $("#useremail").val() == "Your email address..." ||
					$.trim($("#useremailrepeat").val()) == "" || $("#useremailrepaet").val() == "Repeat email address..." ||
					$.trim($("#question_area").val()) == "" || $("#question_area").val() == "Submit Enquiry..." 
				) {
					$("#res_mes").html("Please fill<br/>all fields.");
					$("#res_mes").css("color","#ffffff");
					$("#res_mes").css("background-color","#ff0000");
		        	return false;
		      	}
		    	if ($.trim($("#useremail").val()) != $.trim($("#useremailrepeat").val()) ) {
					$("#res_mes").html("Your emails<br/>not equal.");
					$("#res_mes").css("color","#ffffff");
					$("#res_mes").css("background-color","#ff0000");
		        	return false;
		    	}
		      	return true;
		    });
			
			$("#username").focus(function() {
				if($("#username").val() == "Your Name...") {
					$("#username").val("");
				}
			});

			$("#username").blur(function() {
				if($.trim($("#username").val()) == "") {
					$("#username").val("Your Name...");
				}
			});


			$("#useremail").focus(function() {
				if($("#useremail").val() == "Your email address...") {
					$("#useremail").val("");
				}
			});

			$("#useremail").blur(function() {
				if($.trim($("#useremail").val()) == "") {
					$("#useremail").val("Your email address...");
				}
			});

			$("#useremailrepeat").focus(function() {
				if($("#useremailrepeat").val() == "Repeat email address...") {
					$("#useremailrepeat").val("");
				}
			});

			$("#useremailrepeat").blur(function() {
				if($.trim($("#useremailrepeat").val()) == "") {
					$("#useremailrepeat").val("Repeat email address...");
				}
			});
			
			
			$("#question_area").focus(function() {
				if($("#question_area").val() == "Submit Enquiry...") {
					$("#question_area").val("");
				}
			});

			$("#question_area").blur(function() {
				if($.trim($("#question_area").val()) == "") {
					$("#question_area").val("Submit Enquiry...");
				}
			});
			
			//"Our Clients" page pop-up
			$("#our_clients div.short_logo a, #our_clients a.moreinfolink").bind(
				'click',
				function (){
					zparent = $(this).parent().parent();
					zlogo = $(zparent).children("div.short_logo").children("a").html();
					
					$(zparent).children("div.moreinfo").children("div.moreinfo_logo").html(zlogo);
					$(".moreinfo_logo img").removeClass("aligncenter");
					
					$.prompt($(zparent).children(".moreinfo").html(),
							{buttons:{},opacity:0.7, top: 200, overlayspeed: 300, promptspeed: 400 }
					);
				}
			);
			
			//fade "say about us" section on "Our Clients" page	
			//start	
			function headerSwitch () {
				if ($("#say_about_us>li:visible").next().length>0) {
					$("#say_about_us>li:visible").next().addClass("toShow");
				} else {
					$("#say_about_us>li:first").addClass("toShow");
				}
				function show () {
					$(".toShow").fadeIn(2500).removeClass("toShow");
				}
				$("#say_about_us>li:visible").fadeOut(2500,show());
				setTimeout(headerSwitch, 14000);
			}
			if ($("#say_about_us>li:visible").length>0) {
				setTimeout(headerSwitch, 8000);
			}
			//end style="display:none"	
	
			//pop-up for "Meet the team" page
			$(".team a").bind(
				'click',
				function (){
					current = $(this).parent().parent().clone(); //clone <div class="team">
					var work = "";
					current.find("cufontext").each(function () {
						work = work + $(this).html();
					});
					$(current).children(".hidden").removeClass("hidden");
					$(current).children("img").remove();
					$(current).children("a").children(".work").children("cufon").remove();
					$(current).children("a").children(".work").text(work);
					$.prompt($(current).html(),{buttons:{},opacity:0.7, top: 100, prefix: 'jqiteam' });
				//	Cufon.DOM.ready(function() {Cufon.replace('span.work');});
				}
			);	
			
			//pop-up for "training courses" page
			$(".training-desc a.read_more_popup").bind(
				'click',
				function (){
					h3a = $(this).parent().parent().parent().find("h3").clone();
					current = $(this).parent().parent().clone();
					$(current).prepend(h3a);
					$(current).children(".hidden").css("display", "block");
					$(current).children(".hidden").removeClass("hidden");
					
					$(current).find("a.read_more_popup").remove();
					$(current).find("a.download_full_pdf").remove();
					$(current).find("a.training-desc-back").remove();

					$.prompt($(current).html(),{buttons:{},opacity:0.7, top: 100, prefix: 'jqiteam' });


				}

			);
			
			//pop-up for "Services" page
			$(".services-list a.apopup").bind(
				'click',
				function (){
					
					current = $(this).parent().clone();
					$(current).children(".hidden").css("display", "block");
					$(current).children(".hidden").removeClass("hidden");
					
					$.prompt($(current).html(),
							{buttons:{},opacity:0.7, top: 200, prefix: 'jqiserv', overlayspeed: 200, promptspeed: 200 }
					);
				}
			);			
			
			$("div#services h2 a.apopup").bind(
				'click',
				function (){
					current = $(this).parent().clone();
					next = $(this).parent().next().clone();
					
					$(current).next(".hidden").css("display", "block");
					$(current).next(".hidden").removeClass("hidden");
					
					$.prompt($(current).html() + $(next).html(),
							{buttons:{},opacity:0.7, top: 200, prefix: 'jqiserv', overlayspeed: 200, promptspeed: 200 }
					);
				}
			);			
			
			
			
			//links creation for "Training Courses"
			if($("#post-training-courses").length>0){
				$(".training-days li").each(function(){
					zparent = $(this).parent().parent();
					ztext = $(zparent).children("h3").children("a").html();
					$(this).wrap("<a href='mailto:info@aversionrms.co.uk?subject="+ ztext +" Leeds "+$(this).html()+"'></a>");
				});
				
				
				$(".training_li h3 a.apopup").bind(
					'click',
					function (){
						current = $(this).parent().parent(); //li.training_li
						$(current).children("ul.training-days").fadeOut(500, zshow());
						$(current).children("p").fadeOut(500);
						function zshow () {
							if($(current).children(".training-desc-close").length == 0)
								$(current).append("<div class='training-desc-close ie6png'></div>");
							else
								$(current).children(".training-desc-close").fadeIn(3000);

							$(current).children(".training-desc-close").bind(
								'click',
								function (){
									current = $(this).parent(); //li.training_li
									$(current).children("ul.training-days").fadeIn(3000, zshow());
									$(current).children("p").fadeIn(3000);
									function zshow () {
										$(current).removeClass("training_li_desk");
										$(current).children("div.training-desc").addClass("hidden");
										$(current).children("div.training-desc").fadeOut(500);
										
										$(current).children(".training-desc-close").fadeOut(500);
									}
								}
							);
							
							$("a.training-desc-back").bind(
								'click',
								function (){
									current = $(this).parent().parent().parent(); //li.training_li
									$(current).children("ul.training-days").fadeIn(3000, zshow());
									$(current).children("p").fadeIn(3000);
									function zshow () {
										$(current).removeClass("training_li_desk");
										$(current).children("div.training-desc").addClass("hidden");
										$(current).children("div.training-desc").fadeOut(500);
										
										$(current).children(".training-desc-close").fadeOut(500);
									}
								}
							);
										
							$(current).addClass("training_li_desk");
							$(current).children("div.training-desc").removeClass("hidden");
							$(current).children("div.training-desc").fadeIn(3000);
						}
					}
				);

						
			} 
		});

