jQuery.extend({ 
 getURLParam: function(strParamName){
	  var strReturn = "";
	  var strHref = window.location.href;
	  var bFound=false;
	  var cmpstring = strParamName + "=";
	  var cmplen = cmpstring.length;

	  if ( strHref.indexOf("?") > -1 ){
	    var strQueryString = strHref.substr(strHref.indexOf("?")+1);
	    var aQueryString = strQueryString.split("&");
	    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
	      if (aQueryString[iParam].substr(0,cmplen)==cmpstring){
	        var aParam = aQueryString[iParam].split("=");
	        strReturn = aParam[1];
	        bFound=true;
	        break;
	      }
	      
	    }
	  }
	  if (bFound==false) return null;
	  return strReturn;
	}
});

jQuery.extend({ 
 	clientProjects: function(clientID){
	 	$.ajax({
			type: "GET", url: "xml/portfolio.xml", dataType: "xml", success: function(xml) {
				$(xml).find('client').each(function() {
					var clientName = $(this).attr("name");
					if(clientName==clientID){
						var client = $(this);
						$(client,xml).find('projet').each(function() {
							var project=$(this);
							var imageurl = $(project).find('image').text()
							var legendeurl = $(project).find('legend').text()
							var isfirstitem = $(project).attr("firstitem");
							if((typeof(isfirstitem) != "undefined")&&(isfirstitem==="true")){
								$('#col_main').append("<div class='first_item'><img src='"+imageurl+"' alt='"+legendeurl+"' /><p>"+legendeurl+"</p></div>");
							}else{
								$('#col_main').append("<div class='item'><img src='"+imageurl+"' alt='"+legendeurl+"' /><p>"+legendeurl+"</p></div>");
							}
						});								
					}
				});				
			 }
		});  
	}
})
jQuery.extend({ 
 	expertiseProjects: function(expertiseID){
	 	$.ajax({
			type: "GET", url: "xml/portfolio.xml", dataType: "xml", success: function(xml) {
				$(xml).find('projet').each(function() {
					var expertiseType = $(this).attr("expertise");
					if((typeof(expertiseType) != "undefined")&&(expertiseType==expertiseID)){
						var project=$(this);
						var imageurl = $(project).find('image').text()
						var legendeurl = $(project).find('legend').text()
						$('#col_main').append("<div class='item'><img src='"+imageurl+"' alt='"+legendeurl+"' /><p>"+legendeurl+"</p></div>");
					}
				});				
			 }
		});  
	}
})
jQuery.extend({ 
 	staffParse: function(idrequest){
		$('#col_main').append("<div id='stafflist'></div>");
	 	$.ajax({
			type: "GET", url: "xml/staff.xml", dataType: "xml", success: function(xml) {
				$(xml).find('person').each(function() {
					var personID = $(this).attr("id");
					if((typeof(personID) != "undefined")&&(personID==idrequest)){
						var person=$(this);
						var personName = $(person).find('name').text()
						var personFullName = $(person).find('fullname').text()
						var personPosition = $(person).find('position').text()
						var personTel = $(person).find('tel').text()
						var personEmail = $(person).find('email').text()
						$('#stafflist').append("<h2 class='nametitle'>"+personName+"</h2><ul><li class='pname'>"+personFullName+"</li><li class='pposition'>"+personPosition+"</li><li class='ptel'>"+personTel+"</li><li class='pemail'>"+personEmail+"</li></ul>");
					}
				});				
			 }
		});
	}
})

