﻿var noMembershipAlert = 'This functionality is available after updating your account.';
var noProfileAlert = 'This functionality is available after completing your company profile.';
var noRecruiterLogin = 'This is only available to Recruiters that are logged into their account.  Please login as a Recruiter.';
var RAAlert = 'This functionality is only available for non-Reverse Auction Memberships.';
// Get the value of a COOKIE
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

// Functions used to create URL menu items for RECRUITERS
function getFindConsultantsURL()
{
    if (readCookie('HAS_PROFILE') != '1')
    {
        document.write('<a style="color:#AAAAAA" href="#" id="findNav" onclick="alert(\'' + noProfileAlert + '\');">Find Consultants</a>');
        return;
    }
    
	if (readCookie('HAS_MEMBERSHIP') != '1')
	{
		document.write('<a style="color:#AAAAAA" href="#" id="findNav" onclick="alert(\'' + noMembershipAlert + '\');">Find Consultants</a>');
		return;
	}
	
	if (readCookie('RA') == '1')
	{
	    document.write('<a style="color:#AAAAAA" href="#" id="findNav" onclick="alert(\'' + RAAlert + '\');">Find Consultants</a>');
		return;
	}
	
	var canSearch = readCookie('CAN_SEARCH');
	//alert('Can search: '+canSearch);
	if (canSearch != '1')
	{
		document.write('<a style="color:#AAAAAA" href="#" id="findNav" onclick="alert(\'This functionality is available after the free trial and is enabled by ERP-Consulting Management.\');">Find Consultants</a>');
	}
	else
		//document.write('<a href="recruiterSearch.html" id="findNav">Find Consultants</a>');
		document.write('<a href="New/Recruiter/SearchCandidates" id="findNav">Find Consultants</a>');
}

function getFindConsultantsURL2()
{
    if (readCookie('LOGINTYPE') == null || readCookie('LOGINTYPE') == "" || readCookie('LOGINTYPE') == 'C')
    {
        document.write('<a style="color:#AAAAAA" href="#" id="findNav" onclick="alert(\'' + noRecruiterLogin + '\');">Find Consultants</a>');
        return;
    }
    if (readCookie('HAS_PROFILE') != '1')
    {
        document.write('<a style="color:#AAAAAA" href="#" id="findNav" onclick="alert(\'' + noProfileAlert + '\');">Find Consultants</a>');
        return;
    }
        
	if (readCookie('HAS_MEMBERSHIP') != '1')
	{
		document.write('<a style="color:#AAAAAA" href="#" id="findNav" onclick="alert(\'' + noMembershipAlert + '\');">Find Consultants</a>');
		return;
	}
	
	if (readCookie('RA') == '1')
	{
	    document.write('<a style="color:#AAAAAA" href="#" id="findNav" onclick="alert(\'' + RAAlert + '\');">Find Consultants</a>');
		return;
	}
	
	var canSearch = readCookie('CAN_SEARCH');
	if (canSearch != '1')
	{
		document.write('<a style="color:#888888" href="#" id="findNav" onclick="alert(\'This functionality is available after the free trial and is enabled by ERP-Consulting Management.\');">Find Consultants</a>');
	}
	else
		document.write('<a href="New/Recruiter/SearchCandidates" id="findNav">Find Consultants</a>');
}

function getCandidateTrackingsURL()
{
    /*alert('links');
    alert('HAS_PROFILE='+readCookie('HAS_PROFILE'));
    alert('HAS_MEMBERSHIP='+readCookie('HAS_MEMBERSHIP'));
    alert('RA='+readCookie('RA'));
    alert('CAN_SEARCH='+readCookie('CAN_SEARCH'));
    */
    if (readCookie('HAS_PROFILE') != '1')
    {
        document.write('<a style="color:#AAAAAA" href="#" id="trackingNav" onclick="alert(\'' + noProfileAlert + '\');">Candidate Tracking</a>');
        return;
    }
    
	if (readCookie('HAS_MEMBERSHIP') != '1')
	{
		document.write('<a style="color:#AAAAAA" href="#" id="trackingNav" onclick="alert(\'' + noMembershipAlert + '\');">Candidate Tracking</a>');
		return;
	}
	
	if (readCookie('RA') == '1')
	{
	    document.write('<a style="color:#AAAAAA" href="#" id="trackingNav" onclick="alert(\'' + RAAlert + '\');">Candidate Tracking</a>');
		return;
	}
	
	if (readCookie('CAN_SEARCH') != '1')
	{
		document.write('<a style="color:#AAAAAA" href="#" id="trackingNav" onclick="alert(\'This functionality is available after the free trial and is enabled by ERP-Consulting Management.\');">Candidate Tracking</a>');
	}
	else
		document.write('<a href="RecruiterTracking.aspx" id="trackingNav">Candidate Tracking</a>');
}

function getMyJobsURL()
{
    /*alert('HAS_PROFILE='+readCookie('HAS_PROFILE'));
    alert('HAS_MEMBERSHIP='+readCookie('HAS_MEMBERSHIP'));
    alert('RA='+readCookie('RA'));*/
    if (readCookie('HAS_PROFILE') != '1')
    {
        document.write('<a style="color:#AAAAAA" href="#" id="postNav" onclick="alert(\'' + noProfileAlert + '\');">My Jobs</a>');
        return;
    }
        
	if (readCookie('HAS_MEMBERSHIP') != '1')
	{
		document.write('<a style="color:#AAAAAA" href="#" id="postNav" onclick="alert(\'' + noMembershipAlert + '\');">My Jobs</a>');
		return;
	}
	
	if (readCookie('RA') == '1')
	{
	    document.write('<a href="RecruiterJobs.aspx" id="postNav">My Auctions</a>');
	}
	else
		document.write('<a href="RecruiterJobs.aspx" id="postNav">My Jobs</a>');
}

function getCandidateAccountURL()
{
    if (readCookie('HAS_PROFILE') != '1')
    {
        document.write('<a style="color:#AAAAAA" href="#" id="currentAccountNav" onclick="alert(\'' + noProfileAlert + '\');">Current Account</a>');
        return;
    }
    else
        document.write('<a href="RecruiterAccount.aspx" id="currentAccountNav">Current Account</a></li><li><a href="RecruiterSettings.aspx" id="upgradeNav">Upgrade/Purchase</a>');
        
        
	//if (readCookie('CAN_SEARCH') != '1')
	//{
	//	document.write('<a style="color:#AAAAAA" href="#" id="upgradeNav" onclick="alert(\'This functionality is available after the free trial and is enabled by ERP-Consulting Management.\');">Account Settings</a>');
	//}
	//else
	//	document.write('<a href="recruiter_settings.html" id="upgradeNav">Account Settings</a>');
	//document.write('<a href="RecruiterAccount.aspx" id="currentAccountNav">Current Account</a></li><li><a href="RecruiterSettings.aspx" id="upgradeNav">Upgrade/Purchase</a>');
}

function getSavedSearchesURL()
{
    if (readCookie('HAS_PROFILE') != '1')
    {
        document.write('<a style="color:#AAAAAA" href="#" id="jobmatchNav" onclick="alert(\'' + noProfileAlert + '\');">JobMatch<sup>TM</sup></a>');
        return;
    }
    
	if (readCookie('HAS_MEMBERSHIP') != '1')
	{
		document.write('<a style="color:#AAAAAA" href="#" id="jobmatchNav" onclick="alert(\'' + noMembershipAlert + '\');">JobMatch<sup>TM</sup></a>');
		return;
	}
	
	if (readCookie('RA') == '1')
	{
	    document.write('<a style="color:#AAAAAA" href="#" id="jobmatchNav" onclick="alert(\'' + RAAlert + '\');">JobMatch<sup>TM</sup></a>');
		return;
	}
	
	if (readCookie('CAN_SEARCH') != '1')
	{
		document.write('<a style="color:#AAAAAA" href="#" id="jobmatchNav" onclick="alert(\'This functionality is available after the free trial and is enabled by ERP-Consulting Management.\');">JobMatch<sup>TM</sup></a>');
	}
	else
		//document.write('<a href="recruiter_savedSearches.html" id="jobmatchNav">JobMatch<sup>TM</sup></a>');
		document.write('<a href="RecruiterJobMatch.aspx" id="jobmatchNav">JobMatch<sup>TM</sup></a>');
}

function checkSearchOrTrackingAccess()
{
	if (readCookie('CAN_SEARCH') != '1')
	{
		alert('This functionality is available after the free trial and is enabled by ERP-Consulting Management.');
		location.href = "RecruiterProfileHome.aspx";
	}
}

// Functions used to create URL menu items for CONSULTANTS


function setHighlightedItem(name)
{
    var item = document.getElementById(name);
    if (item != null)
    {
        item.style.color = '#F2B310';
	    item.style.backgroundColor = '#FFFFFF';
	}
}

function getChangePasswordURL()
{
    if (readCookie('HAS_PROFILE') != '1')
    {
        document.write('<a style="color:#AAAAAA" href="#" id="changeNav" onclick="alert(\'' + noProfileAlert + '\');">Change Password</a>');
        return;
    }
    else
        //document.write('<a href="recruiter_password.html" id="changePassNav">Change Password</a>');   
        document.write('<a href="RecruiterChangePassword.aspx" id="changePassNav">Change Password</a>');
}

function getSignOutURL()
{
//    if (readCookie('HAS_PROFILE') != '1')
//    {
//        document.write('<a style="color:#AAAAAA" href="#" id="changeNav" onclick="alert(\'' + noProfileAlert + '\');">Sign Out</a>');
//        return;
//    }
//    else
        //document.write('<a href="logout.html" id="signOutNav">Sign Out</a>');
//      var nonSecureLocation = readCookie('SERVERURL');
//      var secureLocation = nonSecureLocation.replace("https", "http") + '/logout.aspx';
//      var newLocation = 'document.location=\'' + secureLocation + '\'';
      document.write('<a href="logout.aspx" id="signOutNav">Sign Out</a>');
      
}

