function checkPublished(date){
	var currentdate = date;
    var startdate = document.getElementById("fromdate").value;
    var enddate = document.getElementById("todate").value;
    
    arr_startdate = startdate.split('-');
    str_startdate = arr_startdate[2]+'-'+arr_startdate[1]+'-'+arr_startdate[0];

    arr_enddate = enddate.split('-');
    str_enddate = arr_enddate[2]+'-'+arr_enddate[1]+'-'+arr_enddate[0];
    
    if(startdate == ''){
    	bool = 1;
    }
    else if( (str_startdate <= currentdate) && (currentdate <= str_enddate) ){
    	bool = 1;
    }
    else{ 
    	bool = 0;
    }
    
    if(bool == 0)
    {
        //published  enable the show buttons
        document.forms[0].publish[0].checked=true;
        document.forms[0].publish[0].disabled=true;
        document.forms[0].publish[1].disabled=true;
        // show that the job is active
    }
    else
    {   
    	// disable them
    	document.forms[0].publish[1].checked=true;
        document.forms[0].publish[0].disabled=false;
        document.forms[0].publish[1].disabled=false;            
    }
}
function sendContactsSearch(role, txt)
{
	new Ajax.Request('/ajax/contactsearchrequest', 
				  	{ 
						method: 'post', 
						parameters: {
							role : role,
							txt : txt
						}, 
						onComplete: function(request) {
						    var xmlReply = request.responseXML;
							var addcontacts = document.getElementById('newcontactContainer');
							var contacts = xmlReply.getElementsByTagName('contacts');
							var contactsselect = contacts[0].firstChild.nodeValue;
							addcontacts.innerHTML = contactsselect;
						},
						onFailure: function(request) {    // Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
							alert('unable to collect contacts');
						}
					}
	);
    return false;
}
/* Mu profile Password validation */
function CallPwdForm(errPwd, strTitle) {
	Modalbox.show($('popupcontainer').innerHTML,
	{
		title: strTitle, 
		width: 400,
		height: 250
	});
}

function sendDialogForm(errPwd, formName, e) {

	var submit = 0;
	var key=e.keyCode || e.which;
	if(key != ''){
		if(key==13){
			var submit = 1;
		}
	}
	if(key == 1 || key == undefined){
		var submit = 1;
	}
	if(submit == 1){
		document.getElementById('popuperrorimage').style.display = 'block';
		new Ajax.Request('/ajax/validatepassword', 
					  	{ 
							method: 'post', 
							parameters: {pwd : $('currentpassword').value}, 
							onComplete: function(request) {
								result = request.responseText;
							    if(result == 1) $(formName).submit();
							    else {
							    	document.getElementById('popuperrorimage').style.display = 'none';
							        $('popuperrortext').innerHTML = errPwd;
							        $('popuperrortext').show();
							     }
							},
							onFailure: function(request) {    // Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
								document.getElementById('popuperrorimage').style.display = 'none';
								$('popuperrortext').innerHTML = errPwd;
							}
						}
		);
	    return false;
	}
}

/* Add contacts create message */
function delete_recepients(type)
{
	if(type == 'to'){
		for(i =0; i < document.getElementById('addtocontact').length; i++){
			if(i == document.getElementById('addtocontact').selectedIndex){
				document.getElementById('addtocontact').removeChild(document.getElementById('addtocontact').options[i])
			}
		}
	}
	if(type == 'cc'){
		for(i =0; i < document.getElementById('addcccontact').length; i++){
			if(i == document.getElementById('addcccontact').selectedIndex){
				document.getElementById('addcccontact').removeChild(document.getElementById('addcccontact').options[i])
			}
		}
	}
}

function copy_recepients(type)
{
	if(type == 'all'){
		document.getElementById('hiddento').value = '';
		document.getElementById('toname').value = '';
		document.getElementById('hiddencc').value = '';
		document.getElementById('ccname').value = '';

		for(i =0; i < document.getElementById('addtocontact').length; i++){
			document.getElementById('hiddento').value = document.getElementById('hiddento').value + document.getElementById('addtocontact').options[i].value + '; ';
			document.getElementById('toname').value = document.getElementById('toname').value + document.getElementById('addtocontact').options[i].text + '; ';
		}
		for(i =0; i < document.getElementById('addcccontact').length; i++){
			document.getElementById('hiddencc').value = document.getElementById('hiddencc').value + document.getElementById('addcccontact').options[i].value + '; ';
			document.getElementById('ccname').value = document.getElementById('ccname').value + document.getElementById('addcccontact').options[i].text + '; ';
		}
		document.getElementById('searchcontact').value = '';
		Modalbox.hide();return false;
	}
	else
	{
		
		if(document.getElementById('newcontact').value != ''){
			var userid = document.getElementById('newcontact').value;
			var username = document.getElementById('newcontact').options[document.getElementById('newcontact').selectedIndex].text;
			if(!excists_sendto(userid) && !excists_sendcc(userid)){
				if(type == 'to'){
					optie = document.createElement('option');
					optie.setAttribute('value', userid);
					optie.appendChild(document.createTextNode(username));
					document.getElementById('addtocontact').appendChild(optie);
				}
				if(type == 'cc'){
					optie = document.createElement('option');
					optie.setAttribute('value', userid);
					optie.appendChild(document.createTextNode(username));
					document.getElementById('addcccontact').appendChild(optie);
				}
			}
		}
	}
}
function excists_sendto(userid){
	for(i=0; i < document.getElementById('addtocontact').length; i++){
		if(userid == document.getElementById('addtocontact').options[i].value){
			alert('Contact already selected in "TO" or "CC"');
			return true;
		}
	}
}
function excists_sendcc(userid){
	for(i=0; i < document.getElementById('addcccontact').length; i++){
		if(userid == document.getElementById('addcccontact').options[i].value){
			alert('Contact already selected in "TO" or "CC"');
			return true;
		}
	}
}
function getOldContacts(){
	/* TO Contacts */
	arr_tocontacts = document.getElementById('toname').value.split(';')
	arr_toids = document.getElementById('hiddento').value.split(';')
	for(i=0;i<(arr_tocontacts.length-1);i++){
		optie = document.createElement('option');
		optie.setAttribute('value', arr_toids[i]);
		optie.appendChild(document.createTextNode(arr_tocontacts[i]));
		document.getElementById('addtocontact').appendChild(optie);
	}
	/* CC Contacts */
	arr_cccontacts = document.getElementById('ccname').value.split(';')
	arr_ccids = document.getElementById('hiddencc').value.split(';')
	for(i=0;i<(arr_cccontacts.length-1);i++){
		optie = document.createElement('option');
		optie.setAttribute('value', arr_ccids[i]);
		optie.appendChild(document.createTextNode(arr_cccontacts[i]));
		document.getElementById('addcccontact').appendChild(optie);
	}
}

function openContactWindow(strTitle){3
	strTitle = 'Select receipt\'s name(s)';
	Modalbox.show($('addcontacts').innerHTML,
	{
		title: strTitle, 
		width: 700,
		height: 450
	});
	getOldContacts();
	
}
function resellerGetReferrersByName(imageurl, webhost, strNoResults){
	// Eventuele oude interval stoppen
    window.clearInterval(self.$intervalId); 
    // Stel interval waardes in
    self.$intervalValue = 1;
    self.$intervalMaxValue = 40; 
    // Interval starten (1 ms)
    self.$intervalId = window.setInterval(function(){
       
        // Controleer timer
        if(self.$intervalValue == self.$intervalMaxValue) {

			new Ajax.Request('/ajax/resellergetreferrersbyname', 
				  	{ 
						method: 'post', 
						parameters: 
						{
							search : $('searchname').value,
							direction : $('direction').value,
							sort : $('sort').value
						}, 
						onComplete: function(request) {
							xmlDoc1 = request.responseXML;

							// Set page navigation
							var str_navigation = xmlDoc1.getElementsByTagName("pagenavigation")[0].childNodes[0].firstChild.nodeValue;
							document.getElementById('listindex').innerHTML = str_navigation;
							document.getElementById('listindex2').innerHTML = str_navigation;
							var str_prevnext = xmlDoc1.getElementsByTagName("pagenavigation")[0].childNodes[1].firstChild.nodeValue;
							document.getElementById('prevnext').innerHTML = str_prevnext;
							document.getElementById('prevnext2').innerHTML = str_prevnext;
							
							// Read contacts
							var result = xmlDoc1.getElementsByTagName("contact");
							// Reset table
							
							
							document.getElementById('referrerresult').innerHTML = '';
							contenttable = document.createElement('table');
							contenttable.style.width="100%";
							contenttable.cellSpacing="0";
							//contenttable.style = 'width:100%';
							for(i=0;i<result.length;i++){
								var str_rating = '';
								var strban = '';
								if(result[i].childNodes[7].firstChild.nodeValue == 1){
									strban = '<a href="'+webhost+'/management/activateuser/referrer/'+result[i].childNodes[0].firstChild.nodeValue+ '"><img title="Activate this user to use GoozUp" alt="Activate this user to use GoozUp" src="'+imageurl+'Deactivated.gif"></a>';
								}
								else{
									strban = '<a href="'+webhost+'/management/deactivateuser/referrer/'+result[i].childNodes[0].firstChild.nodeValue+ '"><img title="De-Activate this user to use GoozUp" alt="De-Activate this user to use GoozUp" src="'+imageurl+'Activated.gif"></a>';
								}
								tbody = document.createElement("tbody");
								tr = document.createElement("tr");
								tr.className = "grid-row";
						        tr.onclick = new Function("DoNav('"+webhost+"/management/referrerdetails/referrer/"+result[i].childNodes[0].firstChild.nodeValue+"')");
						        tr.onmouseover = new Function("ChangeColor(this, true);");
						        tr.onmouseout = new Function("ChangeColor(this, false);");
								
								// Nickname
								td = document.createElement("td");
								td.style.width = "31%";
								td.innerHTML = result[i].childNodes[1].firstChild.nodeValue;
								tr.appendChild(td);
								// Rating
								td = document.createElement("td");
								td.style.width = "16%";
								td.innerHTML = result[i].childNodes[2].firstChild.nodeValue +' ('+result[i].childNodes[3].firstChild.nodeValue+')';
								tr.appendChild(td);
								// Location
								td = document.createElement("td");
								td.style.width = "20%";
								td.innerHTML = result[i].childNodes[4].firstChild.nodeValue;
								tr.appendChild(td);
								// Candidates
								td = document.createElement("td");
								td.style.width = "8%";
								td.innerHTML = result[i].childNodes[5].firstChild.nodeValue;
								tr.appendChild(td);
								// Number applications
								td = document.createElement("td");
								td.style.width = "8%";
								td.innerHTML = result[i].childNodes[6].firstChild.nodeValue;
								tr.appendChild(td);
								// Registrationdate
								td = document.createElement("td");
								td.style.width = "11%";
								td.innerHTML = result[i].childNodes[7].firstChild.nodeValue;
								tr.appendChild(td);
								// Options
								td = document.createElement("td");
								td.style.width = "6%";
								td.align = 'right';
								td.innerHTML = '<a href="'+webhost+'/management/referrerdetails/referrer/'+result[i].childNodes[0].firstChild.nodeValue+'"><img src="'+imageurl+'Open.gif"></a> '+strban;
								tr.appendChild(td);
								
								tr.appendChild(td);
								tbody.appendChild(tr);
								contenttable.appendChild(tbody);
								document.getElementById('referrerresult').appendChild(contenttable);
							}
							// Show message if there are 0 results
							if(result.length == 0){
								tbody = document.createElement("tbody");
								tr = document.createElement("tr");
								tr.className = "grid-row";
						        
								// Error message
								td = document.createElement("td");
								td.colspan = "6";
								td.innerHTML = strNoResults; 
								tr.appendChild(td);
								
								tr.appendChild(td);
								
								tr.appendChild(td);
								tbody.appendChild(tr);
								contenttable.appendChild(tbody);
								document.getElementById('referrerresult').appendChild(contenttable);
							}
							// Table header
							$('referrername').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[0].firstChild.nodeValue;
							$('rating').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[1].firstChild.nodeValue;
							$('region').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[2].firstChild.nodeValue;
							$('numbercontacts').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[3].firstChild.nodeValue;
							$('numberapplications').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[4].firstChild.nodeValue;
							$('joindate').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[5].firstChild.nodeValue;
						},
						onFailure: function(request) {    
							// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
							alert('An error occured while collecting your contacts')
						}
					}
				);
    			// Stop interval;
            	return window.clearInterval(self.$intervalId);
        }
        // Verhoog timerwaarde
        self.$intervalValue++;
    }, 1); 
}
 
function referrerGetContactsByName(imageurl, webhost, strNoResults){
	
    // Eventuele oude interval stoppen
    window.clearInterval(self.$intervalId); 
    // Stel interval waardes in
    self.$intervalValue = 1;
    self.$intervalMaxValue = 40; 
    // Interval starten (1 ms)
    self.$intervalId = window.setInterval(function(){
       
        // Controleer timer
        if(self.$intervalValue == self.$intervalMaxValue) {

        	// Doe request
            new Ajax.Request('/ajax/referrergetcontactsbyname', 
		  	{ 
				method: 'post', 
				parameters: 
				{
					search : $('searchname').value,
					direction : $('directionid').value,
					sort : $('sortid').value
				}, 
				onComplete: function(request) {
					xmlDoc1 = request.responseXML;
					var str_navigation = xmlDoc1.getElementsByTagName("pagenavigation")[0].childNodes[0].firstChild.nodeValue;
					document.getElementById('listindex').innerHTML = str_navigation;
					document.getElementById('listindex2').innerHTML = str_navigation;
					var str_prevnext = xmlDoc1.getElementsByTagName("pagenavigation")[0].childNodes[1].firstChild.nodeValue;
					document.getElementById('prevnext').innerHTML = str_prevnext;
					document.getElementById('prevnext2').innerHTML = str_prevnext;
					// Read contacts
					var result = xmlDoc1.getElementsByTagName("contact");
					// Reset table
					document.getElementById('contactsresult').innerHTML = '';
					
					contenttable = document.createElement('table');
					contenttable.style.width="100%";
					contenttable.cellSpacing="0";
					for(i=0;i<result.length;i++){
						tbody = document.createElement("tbody");
						tr = document.createElement("tr");
						tr.className = "grid-row";
				        tr.onclick = new Function("DoNav('"+webhost+"/referrer/contactsdetails/contact/"+result[i].childNodes[0].firstChild.nodeValue+"')");
				        tr.onmouseover = new Function("ChangeColor(this, true);");
				        tr.onmouseout = new Function("ChangeColor(this, false);");
						// Nickname
						td = document.createElement("td");
						td.style.width = "23%";
						td.innerHTML = result[i].childNodes[1].firstChild.nodeValue;
						tr.appendChild(td);
						// Function
						td = document.createElement("td");
						td.style.width = "20%";
						td.innerHTML = result[i].childNodes[2].firstChild.nodeValue;
						tr.appendChild(td);
						// Industry
						td = document.createElement("td");
						td.style.width = "25%";
						td.innerHTML = result[i].childNodes[3].firstChild.nodeValue;
						tr.appendChild(td);
						// Region
						td = document.createElement("td");
						td.style.width = "20%";
						td.innerHTML = result[i].childNodes[4].firstChild.nodeValue;
						tr.appendChild(td);
						// Options
						td = document.createElement("td");
						td.style.width = "12%";
						td.align = 'right';
						td.innerHTML = '<a href="'+webhost+'/referrer/contactsdetails/contact/'+result[i].childNodes[0].firstChild.nodeValue+'"><img src="'+imageurl+'Open.gif"></a> ';
						td.innerHTML += '<a href="'+webhost+'/referrer/contactscreate/contact/'+result[i].childNodes[0].firstChild.nodeValue+'/act/edit"><img src="'+imageurl+'Edit.gif"></a> ';
						td.innerHTML += '<a href="'+webhost+'/referrer/contactsdelete/contact/'+result[i].childNodes[0].firstChild.nodeValue+'/act/edit"><img src="'+imageurl+'Delete.gif"></a> ';
						tr.appendChild(td);

						tbody.appendChild(tr);
						contenttable.appendChild(tbody);
						document.getElementById('contactsresult').appendChild(contenttable);
					}
					// Show message if there are 0 results
					if(result.length == 0){
						tbody = document.createElement("tbody");
						tr = document.createElement("tr");
						tr.className = "grid-row";
				        
						// Error message
						td = document.createElement("td");
						td.colspan = "5";
						td.innerHTML = strNoResults; 
						tr.appendChild(td);
						
						tr.appendChild(td);
						
						tr.appendChild(td);
						tbody.appendChild(tr);
						contenttable.appendChild(tbody);
						document.getElementById('contactsresult').appendChild(contenttable);
					}
					// Set header
					$('name').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[0].firstChild.nodeValue;
					$('function').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[1].firstChild.nodeValue;
					$('industry').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[2].firstChild.nodeValue;
					$('location').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[3].firstChild.nodeValue;
				},
				onFailure: function(request) {    
					// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
					alert('An error occured while collecting your contacts')
				}
			}
			);
            // Stop interval;
            return window.clearInterval(self.$intervalId);
        }
       
        // Verhoog timerwaarde
        self.$intervalValue++;
    }, 1); 
}
function resellerGetRecruitersByName(imageurl, webhost, strNoResults){
	// Eventuele oude interval stoppen
    window.clearInterval(self.$intervalId); 
    // Stel interval waardes in
    self.$intervalValue = 1;
    self.$intervalMaxValue = 40; 
    // Interval starten (1 ms)
    self.$intervalId = window.setInterval(function(){
       
        // Controleer timer
        if(self.$intervalValue == self.$intervalMaxValue) {

			new Ajax.Request('/ajax/resellergetrecruitersbyname', 
				  	{ 
						method: 'post', 
						parameters: {
							search : $('searchname').value,
							direction : $('direction').value,
							sort : $('sort').value
						}, 
						onComplete: function(request) {
							xmlDoc1 = request.responseXML;

							// Set page navigation
							var str_navigation = xmlDoc1.getElementsByTagName("pagenavigation")[0].childNodes[0].firstChild.nodeValue;
							document.getElementById('listindex').innerHTML = str_navigation;
							document.getElementById('listindex2').innerHTML = str_navigation;
							var str_prevnext = xmlDoc1.getElementsByTagName("pagenavigation")[0].childNodes[1].firstChild.nodeValue;
							document.getElementById('prevnext').innerHTML = str_prevnext;
							document.getElementById('prevnext2').innerHTML = str_prevnext;
							
							// Read contacts
							var result = xmlDoc1.getElementsByTagName("contact");
							// Reset table
							document.getElementById('recruiterresult').innerHTML = '';
							contenttable = document.createElement('table');
							contenttable.style.width="100%";
							contenttable.cellSpacing="0";
							// Loop through results
							for(i=0;i<result.length;i++){
								if(result[i].childNodes[6].firstChild.nodeValue == 1){
									strban = '<a href="javascript:;"><img id="status'+result[i].childNodes[0].firstChild.nodeValue+'" src="'+imageurl+'Deactivated.gif" title="Activate this user to use GoozUp" alt="Activate this user to use GoozUp" onclick="event.cancelBubble=true;changeStatusUser(\'recruiter\', \''+imageurl+'\', \'activate\', '+result[i].childNodes[0].firstChild.nodeValue+');" width="16" height="16"></a>';
								}
								else{
									strban = '<a href="javascript:;"><img id="status'+result[i].childNodes[0].firstChild.nodeValue+'" src="'+imageurl+'Activated.gif" title="De-Activate this user to use GoozUp" alt="De-Activate this user to use GoozUp" onclick="event.cancelBubble=true;changeStatusUser(\'recruiter\', \''+imageurl+'\', \'deactivate\', '+result[i].childNodes[0].firstChild.nodeValue+');" width="16" height="16"></a>';
								}
								tbody = document.createElement("tbody");
								tr = document.createElement("tr");
								tr.className = "grid-row";
						        tr.onclick = new Function("DoNav('"+webhost+"/management/recruiterdetails/recruiter/"+result[i].childNodes[0].firstChild.nodeValue+"')");
						        tr.onmouseover = new Function("ChangeColor(this, true);");
						        tr.onmouseout = new Function("ChangeColor(this, false);");
								
								// Nickname
								td = document.createElement("td");
								td.style.width = "31%";
								td.innerHTML = result[i].childNodes[1].firstChild.nodeValue;
								tr.appendChild(td);
								// Company
								td = document.createElement("td");
								td.style.width = "22%";
								td.innerHTML = result[i].childNodes[2].firstChild.nodeValue;
								tr.appendChild(td);
								// Region
								td = document.createElement("td");
								td.style.width = "20%";
								td.innerHTML = result[i].childNodes[3].firstChild.nodeValue;
								tr.appendChild(td);
								// Jobs
								td = document.createElement("td");
								td.style.width = "10%";
								td.innerHTML = result[i].childNodes[4].firstChild.nodeValue;
								tr.appendChild(td);
								// Jobs
								td = document.createElement("td");
								td.style.width = "11%";
								td.innerHTML = result[i].childNodes[5].firstChild.nodeValue;
								tr.appendChild(td);
								// Options
								td = document.createElement("td");
								td.style.width = "6%";
								td.align = 'right';
								td.innerHTML = '<a href="'+webhost+'/management/recruiterdetails/recruiter/'+result[i].childNodes[0].firstChild.nodeValue+'"><img src="'+imageurl+'Open.gif"></a> '+strban;
								tr.appendChild(td);
								
								tr.appendChild(td);
								tbody.appendChild(tr);
								contenttable.appendChild(tbody);
								document.getElementById('recruiterresult').appendChild(contenttable);
							}
							// Show message if there are 0 results
							if(result.length == 0){
								tbody = document.createElement("tbody");
								tr = document.createElement("tr");
								tr.className = "grid-row";
						        
								// Error message
								td = document.createElement("td");
								td.colspan = "5";
								td.innerHTML = strNoResults; 
								tr.appendChild(td);
								
								tr.appendChild(td);
								
								tr.appendChild(td);
								tbody.appendChild(tr);
								contenttable.appendChild(tbody);
								document.getElementById('recruiterresult').appendChild(contenttable);
							}
							// Table header
								$('recruitername').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[0].firstChild.nodeValue;
								$('company').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[1].firstChild.nodeValue;
								$('region').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[2].firstChild.nodeValue;
								$('nrjobs').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[3].firstChild.nodeValue;
								$('joindate').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[4].firstChild.nodeValue;
						},
						onFailure: function(request) {    
							// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
							alert('An error occured while collecting your contacts')
						}
					}
			);
    		// Stop interval;
            return window.clearInterval(self.$intervalId);
        }
       
        // Verhoog timerwaarde
        self.$intervalValue++;
    }, 1); 
}
function applicationReminder(applicationid, referrerid, strTitle){
	callConfirmationbox(strTitle);
	
	// Eventuele oude interval stoppen
    window.clearInterval(self.$intervalId); 
    // Stel interval waardes in
    self.$intervalValue = 1;
    self.$intervalMaxValue = 40; 
    // Interval starten (1 ms)
    self.$intervalId = window.setInterval(function(){
       
        // Controleer timer
        if(self.$intervalValue == self.$intervalMaxValue) {
	
			new Ajax.Request('/referrer/applicationsremind', 
			  	{ 
					method: 'post', 
					parameters: {
						application : applicationid
					}, 
					onComplete: function(request) {
						$('reminderstatusloading').style.display = 'none';
						$('reminderstatusok').style.display = 'block';
						$('reminderstatusresult').style.display = 'block';
					},
					onFailure: function(request) {    
						// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
						alert('An error occured while collecting your contacts')
					}
				}
			);
    		// Stop interval;
            return window.clearInterval(self.$intervalId);
        }
       
        // Verhoog timerwaarde
        self.$intervalValue++;
    }, 1); 
}
function callConfirmationbox(strTitle){
	Modalbox.show($('confirmationbox').innerHTML,
	{
		title: strTitle, 
		width: 400,
		height: 250
	});
}
function resellerGetCandidatesByName(imageurl, webhost, strNoResults){
	// Eventuele oude interval stoppen
    window.clearInterval(self.$intervalId); 
    // Stel interval waardes in
    self.$intervalValue = 1;
    self.$intervalMaxValue = 40; 
    // Interval starten (1 ms)
    self.$intervalId = window.setInterval(function(){
       
        // Controleer timer
        if(self.$intervalValue == self.$intervalMaxValue) {
	
			new Ajax.Request('/ajax/resellergetcandidatesbyname', 
				  	{ 
						method: 'post', 
						parameters: {
							search : $('searchname').value
						}, 
						onComplete: function(request) {
							xmlDoc1 = request.responseXML;

							// Set page navigation
							var str_navigation = xmlDoc1.getElementsByTagName("pagenavigation")[0].childNodes[0].firstChild.nodeValue;
							document.getElementById('listindex').innerHTML = str_navigation;
							document.getElementById('listindex2').innerHTML = str_navigation;
							var str_prevnext = xmlDoc1.getElementsByTagName("pagenavigation")[0].childNodes[1].firstChild.nodeValue;
							document.getElementById('prevnext').innerHTML = str_prevnext;
							document.getElementById('prevnext2').innerHTML = str_prevnext;
							
							// Read contacts
							var result = xmlDoc1.getElementsByTagName("contact");
							// Reset table
							document.getElementById('candidatesresult').innerHTML = '';
							// Loop through results
							for(i=0;i<result.length;i++){
								document.getElementById('candidatesresult').innerHTML += '<tr class="grid-row"onclick="DoNav(\''+webhost+'/management/candidatesdetails/candidate/'+result[i].childNodes[0].firstChild.nodeValue+ '\');" onmouseover="ChangeColor(this, true);" onmouseout="ChangeColor(this, false);"><td style="width:40%;">'+result[i].childNodes[1].firstChild.nodeValue+ '</td><td style="width: 25%;">'+result[i].childNodes[2].firstChild.nodeValue+ '</td><td style="width: 25%;">'+result[i].childNodes[3].firstChild.nodeValue+ '</td><td style="width: 10%;" align="right"><a href="'+webhost+'/management/candidatesdetails/candidate/'+result[i].childNodes[0].firstChild.nodeValue+'"><img src="'+imageurl+'Open.gif"></a></td></tr>';
							}
							// Show message if there are 0 results
							if(result.length == 0){
								document.getElementById('candidatesresult').innerHTML += '<tr><td colspan="6">There are no Candidates in your region</td></tr>';
							}
						},
						onFailure: function(request) {    
							// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
							alert('An error occured while collecting your contacts')
						}
					}
			);
    		// Stop interval;
            return window.clearInterval(self.$intervalId);
        }
       
        // Verhoog timerwaarde
        self.$intervalValue++;
    }, 1); 
}
function resellerGetOpenJobsByName(imageurl, webhost, strNoResults){
	// Eventuele oude interval stoppen
    window.clearInterval(self.$intervalId); 
    // Stel interval waardes in
    self.$intervalValue = 1;
    self.$intervalMaxValue = 40; 
    // Interval starten (1 ms)
    self.$intervalId = window.setInterval(function(){
       
        // Controleer timer
        if(self.$intervalValue == self.$intervalMaxValue) {
	
			new Ajax.Request('/ajax/resellergetopenjobsbyname', 
			  	{ 
					method: 'post', 
					parameters: {
						search : $('searchname').value,
						direction : $('direction').value,
						sort : $('sort').value
					}, 
					onComplete: function(request) {
						xmlDoc1 = request.responseXML;
						// Set page navigation
						var str_navigation = xmlDoc1.getElementsByTagName("pagenavigation")[0].childNodes[0].firstChild.nodeValue;
						document.getElementById('listindex').innerHTML = str_navigation;
						document.getElementById('listindex2').innerHTML = str_navigation;
						var str_prevnext = xmlDoc1.getElementsByTagName("pagenavigation")[0].childNodes[1].firstChild.nodeValue;
						document.getElementById('prevnext').innerHTML = str_prevnext;
						document.getElementById('prevnext2').innerHTML = str_prevnext;
						
						// Read contacts
						var result = xmlDoc1.getElementsByTagName("jobs");
						// Reset table
						$('jobsresult').innerHTML = '';
						contenttable = document.createElement('table');
						contenttable.style.width="100%";
						contenttable.cellSpacing="0";
						// Loop through results
						for(i=0;i<result.length;i++){

							tbody = document.createElement("tbody");
							tr = document.createElement("tr");
							tr.className = "grid-row";
					        tr.onclick = new Function("DoNav('"+webhost+"/management/marketingjobdetails/job/"+result[i].childNodes[0].firstChild.nodeValue+"')");
					        tr.onmouseover = new Function("ChangeColor(this, true);");
					        tr.onmouseout = new Function("ChangeColor(this, false);");
							
							// Title
							td = document.createElement("td");
							td.style.width = "28%";
							td.innerHTML = result[i].childNodes[1].firstChild.nodeValue;
							tr.appendChild(td);
							// Recruiter
							td = document.createElement("td");
							td.style.width = "20%";
							td.innerHTML = result[i].childNodes[2].firstChild.nodeValue;
							tr.appendChild(td);
							// Location
							td = document.createElement("td");
							td.style.width = "19%";
							td.innerHTML = result[i].childNodes[3].firstChild.nodeValue;
							tr.appendChild(td);
							// Status
							td = document.createElement("td");
							td.style.width = "8%";
							td.className = 'makestrong';
							td.innerHTML = result[i].childNodes[6].firstChild.nodeValue;
							tr.appendChild(td);
							// Postdate
							td = document.createElement("td");
							td.style.width = "13%";
							td.innerHTML = result[i].childNodes[4].firstChild.nodeValue;
							tr.appendChild(td);
							// Reward
							td = document.createElement("td");
							td.style.width = "8%";
							td.innerHTML = result[i].childNodes[5].firstChild.nodeValue;
							tr.appendChild(td);
							// Options
							td = document.createElement("td");
							td.style.width = "4%";
							td.align = 'right';
							td.innerHTML = '<a href="'+webhost+'/management/marketingjobdetails/job/'+result[i].childNodes[0].firstChild.nodeValue+'"><img src="'+imageurl+'Open.gif"></a>';
							tr.appendChild(td);
							
							tr.appendChild(td);
							tbody.appendChild(tr);
							contenttable.appendChild(tbody);
							$('jobsresult').appendChild(contenttable);
						}
						// Show message if there are 0 results
						if(result.length == 0){
							tbody = document.createElement("tbody");
							tr = document.createElement("tr");
							tr.className = "grid-row";
					        
							// Error message
							td = document.createElement("td");
							td.colspan = "5";
							td.innerHTML = strNoResults; 
							tr.appendChild(td);
							
							tr.appendChild(td);
							
							tr.appendChild(td);
							tbody.appendChild(tr);
							contenttable.appendChild(tbody);
							$('jobsresult').appendChild(contenttable);
						}
						$('jobtitle').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[0].firstChild.nodeValue;
						$('recruiter').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[1].firstChild.nodeValue;
						$('location').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[2].firstChild.nodeValue;
						$('postdate').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[3].firstChild.nodeValue;
						$('reward').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[4].firstChild.nodeValue;
					},
					onFailure: function(request) {    
						// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
						alert('An error occured while collecting your contacts')
					}
				}
			);
    		// Stop interval;
            return window.clearInterval(self.$intervalId);
        }
       
        // Verhoog timerwaarde
        self.$intervalValue++;
    }, 1); 
}

function resellerGetClosedJobsByName(imageurl, webhost, strNoResults){
	// Eventuele oude interval stoppen
    window.clearInterval(self.$intervalId); 
    // Stel interval waardes in
    self.$intervalValue = 1;
    self.$intervalMaxValue = 40; 
    // Interval starten (1 ms)
    self.$intervalId = window.setInterval(function(){
       
        // Controleer timer
        if(self.$intervalValue == self.$intervalMaxValue) {
	
			new Ajax.Request('/ajax/resellergetclosedjobsbyname', 
				  	{ 
						method: 'post', 
						parameters: {
							search : $('searchname').value,
							direction : $('direction').value,
							sort : $('sort').value
						}, 
						onComplete: function(request) {
							xmlDoc1 = request.responseXML;
							// Set page navigation
							var str_navigation = xmlDoc1.getElementsByTagName("pagenavigation")[0].childNodes[0].firstChild.nodeValue;
							document.getElementById('listindex').innerHTML = str_navigation;
							document.getElementById('listindex2').innerHTML = str_navigation;
							var str_prevnext = xmlDoc1.getElementsByTagName("pagenavigation")[0].childNodes[1].firstChild.nodeValue;
							document.getElementById('prevnext').innerHTML = str_prevnext;
							document.getElementById('prevnext2').innerHTML = str_prevnext;
							
							// Read contacts
							var result = xmlDoc1.getElementsByTagName("jobs");
							// Reset table
							$('jobsresult').innerHTML = '';
							contenttable = document.createElement('table');
							contenttable.style.width="100%";
							contenttable.cellSpacing="0";
							// Loop through results
							for(i=0;i<result.length;i++){

								tbody = document.createElement("tbody");
								tr = document.createElement("tr");
								tr.className = "grid-row";
						        tr.onclick = new Function("DoNav('"+webhost+"/management/marketingjobdetails/job/"+result[i].childNodes[0].firstChild.nodeValue+"')");
						        tr.onmouseover = new Function("ChangeColor(this, true);");
						        tr.onmouseout = new Function("ChangeColor(this, false);");
								
								// Title
								td = document.createElement("td");
								td.style.width = "28%";
								td.innerHTML = result[i].childNodes[1].firstChild.nodeValue;
								tr.appendChild(td);
								// Recruiter
								td = document.createElement("td");
								td.style.width = "25%";
								td.innerHTML = result[i].childNodes[2].firstChild.nodeValue;
								tr.appendChild(td);
								// Location
								td = document.createElement("td");
								td.style.width = "20%";
								td.innerHTML = result[i].childNodes[3].firstChild.nodeValue;
								tr.appendChild(td);
								// Postdate
								td = document.createElement("td");
								td.style.width = "15%";
								td.innerHTML = result[i].childNodes[4].firstChild.nodeValue;
								tr.appendChild(td);
								// Reward
								td = document.createElement("td");
								td.style.width = "8%";
								td.innerHTML = result[i].childNodes[5].firstChild.nodeValue;
								tr.appendChild(td);
								// Options
								td = document.createElement("td");
								td.style.width = "4%";
								td.align = 'right';
								td.innerHTML = '<a href="'+webhost+'/management/marketingjobdetails/job/'+result[i].childNodes[0].firstChild.nodeValue+'"><img src="'+imageurl+'Open.gif"></a>';
								tr.appendChild(td);
								
								tr.appendChild(td);
								tbody.appendChild(tr);
								contenttable.appendChild(tbody);
								$('jobsresult').appendChild(contenttable);
							}
							// Show message if there are 0 results
							if(result.length == 0){
								tbody = document.createElement("tbody");
								tr = document.createElement("tr");
								tr.className = "grid-row";
						        
								// Error message
								td = document.createElement("td");
								td.colspan = "5";
								td.innerHTML = strNoResults; 
								tr.appendChild(td);
								
								tr.appendChild(td);
								
								tr.appendChild(td);
								tbody.appendChild(tr);
								contenttable.appendChild(tbody);
								$('jobsresult').appendChild(contenttable);
							}
							$('jobtitle').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[0].firstChild.nodeValue;
							$('recruiter').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[1].firstChild.nodeValue;
							$('location').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[2].firstChild.nodeValue;
							$('postdate').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[3].firstChild.nodeValue;
							$('reward').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[4].firstChild.nodeValue;
						},
						onFailure: function(request) {    
							// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
							alert('An error occured while collecting your contacts')
						}
					}
			);
    		// Stop interval;
            return window.clearInterval(self.$intervalId);
        }
       
        // Verhoog timerwaarde
        self.$intervalValue++;
    }, 1); 
}

function getLocationsList(countryid, resultid1, resultid2){
	if(countryid!=0 )
	{
		new Ajax.Request('/ajax/locationlist', 
		  	{ 
				method: 'post', 
				parameters: {
					country : countryid
				}, 
				onComplete: function(transport) {
					var json = transport.responseText.evalJSON();
					// Remove old elements
					while ($(resultid1).hasChildNodes()) {
						$(resultid1).removeChild($(resultid1).firstChild);
					}
					// Remove entry 2
					if(resultid2 != null){
						while ($(resultid2).hasChildNodes()) {
							$(resultid2).removeChild($(resultid2).firstChild);
						}
					}
					
					// Check for optgroups
					if(json.optgroup != null){
						for(i=0;i<json.optgroup.length;i++){
							var optgroup = document.createElement('optgroup');
							optgroup.setAttribute('label', json.optgroup[i]['name']);		
							// Append																	
							$(resultid1).appendChild(optgroup);
							// Loop through subelements
							for(a=0;a<json.optgroup[i].sublocations.length;a++){
								var option = document.createElement('option');	
								option.setAttribute('value', json.optgroup[i].sublocations[a].id);
								if ( typeof(option.innerText) != 'undefined' ) {
									option.innerText = json.optgroup[i].sublocations[a].name;
								}
								else{
									option.text = json.optgroup[i].sublocations[a].name;
								}
								optgroup.appendChild(option);								
							}	

							//Append list 2
							if(resultid2 != null){	
								var optgroup = document.createElement('optgroup');
								optgroup.setAttribute('label', json.optgroup[i]['name']);		
								// Append																	
								$(resultid2).appendChild(optgroup);
								// Loop through subelements
								for(a=0;a<json.optgroup[i].sublocations.length;a++){
									var option = document.createElement('option');	
									option.setAttribute('value', json.optgroup[i].sublocations[a].id);
									if ( typeof(option.innerText) != 'undefined' ) {
										option.innerText = json.optgroup[i].sublocations[a].name;
									}
									else{
										option.text = json.optgroup[i].sublocations[a].name;
									}
									optgroup.appendChild(option);								
								}		
							}				
						}
					}
					else{
						// Loop through results
						for(i=0;i<json.length;i++){
							var option = document.createElement('option');	
							option.setAttribute('value', json[i].id);
							if ( typeof(option.innerText) != 'undefined' ) {
								option.innerText = json[i].name;
							}
							else{
								option.text = json[i].name;
							}
							$(resultid1).appendChild(option);	
							// append list 2
							if(resultid2 != null){
								var option = document.createElement('option');	
								option.setAttribute('value', json[i].id);
								if ( typeof(option.innerText) != 'undefined' ) {
									option.innerText = json[i].name;
								}
								else{
									option.text = json[i].name;
								}
								$(resultid2).appendChild(option);	
							}
							
						}
					}
				},
				onFailure: function(request) {    
					// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
					alert('An error occured while collecting the locationlist');
				}
			}
		);
		return false;
	    
	}
	else{
//    	clearLocations(resultdiv, resultdiv, newname, bool_all);
	}
}
/**
 *	this function will collect the locations connect with the selected country
 */
function getLocations(countryID, resultdiv, newname, bool_all)
{   
	var xmlDoc = '';
	if(countryID!=0 )
	{
		new Ajax.Request('/ajax/locations', 
					  	{ 
							method: 'post', 
							parameters: {
								country : countryID,
								result : resultdiv,
								newname : newname,
								all : bool_all
							}, 
							onComplete: function(request) {
								var xmlDoc = request.responseXML;
								var locationsDiv = document.getElementById(resultdiv);
								var locations = xmlDoc.getElementsByTagName('locations');
								var locationsSelect = locations[0].firstChild.nodeValue;
								locationsDiv.innerHTML = locationsSelect;
							},
							onFailure: function(request) {    
								// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
								alert('An error occured while collecting your contacts')
							}
						}
		);
		return false;
	    
	}
	else{
    	clearLocations(resultdiv, resultdiv, newname, bool_all);
	}
}
/**
 * Get Myprofile Regions
 */
function getMyProfileLocations(countryID){
	var xmlDoc = '';
	if(countryID!=0 )
	{
		new Ajax.Request('/ajax/locations', 
					  	{ 
							method: 'post', 
							parameters: {
								country : countryID,
								all : 3
							}, 
							onComplete: function(request) {
								var xmlDoc = request.responseXML;
								
								// Put in top div
								var locations = xmlDoc.getElementsByTagName('locations');
								var locationsSelect = '<select name="location"><option value=""></option>'+locations[0].firstChild.nodeValue+'</select>';
								$('location').innerHTML = locationsSelect;
								
								if($('workinglocations') != null){
									// Put in multiselect div
									var locations = xmlDoc.getElementsByTagName('locations');
									var locationsSelect = '<select name="workinglocations[]" multiple style="width:100%; height:200px">'+locations[0].firstChild.nodeValue+'</select>';
									$('workinglocations').innerHTML = locationsSelect;
								}
							},
							onFailure: function(request) {    
								// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
								alert('An error occured while collecting your contacts')
							}
						}
		);
		return false;
	    
	}
	else{
    	clearLocations(resultdiv);
	}
}
/**
 * Clear the result div 
 */
function clearLocations(resultdiv, resultdiv, newname, bool_all)
{
	var locationsDiv = $(resultdiv);
	var defaultValue = "<select id="+resultdiv+" name="+newname+"><option value=\"0\"></option></select>";
	locationsDiv.innerHTML = defaultValue;
}
function resendInvoice(id){
	Modalbox.show($('popupcontainer').innerHTML,
	{
		title: 'Resend Invoice', 
		width: 400,
		height: 250
	});
	new Ajax.Request('/ajax/resellersendrecruiterinvoice', 
				  	{ 
						method: 'post', 
						parameters: {
							invoiceid : id
						}, 
						onComplete: function(request) {
						},
						onFailure: function(request) {    
							// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
							alert('An error occured while resolving action')
						}
					}
	);
	return false;
}
function paidInvoice(invID, webhost){
	$('popupcontent').innerHTML = '<p align="center">Did the recruiter paid the whole invoice?</br><br/><a href="'+webhost+'/management/invoicessendpayment/invoice/'+invID+'">YES</a> - NO<br/><br/><a href="#" title="Cancel" onclick="Modalbox.hide();return false;">Cancel</a></p>';
	Modalbox.show($('popupcontainer').innerHTML,
	{
		title: 'Paid Invoice', 
		width: 600,
		height: 250
	});
}
function changeStatusUser(role, imageurl, status, userid, event){
	if(status == 'activate'){
		var strMessage = 'Are you sure you want to Activate this user?';
	}
	else{
		var strMessage = 'Are you sure you want to De-activate this user?';
	}
	$('status'+userid).src = imageurl+'Loading2.gif';
	// Check if action is true
	if(confirm(strMessage)){
		new Ajax.Request('/ajax/resellerchangeuserstatus', 
	  	{ 
			method: 'post', 
			parameters: {
				role : role,
				status : status,
				userid : userid 
			}, 
			onComplete: function(request) {
				// Activated
				if(status == 'activate'){
					$('status'+userid).src = imageurl+'Activated.gif';
					$('status'+userid).title = 'De-Activate this user to use GoozUp';
					$('status'+userid).alt = 'De-Activate this user to use GoozUp';
					document.getElementById('status'+userid).onclick =
																    function( event )
																	{
																	  var event = event || window.event;
																	  event.cancelBubble=true;
																	  changeStatusUser(role, imageurl, 'deactivate', userid);
																	  return;
																	};
				}
				// De-Activated
				else{
					$('status'+userid).src = imageurl+'Deactivated.gif';
					$('status'+userid).title = 'Activate this user to use GoozUp';
					$('status'+userid).alt = 'Activate this user to use GoozUp';
					document.getElementById('status'+userid).onclick =
																    function( event )
																	{
																	  var event = event || window.event;
																	  event.cancelBubble=true;
																	  changeStatusUser(role, imageurl, 'activate', userid);
																	  return;
																	};
				}
			},
			onFailure: function(request) {    
				// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
				alert('An error occured while resolving action')
			}
		}
		);
		return false;
	}
	else{
		if(status == 'activate'){
			$('status'+userid).src= imageurl+'Deactivated.gif';
		}
		else{
			$('status'+userid).src= imageurl+'Activated.gif';
		}
	}
}
function calculateJobRewardBySalary(salary){
	// Eventuele oude interval stoppen
    window.clearInterval(self.$intervalId); 
    // Stel interval waardes in
    self.$intervalValue = 1;
    self.$intervalMaxValue = 25; 
    // Interval starten (1 ms)
    self.$intervalId = window.setInterval(function(){
       
        // Controleer timer
        if(self.$intervalValue == self.$intervalMaxValue) {
			if(salary == null){
				salary = $('salary').value;
			}
        	if($('perhour').checked == true){
				var type = 1;
			}
			else if($('perweek').checked == true){
				var type = 2;
			}
			else if($('permonth').checked == true){
				var type = 3;
			}
			else if($('peryear').checked == true){
				var type = 4;
			}
			new Ajax.Request('/ajax/recruiterscalculatejobreward', 
				  	{ 
						method: 'post', 
						parameters: {
							salary : salary,
							type : type
						}, 
						onComplete: function(request) {
							$('rewardid').value = request.responseText;
						},
						onFailure: function(request) {    
							// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
							alert('An error occured while collecting your result')
						}
					}
			);
    		// Stop interval;
            return window.clearInterval(self.$intervalId);
        }
       
        // Verhoog timerwaarde
        self.$intervalValue++;
    }, 1); 
}
function resellerGetNewByTitle(imageurl, webhost, strNoResults){
	// Eventuele oude interval stoppen
    window.clearInterval(self.$intervalId); 
    // Stel interval waardes in
    self.$intervalValue = 1;
    self.$intervalMaxValue = 40; 
    // Interval starten (1 ms)
    self.$intervalId = window.setInterval(function(){
       
        // Controleer timer
        if(self.$intervalValue == self.$intervalMaxValue) {
	
			new Ajax.Request('/ajax/resellergetnewsbytitle', 
				  	{ 
						method: 'post', 
						parameters: {
							search : $('searchname').value,
							direction : $('direction').value,
							sort : $('sort').value
						}, 
						onComplete: function(request) {
							xmlDoc1 = request.responseXML;
							// Set page navigation
							var str_navigation = xmlDoc1.getElementsByTagName("pagenavigation")[0].childNodes[0].firstChild.nodeValue;
							document.getElementById('listindex').innerHTML = str_navigation;
							document.getElementById('listindex2').innerHTML = str_navigation;
							var str_prevnext = xmlDoc1.getElementsByTagName("pagenavigation")[0].childNodes[1].firstChild.nodeValue;
							document.getElementById('prevnext').innerHTML = str_prevnext;
							document.getElementById('prevnext2').innerHTML = str_prevnext;
							// Read contacts
							var result = xmlDoc1.getElementsByTagName("news");
							// Reset table
							$('newsresult').innerHTML = '';
							contenttable = document.createElement('table');
							contenttable.style.width="100%";
							contenttable.cellSpacing="0";
							// Loop through results
							for(i=0;i<result.length;i++){

								tbody = document.createElement("tbody");
								tr = document.createElement("tr");
								tr.className = "grid-row";
						        tr.onclick = new Function("DoNav('"+webhost+"/management/marketingnewsdetails/news/"+result[i].childNodes[0].firstChild.nodeValue+"')");
						        tr.onmouseover = new Function("ChangeColor(this, true);");
						        tr.onmouseout = new Function("ChangeColor(this, false);");
								
								// Title
								td = document.createElement("td");
								td.style.width = "65%";
								td.innerHTML = result[i].childNodes[1].firstChild.nodeValue;
								tr.appendChild(td);
								
								// Date
								td = document.createElement("td");
								td.style.width = "18%";
								td.innerHTML = result[i].childNodes[2].firstChild.nodeValue;
								tr.appendChild(td);
								
								// Status
								td = document.createElement("td");
								td.style.width = "8%";
								td.innerHTML = result[i].childNodes[3].firstChild.nodeValue;
								if(result[i].childNodes[3].firstChild.nodeValue == 0){
									td.innerHTML = 'Offline';
									td.className = 'offline'; 
								}
								else{
									td.innerHTML = 'Online' 
									td.className = 'online';
								}
								tr.appendChild(td);
								// Options
								td = document.createElement("td");
								td.style.width = "9%";
								td.align = 'right';
								td.innerHTML = '<a id="urlopen'+result[i].childNodes[0].firstChild.nodeValue+'" href="'+webhost+'/management/marketingnewsdetails/news/'+result[i].childNodes[0].firstChild.nodeValue+'"><img id="open'+result[i].childNodes[0].firstChild.nodeValue+'" alt="Open this News Item" title="Open this News Item" src="'+imageurl+'Open.gif"></a> <a id="urledit'+result[i].childNodes[0].firstChild.nodeValue+'" href="'+webhost+'/management/marketingnewscreate/news/'+result[i].childNodes[0].firstChild.nodeValue+'/act/edit"><img id="edit'+result[i].childNodes[0].firstChild.nodeValue+'" alt="Edit this News Item" title="Edit this News Item" src="'+imageurl+'Edit.gif"></a> <a id="urldelete0" href="'+webhost+'/management/marketingnewsdelete/news/'+result[i].childNodes[0].firstChild.nodeValue+'"><img id="delete'+result[i].childNodes[0].firstChild.nodeValue+'" alt="Delete this News Item" title="Delete this News Item" src="'+imageurl+'Delete.gif"></a>';
								tr.appendChild(td);

								tr.appendChild(td);
								tbody.appendChild(tr);
								contenttable.appendChild(tbody);
								$('newsresult').appendChild(contenttable);
							}
							// Show message if there are 0 results
							if(result.length == 0){
								tbody = document.createElement("tbody");
								tr = document.createElement("tr");
								tr.className = "grid-row";
						        
								// Error message
								td = document.createElement("td");
								td.colspan = "5";
								td.innerHTML = strNoResults; 
								tr.appendChild(td);
								
								tr.appendChild(td);
								
								tr.appendChild(td);
								tbody.appendChild(tr);
								contenttable.appendChild(tbody);
								$('newsresult').appendChild(contenttable);
							}
							$('newstitle').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[0].firstChild.nodeValue;
							$('newscreationdate').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[1].firstChild.nodeValue;
							$('newsstatus').innerHTML = xmlDoc1.getElementsByTagName("header")[0].childNodes[2].firstChild.nodeValue;
							
						},
						onFailure: function(request) {    
							// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
							alert('An error occured while collecting your contacts')
						}
					}
			);
    		// Stop interval;
            return window.clearInterval(self.$intervalId);
        }
       
        // Verhoog timerwaarde
        self.$intervalValue++;
    }, 1); 
}
function showModalbox(title, key, width, height){
	Modalbox.show($(key).innerHTML,
	{
		title: title, 
		width: width,
		height: height
	});
}
function submitJobscreate(){
	$('loading').style.display = 'block';
	new Ajax.Request('/ajax/recruiterjobscreatecontactdetails', 
  	{ 
		method: 'post', 
		parameters: {
			firstname : $('frmfirstname').value,
			prefix : $('frmprefix').value,
			lastname : $('frmlastname').value,
			address1 : $('frmaddress1').value,
			address2 : $('frmaddress2').value,
			postalcode : $('frmpostalcode').value,
			city : $('frmcity').value,
			company : $('frmcompany').value
		}, 
		onComplete: function(request) {
			xmlDoc = request.responseXML;
			var validform = 1;
			$('loading').style.display = 'none';
			if(xmlDoc.getElementsByTagName("form")[0].childNodes[0].firstChild.nodeValue != ''){
				// firstname
				$('frmfirstname').style.border='1px solid';
				$('frmfirstname').style.borderColor='#FF0000';
				var validform = 0;
			}
			
			else{
				$('frmfirstname').style.border='1px solid';
				$('frmfirstname').style.borderColor='#CCCCCC';
			}
			if(xmlDoc.getElementsByTagName("form")[0].childNodes[1].firstChild.nodeValue != ''){
				// lastname
				$('frmlastname').style.border='1px solid';
				$('frmlastname').style.borderColor='#FF0000';
				var validform = 0;
			}
			else{
				$('frmlastname').style.border='1px solid';
				$('frmlastname').style.borderColor='#CCCCCC';
			}
			if(xmlDoc.getElementsByTagName("form")[0].childNodes[2].firstChild.nodeValue != ''){
				// address
				$('frmaddress1').style.border='1px solid';
				$('frmaddress1').style.borderColor='#FF0000';
				$('frmaddress2').style.border='1px solid';
				$('frmaddress2').style.borderColor='#FF0000';
				var validform = 0;
			}
			else{
				$('frmaddress1').style.border='1px solid';
				$('frmaddress1').style.borderColor='#CCCCCC';
				$('frmaddress2').style.border='1px solid';
				$('frmaddress2').style.borderColor='#CCCCCC';
			}
			if(xmlDoc.getElementsByTagName("form")[0].childNodes[3].firstChild.nodeValue != ''){
				// postalcode
				$('frmpostalcode').style.border='1px solid';
				$('frmpostalcode').style.borderColor='#FF0000';
				var validform = 0;
			}
			else{
				$('frmpostalcode').style.border='1px solid';
				$('frmpostalcode').style.borderColor='#CCCCCC';
			}
			if(xmlDoc.getElementsByTagName("form")[0].childNodes[4].firstChild.nodeValue != ''){
				// city
				$('frmcity').style.border='1px solid';
				$('frmcity').style.borderColor='#FF0000';
				var validform = 0;
			}
			else{
				$('frmcity').style.border='1px solid';
				$('frmcity').style.borderColor='#CCCCCC';
			}
			if(xmlDoc.getElementsByTagName("form")[0].childNodes[5].firstChild.nodeValue != ''){
				// company
				$('frmcompany').style.border='1px solid';
				$('frmcompany').style.borderColor='#FF0000';
				var validform = 0;
			}
			else{
				$('frmcompany').style.border='1px solid';
				$('frmcompany').style.borderColor='#CCCCCC';
			}
			if(validform == 1){
				document.frmjobCreate.submit();
			}
		},
		onFailure: function(request) {    
			// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
			alert('An error occured while resolving action')
		}
	}
	);
	return false;
}
function resendPaymentdetails(id){
	Modalbox.show($('popupcontainer').innerHTML,
	{
		title: 'Payment details', 
		width: 400,
		height: 250
	});
	new Ajax.Request('/ajax/resellersendreferrerpaymentdetails', 
	  	{ 
			method: 'post', 
			parameters: {
				rewardid : id
			}, 
			onComplete: function(request) {
			},
			onFailure: function(request) {    
				// Wordt uitgevoerd wanneer er een 404/500 e.d. op komt
				alert('An error occured while resolving action')
			}
		}
	);
	return false;
	
}
function confirmPayment(strStatus, strTitle, rewardId, strUrl){
	if(strStatus === 1){
		$('valid').style.display = 'block';
		$('notvalid').style.display = 'none';
	}
	else{
		$('valid').style.display = 'none';
		$('notvalid').style.display = 'block';
	}
	$('redirpayurl').href = strUrl+rewardId;
	Modalbox.show($('popupcontainer').innerHTML,
	{
		title: strTitle, 
		width: 400,
		height: 250
	});
}