(function($){

	
	$.fn.kmhBuilder = function(options){

		
		var opts = $.fn.extend({}, $.fn.kmhBuilder.defaults, options);
		var count = 1;
		
		return this.each(function(){
			
			var $this = $(this);
			
			if(location.hash){
				var contentHash = location.hash.substring(1,location.hash.length);
				var hashArr = contentHash.split("_");
				var innerContent = "";

				if(hashArr.length > 1){
					innerContent = hashArr[1];
					
					$.fn.kmhBuilder.showContent(hashArr[0],innerContent,opts);
				}else{
					$.fn.kmhBuilder.showContent(contentHash,innerContent,opts);
				}
				
			}//if location hash
			
			
			/*
			 * Enable main navigation
			 */
			$("#mainNav a").click(function(){
				$link = $(this);
				var href = $link.attr("href").substring(1);
				$.fn.kmhBuilder.showContent(href,"",opts);
			});
				  	
		});//each
	
		};//kmhBuilder
		
		
		$.fn.kmhBuilder.showContent = function(content,contentInner,opts){
			
			
			if($("#" + content + "Block").length && !$("#" + content + "Block").is(":visible")){
				//alert($("#" + content + "Block").is(":visible"));
				var $contentBlock = $("#" + content + "Block"); 
				
				$(".hideContent").hide();
				
				if($(".contentBlock:visible").length){
					
					//alert($(".contentBlock:visible").find(".hideContent:visible").attr("class"));
					$(".contentBlock:visible").fadeOut(opts.fadeOut,function(){
						$contentBlock.fadeIn(opts.fadeIn);
					});
					
				}else{
					$contentBlock.fadeIn(opts.fadeIn);
				}//else
				
				switch(content){
					case "portfolio": $.fn.kmhBuilder.activatePortfolio(content,contentInner,opts);break;
					case "practice": $.fn.kmhBuilder.activatePractice(content,contentInner,opts); $.fn.kmhBuilder.loadRandom(); break;
					case "noticeboard":$.fn.kmhBuilder.activateNoticeboard(content,contentInner,opts); $.fn.kmhBuilder.loadRandom();break;
					case "printroom": $.fn.kmhBuilder.activatePrintroom(content,contentInner,opts); $.fn.kmhBuilder.loadRandom();break;
					case "jobs": $.fn.kmhBuilder.activateJobs(content,contentInner,opts); $.fn.kmhBuilder.loadRandom();break;
					case "contact": $.fn.kmhBuilder.loadRandom();break;
				
				}//switch

				Cufon.replace(".fontReplace");
				if($.browser.msie && $.browser.version=="6.0")
				{
					DD_belatedPNG.fix("#mainNav, .contentWrapper, .contentBlock, #portfolioBlock, #controls-wrapper");
				}	
			}//if element exists			
		};
		
		$.fn.kmhBuilder.loadRandom = function(){
			if(!$("#bgstretcher").hasClass("random")){
				$("#bgstretcher").remove();
				$(".addPrint").hide(400);
				$(".projectInfo").hide(400);
				$("#navigation").hide(400);
				$.getJSON("cmsignition/galleryImagesHome.php",function(json){
					$(document).bgStretcher({
						images:  json,
						nextSlideDelay: 8000,
						imageWidth: 600,				
						imageHeight:378 				
					});
					$("#bgstretcher").addClass("random");	
				});
						
			}//if
			
		};
		
		$.fn.kmhBuilder.activatePrintroom = function(content,contentInner,opts){
			var $contentBlock = $("#"+ content + "Block #printroomInner");
			$.get("cmsignition/sitePrintRoom.php",function(response){
				$.get("cmsignition/sitePrintRoom.php",function(response){
					if(!$contentBlock.hasClass("jspScrollable")){
						$contentBlock.html(response);
						loadScroller("#"+ content + "Block #printroomInner #content_print");
						
					}else{
						$contentBlock.find(".jspPane").html(response);
						var api = $contentBlock.data("jsp");
						api.reinitialise();
					}
				
				});
			});
				
		};
		
		
	
		
		$.fn.kmhBuilder.activatePortfolio = function(content,contentInner,opts){
			var $contentBlock = $("#"+ content + "Block #projectsBlock");
			
		   $.get("cmsignition/siteProjects.php",function(response){
			   $contentBlock.html(response);
			   $("#projectTable li a").hover(function(){
				   var $hoverLink = $(this);
				   var classArr = $hoverLink.attr("class").split(" ");
				   var hoverParent = $hoverLink.parents("ul").attr("id");
				   if($hoverLink.hasClass("clientLink")){
					   $("#projectTable ul li a").not($hoverLink).each(function(){
						 // alert($(this).attr("class") + " >> "+ $(this).closest("ul").attr("id") + " >> " + jQuery.inArray($(this).attr("class"),classArr)); 
						  if(jQuery.inArray($(this).attr("class"),classArr) == -1 ){
							  $(this).addClass("invis");
						  } 
						  
					   });
					  
					  
				   }//if clientLink
				   else{
					   var foundArr = new Array();
					  // alert("#clientList a[class~='"+classArr[0]+"']");
					  $("#clientList a[class~='"+classArr[0]+"']").each(function(){
						 
						  var $clientLink = $(this);
						  var foundCategory = 0;
						  //alert($clientLink.html() + " >> " + classArr[0]);
						 
						  var classArr2 = $clientLink.attr("class").split(" ");
						  $("#projectTable ul li a").not("a.clientLink").each(function(){
							  	
							  	  var thisClass = $(this).attr("class");
							  	  if($(this).hasClass("invis")){
							  		  var thisArr = thisClass.split(" ");
							  		  thisClass= thisArr[0];
							  	  }
								//  alert(thisClass + " >> "+ classArr2.toSource() + " >> " + jQuery.inArray(thisClass,classArr2)); 
								  if(jQuery.inArray(thisClass,classArr2) == -1  ){
									 
									  if(jQuery.inArray(thisClass,foundArr) == -1){
										  $(this).addClass("invis");
									  }else{
										  
										//  $(this).removeClass("invis");
									  }
									  
								  }else{
									  //alert("else >> " + thisClass);
									  //alert(hoverParent);
									/*  if(hoverParent == "categoryList" || hoverParent == "valueList" ||  hoverParent == "scopeList" ||  hoverParent == "yearList" ||  hoverParent == "locationList"){
										 	if( $hoverLink.attr("class")  == thisClass){
										 			 //alert("if categoryList >> " + foundCategory + " >> " + $hoverLink.attr("class") + " >> " + thisClass);
										 			foundArr.push($(this).attr("class"));
													  $(this).removeClass("invis");
													  foundCategory++;
										 		}//if
										 		else{
										 			$(this).addClass("invis");
										 			
										 		}
										 									  
									  }else{*/
										  foundArr.push($(this).attr("class"));
										  $(this).removeClass("invis");
									 // }
									  
									//  alert("else found: " + $(this).attr("class"));
								  }
								  
							   });
						
					  });
					  $("#clientList a[class~='"+classArr[0]+"']").removeClass("invis");
					  $("#clientList a").not("a[class~='"+classArr[0]+"']").addClass("invis");
					  
					 // alert(hoverParent + " >> " + $hoverLink.attr("class"));
					// alert($("." + hoverParent+ " a").not("." + $hoverLink.attr("class")).length);
					 $("#" + hoverParent+ " a").not("." + $hoverLink.attr("class")).addClass("invis");
				   }
				
				   
			   },function(){
				   /*$("#projectTable .invis").animate({
					   color: "#fff"
				   },400);
				  */
				   $("#projectTable a").removeClass("invis");
				   
				   
			   });
			});
		   
		   $("#sortBlock a").click(function(){
			   $("#sortBlock").hide(400,function(){
				   $("#portfolioBlock").show(400);
				   
			   });
			   
			   
		   });
		   
		   $("#projectBlock1Small a").click(function(){
			   $("#projectBlock1Small").hide(400,function(){
				   $("#sortBlock").hide(400);
				   $("#portfolioBlock").show(400);
				   $("#projectBlock1").show(400);
				   
			   });
			   
			   
		   });
		   
		   $("#projectBlock2Small a").click(function(){
			   $("#projectBlock2Small").hide(400,function(){
				   $("#projectBlock2").show(400);
				   
			   });
			   
			   
		   });
			
		   $("#refreshLink").click(function(){
			   
			   $("#projectTable ul li a").show();
			   $("#sortBlock").hide(400);
			   $("#extraBlock").hide(400);
			   $("#projectBlock1").hide();
			   $("#projectBlock2").hide();
			   $("#sortBlock").hide();
			   
			   
		   });
		   
		};
		
		
		$.fn.kmhBuilder.toggleProjects = function(projectClass){
			
		//	$("#projectTable ul li").children("a" + projectClass).removeClass("invis");
			
			/*
			//  alert("toggle: " + projectClass);
			 var speed = 400;
			  var $wall = $("#projectTable");
			  if(projectClass=='.all') {
			    // show all hidden boxes
			    $wall.children('.invis')
			      .toggleClass('invis').fadeIn(speed);
			  } else {  
				 alert(projectClass + " >> "+ $("#projectTable a").not(projectClass).attr("class"));
			    // hide visible boxes
				if(!$("#projectTable a").hasClass(projectClass) ){ 
			    $("#projectTable a").not(projectClass).not('.invis')
			      .toggleClass('invis').fadeOut(speed);
			    // show hidden boxes
			    $("#projectTable a"+ projectClass+'.invis')
			      .toggleClass('invis').fadeIn(speed);
			    
				}//if 
				
			  }//else
			*/
		};
		
		$.fn.kmhBuilder.activatePractice = function(content,contentInner,opts){
			
			//alert("content inner:" + contentInner);
			if(contentInner != ""){
				$.fn.kmhBuilder.showInnerContent(contentInner,opts);
			}else{
				$.fn.kmhBuilder.showInnerContent("company",opts);
			}
			$("#" + content + "Block .subNav a").click(function(){
				var href = $(this).attr("href");
				var hrefArr = href.split("_");
				$.fn.kmhBuilder.showInnerContent(hrefArr[1],opts);
			});
			
		};
		
		
	$.fn.kmhBuilder.activateJobs = function(content,contentInner,opts){
			
			//alert("content inner:" + contentInner);
			if(contentInner == ""){
				contentInner = "job";
			}
			
			switch(contentInner){
		
			case "job" :$.get("cmsignition/siteJobs.php",function(response){
				if(!$("#content_" + contentInner).hasClass("jspScrollable")){
					$("#content_" + contentInner).html(response);
				}else{
					$("#content_" + contentInner).find(".jspPane").html(response);
					
				}
				//alert(response);
				Cufon.replace(".fontReplace");
				Shadowbox.setup("a[rel='shadowbox']");
				$.fn.kmhBuilder.showInnerContent(contentInner,opts);
				
			});
			break; 
			case "success" :
						$.fn.kmhBuilder.showInnerContent(contentInner,opts);
						break; 
			}//switch		
			
				
		
			
		};
		
		$.fn.kmhBuilder.activateNoticeboard = function(content,contentInner,opts){
			
			//alert("content inner:" + contentInner);
			if(contentInner == ""){
				contentInner = "work";
			}
			
			switch(contentInner){
			case "work": 
				$.get("cmsignition/siteNewsArticles.php",{category: "Work in Progress"},function(response){
					if(!$("#content_" + contentInner).hasClass("jspScrollable")){
						$("#content_" + contentInner).html(response);
					}else{
						$("#content_" + contentInner).find(".jspPane").html(response);
						
					}
					Cufon.replace(".fontReplace");
					Shadowbox.setup("a[rel='shadowbox']");
					
					$.fn.kmhBuilder.showInnerContent(contentInner,opts);
					
				});
				break;
			case "fun" :$.get("cmsignition/galleryImages.php",{galleryID: 4},function(response){
				if(!$("#content_" + contentInner).hasClass("jspScrollable")){
						$("#content_" + contentInner).html(response);
				}else{
					$("#content_" + contentInner).find(".jspPane").html(response);
					
				}
						//alert(response);
						Cufon.replace(".fontReplace");
						Shadowbox.setup("a[rel='shadowbox']");
						$.fn.kmhBuilder.showInnerContent(contentInner,opts);
						
						});
						break; 
			}//switch		
			
			
			
			$("#" + content + "Block .subNav a").click(function(){
				var href = $(this).attr("href");
				var hrefArr = href.split("_");
				
				switch(hrefArr[1]){
				case "work": 
					
					$.get("cmsignition/siteNewsArticles.php",{category: "Work in Progress"},function(response){
						if(!$("#content_" + hrefArr[1]).hasClass("jspScrollable")){
							$("#content_" + hrefArr[1]).html(response);
						}else{
							$("#content_" + hrefArr[1]).find(".jspPane").html(response);
							
						}
						
						Cufon.replace(".fontReplace");
						Shadowbox.setup("a[rel='shadowbox']");
						
						$.fn.kmhBuilder.showInnerContent(hrefArr[1],opts);
						
					});
					break;
				case "fun" :$.get("cmsignition/galleryImages.php",{galleryID: 4},function(response){
					
							if(!$("#content_" + hrefArr[1]).hasClass("jspScrollable")){
								$("#content_" + hrefArr[1]).html(response);
							}else{
								$("#content_" + hrefArr[1]).find(".jspPane").html(response);
								
							}
							
						//	alert(response);
							Cufon.replace(".fontReplace");
							Shadowbox.setup("a[rel='shadowbox']",{gallery: "fun"});
							$.fn.kmhBuilder.showInnerContent(hrefArr[1],opts);
							
							});
							break; 
				}//switch		
				
				
			});
			
		};
		
		$.fn.kmhBuilder.showInnerContent = function(content,opts){
			
			if($("#content_" + content ).length && !$("#content_" + content).is(":visible") ){
				//alert("else:" + $("#content_" + content).is(":visible") + " : " + content);
				
				var $contentBlock = $("#content_" + content ); 
				
				if($contentBlock.siblings(".hideContent:visible").length){
					
					$contentBlock.siblings(".hideContent:visible").fadeOut(opts.fadeOut,function(){
										
					$contentBlock.fadeIn(opts.fadeIn, function(){
						
					if( (!$("#content_" + content).hasClass("jspScrollable") && $("#content_" + content).hasClass("scroll-pane")) && !$("#content_" + content).find(".jspPane").length ){
							
							loadScroller("#content_" + content);
						}
						
						
						
					});
					
					
						
						
					});
					
				}else{
				//	alert("Should fade in");
				
				
					$contentBlock.fadeIn(opts.fadeIn, function(){
						if( (!$("#content_" + content).hasClass("jspScrollable") && $("#content_" + content).hasClass("scroll-pane")) &&  !$("#content_" + content).find(".jspPane").length ){
							Cufon.replace(".fontReplace");
							loadScroller("#content_" + content);
						}
						
						});
						
				}//else
				
			
				
			}//if element exists			
			
		};
		
  $.fn.kmhBuilder.defaults = {
		  fadeIn: 500,
		  fadeOut: 200,
		  scrollPane: ""
  };//defaults
  
})(jQuery);



function loadScroller(element){

	$(element).jScrollPane({
		showArrows: true,
		verticalArrowPositions: 'before',
		horizontalArrowPositions: 'before'		

 	});
	
}
	

function viewGallery(galleryID){
	var $contentBlock = $("#galleryLink_" + galleryID).parents("div.hideContent");
	$.get("cmsignition/galleryImages.php", {galleryID: galleryID},function(response){
		$contentBlock.fadeOut(200,function(){
			/*if(!$contentBlock.hasClass("jspScrollable")){
	    			$contentBlock.html(response);
	    		}else{
	    			$contentBlock.find(".jspPane").html(response);
	    		}
			 */
			
			
			if($contentBlock.children("div:eq(0)").hasClass("jspContainer") ){
				
				$contentBlock.find(".jspPane").html(response);
				
				
			}else{
				$contentBlock.html(response);
			}
			
			$contentBlock.fadeIn(500,function(){
				
    				var api = $contentBlock.data("jsp");
	    			api.reinitialise();
    			
				Shadowbox.setup("a[rel='shadowbox']");
				
			});
			
		});
		
		
	});
	
}//function

function viewJob(jobID){
	    var $contentBlock = $("#jobLink_" + jobID).parents("div.hideContent");
	    $.get("cmsignition/siteJob.php", {jobID: jobID},function(response){
	    	$contentBlock.fadeOut(200,function(){
	    		/*if(!$contentBlock.hasClass("jspScrollable")){
	    			$contentBlock.html(response);
	    		}else{
	    			$contentBlock.find(".jspPane").html(response);
	    		}
	    		*/
	    				
	    		if($contentBlock.children("div:eq(0)").hasClass("jspContainer") ){
					
					$contentBlock.find(".jspPane").html(response);
					
					
				}else{
					$contentBlock.html(response);
				}
	    		
	    		$contentBlock.fadeIn(500,function(){
	    			
	    			if($contentBlock.hasClass("jspScrollable")){
	    				var api = $contentBlock.data("jsp");
		    			api.reinitialise();
	    			}else{
	    				
	    				loadScroller("#content_job");
	    				
	    			}
	    			
	    			Cufon.replace(".fontReplace");
	    			
	    		});
	    		//Shadowbox.setup("a[rel='shadowbox']");
	    	});
	    	
	    
	    });
	    
}//function

function loadGalleries(galleryID,category){
	var $contentBlock = $("#galleriesLink_" + galleryID).parents("div.hideContent");
	/*$.get("cmsignition/galleriesImages.php", {galleryID: 4},function(response){
    	$contentBlock.fadeOut(200,function(){
    		if(!$contentBlock.hasClass("jspScrollable")){
    			$contentBlock.html(response);
    		}else{
    			$contentBlock.find(".jspPane").html(response);
    		}
    		$contentBlock.fadeIn(500),function(){
    			var api = $contentBlock.data("jsp");
    			api.reinitialise();
    			
    		};
    		Shadowbox.setup("a[rel='shadowbox']");
    	});
    	
	});
	*/
		viewGallery(4);
    	
}

function loadProject(type,value){
	
	$("#projectTable ul li a.invis").hide(200);
	
	$.get("cmsignition/siteProjectsAjax.php?"+type+ "=" + value,function(response){
		$("#sortBlock").hide(400);
		$("#extraBlock").hide(400);
		$("#projectBlock1Small").hide();
		$("#projectBlock2Small").hide();
		$("#sortBlock").hide();
		   
		$("#projectBlock2").fadeOut(400,function(){
			$("#projectBlock2 .projectInner").html("");
			
		});
		$("#projectBlock1 .projectInner").html(response);
		//alert($("#projectBlock1 .items div.projectItem").size());
		if( $("#projectBlock1 .items div.projectItem").size() > 6 ){
			//$("#projectScroller").scrollable({circular: true,speed:800});
		  $("#projectScroller").scrollable({size:1,speed:800}).navigator(".navi");
		  var api = $("#projectScroller").data("scrollable");
		  $("#projectScroller").siblings(".next").click(function(){
				if(api.getIndex()  == (api.getSize() -1)){
					
					api.seekTo(0,400);
				}else{
					api.next(400);
					
				}
				
				
			});
			
			$("#projectScroller").siblings(".prev").click(function(){
				api.prev(400);
				
			});
			
		}//if
		
		 $("#projectBlock1Small").hide(300);
		 $("#projectBlock1").fadeIn(400);
		 
		 
		   $("#extraBlock").fadeIn(800,function(){
			  
			  // $("#projectBlock2").fadeIn(600);
		   });
	});
	
}//function

function loadProjectInner(projectID){
	//alert(projectID);
	$.getJSON("cmsignition/siteProjectAjax.php",{projectID: projectID},function(json){
		
		$("#projectBlock2 .projectInner").html(json.value);
		$("#projectBlock2 .projectTitleBlock").html(json.title);
		$("#projectBlock2Small a").text("< " + json.title);
		
		if( $("#projectBlock2 .items div.projectItem").size() >6 ){
			$("#galleryScroller").scrollable({size:1,speed:800,next: null, prev:null}).navigator(".navi");
			var api = $("#galleryScroller").data("scrollable");
			$("#galleryScroller").siblings(".next").click(function(){
				if(api.getIndex()  == (api.getSize() -1)){
					
					api.seekTo(0,400);
				}else{
					api.next(400);
					
				}
				
				
			});
			
			$("#galleryScroller").siblings(".prev").click(function(){
				api.prev(400);
				
			});
		}
		 $("#projectBlock2Small").hide(300);
		$("#projectBlock2").show(400);
		
		
		$(".projectInfo").show(400);
		  
		//$(".projectInfo").tooltip({ effect: 'slide', relative: true});
		/*
		if($(".qtip").length){
			
			$(".tooltip").replaceWith(json.info);
			$(".projectInfo").tooltip({ effect: 'slide', relative: true});
		}else{
			
			$(".projectInfo").after(json.info);	
			//var $tooltip = $(json.info);
			//$(".projectInfo").tooltip({ effect: 'slide', relative: true});
			//var api = $(".projectInfo").data("tooltip");
			
		
			//$('.projectInfo').bubbletip($tooltip,{deltaDirection: 'up',offsetLeft: 40});
		}*/
		
		$(".qtip").remove();
		//alert("should add qtip");
		$('.projectInfo').qtip({
			content: json.info,
			   
			   style: { 
				   	  background: "#e7e5e5",
				      width: 450,
				      padding: 10,
				      color: 'black',
				      textAlign: 'center',
				      tip: 'bottomMiddle',
				      name: 'light' // Inherit the rest of the attributes from the preset dark style
			   },
			   position: {
				      corner: {
				         target: 'topMiddle',
				         tooltip: 'bottomMiddle',
				         adjust: {
				        	 screen:true
				         }
				      }
				   },
			  show: { effect: { type: 'fade', length: 600 }, when:{event: 'click'} }
			  
			});
		
	});
}//function
	

function loadGallery(projectID,imageID){
	
$.getJSON("cmsignition/siteProjectImagesAjax.php",{projectID: projectID, imageID: imageID},function(json){
	
	$.fn.supersized.options = {  
			startwidth: 640,  
			startheight: 480,
			vertical_center: 1,
			slideshow: 0,
			navigation: 1,
			thumbnail_navigation: 1,
			transition: 1, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
			pause_hover: 0,
			slide_counter: 1,
			slide_captions: 1,
			slide_interval: 10000,
			slides : 
				json
			
		};
	
		$("#portfolioBlock").fadeOut(400,function(){
			$("#sortBlock").show(400);
		});
		//$("#extraBlock").fadeOut(400);
		$("#projectBlock1").hide(400,function(){
			$("#projectBlock1Small").show(400);
		});
		$("#projectBlock2").hide(400,function(){
			$("#projectBlock2Small").show(400);
		});
		
		$(".addPrint").show(300);
		$("#bgstretcher").remove();

		$(document).bgStretcher({
			images:  json,
			nextSlideDelay: 8000,
			slideShow: false
		});
		
       // $("#supersized").show();
        $("#controls-wrapper").show();
        $("#navigation").show(300);
			    	
    	$(".addPrint a").unbind("click");
    	$(".addPrint a").click(function(){
    		
    		var imgArr = $("li.bgs-current img").attr("id").split("_");
    		
    		$.getJSON("cmsignition/addPrintRoom.php",{projectID: projectID, galleryImageID : imgArr[1]},function(json){
    			//alert(json.status);
    			if(json.status == "success"){
    				$(".qtip").remove();
    				$('.addPrint').qtip({
  					   content: "Image added",
  					   style: { 
  						   	  background: "#e7e5e5",
  						      width: 300,
  						      padding: 10,
  						      color: 'black',
  						      textAlign: 'center',
  						      tip: 'bottomLeft',
  						      name: 'light' // Inherit the rest of the attributes from the preset dark style
  					   },
  					   position: {
  						      corner: {
  						         target: 'topRight',
  						         tooltip: 'bottomMiddle',
  						         adjust: {
  						        	 screen:true
  						         }
  						      }
  						   },
  					  show: { effect: { type: 'fade', length: 600 }, ready: true, when: false }
  					});
     				
    			}else{
    				$('.addPrint').qtip({
 					   content: "Image already added",
 					   style: { 
 						   	  background: "#e7e5e5",
 						      width: 300,
 						      padding: 10,
 						      color: 'black',
 						      textAlign: 'center',
 						      tip: 'bottomLeft',
 						      name: 'light' // Inherit the rest of the attributes from the preset dark style
 					   },
 					   position: {
 						      corner: {
 						         target: 'topRight',
 						         tooltip: 'bottomMiddle',
 						         adjust: {
 						        	 screen:true
 						         }
 						      }
 						   },
 					  show: { effect: { type: 'fade', length: 600 }, ready: true, when: false }
 					});
    				
    			
    			}
    			
    		});
    		
    	});
		  
		  
		
	});

	
	
}


function resetPrintRoom(){
	$.get("cmsignition/sitePrintRoom.php",{value: "reset"},function(response){
		$("#printroomInner").html(response);
		
	});
	
}//function

function loadRecruitment(){
	$.get("cmsignition/siteJobs.php",function(response){


		$("#content_job").fadeOut(400,function(){
			
			//alert(response);
			Cufon.replace(".fontReplace");
			//Shadowbox.setup("a[rel='shadowbox']");

			if(!$("#content_job").hasClass("jspScrollable")){
				$("#content_job").html(response);
			}else{
				$("#content_job").find(".jspPane").html(response);
				
			}
			
				
			$("#content_job").fadeIn(800, function(){
				var api = $("#content_job").data("jsp");
				api.reinitialise();
				
			});
			
		});
		
		
	});
}

function deleteImage(imageID){
	$.get("cmsignition/deleteimage.php",{galleryImageID: imageID},function(){
		
		if(!$("#printImage_" + imageID).siblings("printImage").length){
		$("#printImage_" + imageID).parent(".printRow").remove();		
		}else{
			$("#printImage_" + imageID).remove();	
			
		}
	
		if( !$(".printRow").length ){
			$.get("cmsignition/sitePrintRoom.php",function(response){
				$("#printroomInner").html(response);
				
			});
		}
	});
}
