google.load("feeds", "1");
		
		
function feeds_initialize(count,max,url,type,titel,hoco,gotoURL) {
    //Algemeen
	
	var feed1 = new google.feeds.Feed(url);
    //var feed1 = new google.feeds.Feed("http://accsite4.roxen.ibridge.nl/feeds/ygn-acc.xml");
    //var feed1 = new google.feeds.Feed("http://dev.edit.zwart2.yacht.nl.rsg/content/carriere/vakgebieden/bouwkunde-civiel/job-feed-mwp-all.xml");
    feed1.setNumEntries(max);
    feed1.setResultFormat(google.feeds.Feed.MIXED_FORMAT);
    feed1.load(function(result) {
    
	var container = document.getElementById(type + "feedcp-" + count);
      var html = '<ul class="navigationList small">';
      if (!result.error) {
        if (result.feed.entries.length > 0) {
          for (var i = 0; i < result.feed.entries.length; i++) {
            var entry = result.feed.entries[i];
            // get title
            var entrytitle = entry.title;
  		      var entrytitlefull = entry.title;
            if (entrytitle.length > 70) {
              entrytitle = entrytitle.substr(0,70) + "...";
            }
            // calculate/format date
            var entrydate = new Date(entry.publishedDate);
            var current_day = entrydate.getDate();
            var current_month = entrydate.getMonth() + 1;
            var current_year = entrydate.getFullYear();
            if (current_day < 10) {current_day = "0" + current_day; }
            if (current_month < 10) {current_month = "0" + current_month; }
            var formatteddate = current_day + "-" + current_month + "-" + entrydate.getFullYear();
  		      var entrylink = entry.link;
            var entrylinkfixed = entrylink.replace("/vacatures/","/vacature/");
      		  // build link
      		  //alert(entrylinkfixed);
      		  if (hoco == 'content')
      			{
      			  		if(type == 'opdrachten'){
  							var ahref = "<li><a href='"
  							+ entrylink
  							+ "' target='_self' title='"
  							+ entrytitlefull
  							+ "' alt='"
  							+ entrytitlefull
  							+ "'>"
  							+ entrytitle
  							+ "</a></li>";
  						}else{
  							var ahref = "<li><a href='"
  							+ entrylinkfixed
  							+ "' target='_self' title='"
  							+ entrytitlefull
  							+ "' alt='"
  							+ entrytitlefull
  							+ "'>"
  							+ entrytitle
  							+ "</a></li>";
  						}
  
      			 }
      			if (hoco == 'home')
      				{
  						if(type == 'opdrachten'){
  							var ahref = "<li><a href='"
  							+ entrylink
  							+ "' target='_self' title='"
  							+ entrytitlefull
  							+ "' alt='"
  							+ entrytitlefull
  							+ "'>"
  							+ entrytitle
  							+ "</a></li>";
  						}else{
  							var ahref = "<li><a href='"
  							+ entrylinkfixed
  							+ "' target='_self' title='"
  							+ entrytitlefull
  							+ "' alt='"
  							+ entrytitlefull
  							+ "'>"
  							+ entrytitle
  							+ "</a></li>";
  						}
  					
      				}
      		  html = html + "" + ahref;
          }
        }
        else {
          html += "<li>De " + type + " feed kan op dit moment helaas niet worden ingelezen.</li>";
        }
      }        
      else {
        html += "<li>De " + type + " feed kan op dit moment helaas niet worden ingelezen.</li>";
      }

      var rsshtml = "<a href='" + gotoURL + "' class='buttonLink medium' title='Yacht " + type + "' alt='Yacht " + type + "' target='_self'>" + titel + "</a>";
     // var rsshtml = "";
      //html = html + rsshtml + "</ul>";
      html = html + "</ul>" + rsshtml;
      //html = html + "<hr/>";
      container.innerHTML = html;
    });
			
			}
			
			
			//google.setOnLoadCallback(feeds_initialize);
			function ext_feeds_initialize(count,max,url,type,titel,hoco,gotoURL) {
    //Algemeen
	
	var feed1 = new google.feeds.Feed(url);
    //var feed1 = new google.feeds.Feed("http://accsite4.roxen.ibridge.nl/feeds/ygn-acc.xml");
    //var feed1 = new google.feeds.Feed("http://dev.edit.zwart2.yacht.nl.rsg/content/carriere/vakgebieden/bouwkunde-civiel/job-feed-mwp-all.xml");
    feed1.setNumEntries(max);
    feed1.setResultFormat(google.feeds.Feed.MIXED_FORMAT);
    feed1.load(function(result) {
      if (!result.error) {
        var container = document.getElementById(type + "feedcp-" + count);
        var ahref = "";
		
		var closeul = "";
        for (var i = 0; i < result.feed.entries.length; i++) {
		
		var entrydescription = "";
          var entry = result.feed.entries[i];
          // get title
          var entrytitle = entry.title;
          /*if (entrytitle.length > 70) {
            entrytitle = entrytitle.substr(0,45) + "...";
          }*/
          // calculate/format date
          var entrydate = new Date(entry.publishedDate);
          var current_day = entrydate.getDate();
          var current_month = entrydate.getMonth() + 1;
          var current_year = entrydate.getFullYear();
          if (current_day < 10) {current_day = "0" + current_day; }
          if (current_month < 10) {current_month = "0" + current_month; }
          var formatteddate = current_day + "-" + current_month + "-" + entrydate.getFullYear();
		  var entrylink = entry.link;
          var entrylinkfixed = entrylink.replace("/vacaturs/","/vacature/");
		  var entrydescription = entry.contentSnippet;
		 
		  if (i == 0)	{
			entrydescription = entrydescription.substr(0,82);
			var lastValidSpacePos = entrydescription.lastIndexOf(' ');
			entrydescription = entrydescription.substring(0, lastValidSpacePos);

			if (hoco == 'home')
				{
					
					var html = '<ul><li><a class="titleLink" href="' + entrylink + '">' + entrytitle + '</a>';
					url =  "...<a href='" + entrylink + "'>Lees meer</a>";
					html = html + ' - ' + formatteddate + " " + entrydescription;
					html = html + url + '</li>';
					
				}
				
			if (hoco == 'content')
				{
					
		  
				  //Get description
					var html = '<p><strong>'+ entrytitle + '</strong>' + ' - ' +formatteddate + '<br/>';
					//var entrydescription = entry.contentSnippet;
					//entrydescription = entrydescription.substr(0,72);
					url =  "...<a href='" + entrylink + "'>Lees meer</a>";
					
					var openul = '<ul class="navigationList small strong">';
					html = html + entrydescription + url + '</p>' + openul;
				}
			} 
			// i > 0
			else	
				{
				
				if (hoco == 'home')	{
					entrydescription = entrydescription.substr(0,82);
					}
				else{
					entrydescription = entrydescription.substr(0,29);
					}
					
        var lastValidSpacePos = entrydescription.lastIndexOf(' ');
        entrydescription = entrydescription.substring(0, lastValidSpacePos);
				entrydescription = entrydescription + "...";
				if (hoco == 'home')
					{
					var counter = max - 1;
					if (i < counter)
						
						{
					
							var ahref = '<li><a class="titleLink" href="' + entrylink + '">' + entrytitle + '</a>';
							url =  "...<a href='" + entrylink + "'>Lees meer</a>";
							var ahref = ahref + ' - ' + formatteddate + " " + entrydescription + url  + '</li>';
							
						}
					if (i == counter)
						{
						
						var ahref = '<li class="last"><a class="titleLink" href="' + entrylink + '">' + entrytitle + '</a>';
						url =  "<a href='" + entrylink + "'>Lees meer</a>";
						var ahref = ahref + ' - ' + formatteddate + " " + entrydescription + url  + '</li>';
						
						}
					
					}
					
				if (hoco == 'content')
				
					{
						
						var closeul = "</ul>";
						
					  // build link
					  var ahref = "<li><a href='"
						+ entrylinkfixed
						+ "' target='_self' class='linkFeed' title='"
						+ entrytitle
						+ "' alt='"
						+ entrytitle
						+ "'><strong>"
						+ entrytitle
						+ "</strong> - " + formatteddate + " " + entrydescription + "</a></li>";
						}
				}
          
		  
				html = html + ahref ;
			
			
		
        }
  
		if (hoco == 'content')
			{
			html = html + "</ul>";
			}
			
		if (hoco == 'home')
			{
			html = html + "</ul>";
			}

      var rsshtml = "<a href='" + gotoURL + "' class='buttonLink medium' title='Yacht " + type + "' alt='Yacht " + type + "' target='_self'>" + titel + "</a>";			
      html = html + rsshtml;		
        
        container.innerHTML = html;
      }
    });
			
			}
