var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 1200
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        window.location = "/JobSeeker/Default.aspx"
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}


//-- Slider --//

function ChangeValue(hiddenf, value){
    hid = document.getElementById(hiddenf);
    hid.value = value;
}
function MoveSlider(parentID, value, maxValue){
    for(var i=0; i<=maxValue; i++)
    {
        curDiv = document.getElementById(parentID + "_div" + i);
        curDiv.style.backgroundColor = "";
        curDiv.style.cursor = "pointer";
        
        if (value > i-1)
            curDiv.style.backgroundColor = "#F1923E";
        if (i == value){
            curDiv.style.backgroundImage = "url(/Images/m_head_slider.gif)";
            curDiv.style.backgroundRepeat = "no-repeat";
            curDiv.style.backgroundPosition = "center right";
        }
        else {
            curDiv.style.backgroundImage = "";
        }
    }
}

function LostFocus(parentID, hiddenf, maxValue){
    hid = document.getElementById(hiddenf);
    value = hid.value;

    for(var i=0; i<=maxValue; i++)
    {
        curDiv = document.getElementById(parentID + "_div" + i);
        curDiv.style.backgroundColor = "";
        curDiv.style.cursor = "default";
        
        if (i != value || i >0)
            curDiv.style.backgroundImage = "";
            
        if (value > i-1)
            curDiv.style.backgroundColor = "#F1923E";
            
        if (i == value){
            curDiv.style.backgroundImage = "url(/Images/m_head_slider.gif)";
            curDiv.style.backgroundRepeat = "no-repeat";
            curDiv.style.backgroundPosition = "center right";
        }
    }
}

/* JobAd */
function EnableAwardBox()
{
    chkVolunteer = document.getElementById("<%=chkVolunteer.ClientID %>");
    txtUpToAward = document.getElementById("<%=txtUpToAward.ClientID %>");
            
    if(chkVolunteer.checked)
    {
        txtUpToAward.disabled = true;
    }
    else
        txtUpToAward.disabled = false;
}

/* Login panel */

function SubmitData(){
    var usr = document.getElementById("txtEmail").value;
    var pwd = document.getElementById("txtPassword").value;
  
    var divEmail = document.getElementById("divEmail");
    var divPwd = document.getElementById("divPassword");
    
    var EmailRegEx  =  new RegExp("^([a-zA-Z0-9_\.\+\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$");
   
    var valid = true;
    // validation
    if (usr.length == 0 || !EmailRegEx.test(usr)){
        divEmail.style.display = "block";
        valid = false;
    }
    else
        divEmail.style.display = "none";
        
    if (pwd.length == 0){
        divPwd.style.display = "block";
        valid = false;
    }
    else
    {
        divPwd.style.display = "none";
    }
    
	// allowSubmit is defined in the master pages to control the submission
	// of the page form.
	allowSubmit = valid;
}

/* Job Search */

function ShowSkillsRow(rowID){
    row = document.getElementById("SkillsRow" + rowID);
    lnk = document.getElementById("lnkSkills" + rowID);
    
    var browser = navigator.appName
    var display = "table-row";
    if (browser == "Microsoft Internet Explorer")
        display = "block";
        
    if (row.style.display == "none"){
        row.style.display = display;
        lnk.innerHTML = "Hide";
    }
    else {
        row.style.display = "none";
        lnk.innerHTML = "Skills";
    }
}

function showShiftsSpan(jobId)
{
	document.getElementById('spnShifts' + jobId).style.display = 'block';
}
function hideShiftsSpan(jobId)
{
	document.getElementById('spnShifts' + jobId).style.display = 'none';
}


/* Job Search (Logged in Seeker) */

function ShowSkillsRow(rowID){
    row = document.getElementById("SkillsRow" + rowID);
    lnk = document.getElementById("lnkSkills" + rowID);
    
    var browser = navigator.appName
    var display = "table-row";
    if (browser == "Microsoft Internet Explorer")
        display = "block";
        
    if (row.style.display == "none"){
        row.style.display = display;
        lnk.innerHTML = "Hide";
    }
    else {
        row.style.display = "none";
        lnk.innerHTML = "Skills";
    }
}

function ShowFeedbackRow(rowID){
    row = document.getElementById("FeedbackRow" + rowID);
    lnk = document.getElementById("lnkFeedback" + rowID);
    
    var browser = navigator.appName
    var display = "table-row";
    if (browser == "Microsoft Internet Explorer")
        display = "block";
        
    if (row.style.display == "none"){
        row.style.display = display;
        lnk.innerHTML = "Hide";
    }
    else {
        row.style.display = "none";
        lnk.innerHTML = "Feedback";
    }
}

function showShiftsSpan(jobId)
{
	document.getElementById('spnShifts' + jobId).style.display = 'block';
}
function hideShiftsSpan(jobId)
{
	document.getElementById('spnShifts' + jobId).style.display = 'none';
}
	
	
/* Job Availability Locations */	
function ConfirmLocationDelete()
{
	return confirm('Removing this location will erase any availability entered for that area. Are you sure you wish to proceed?');
}

/* trime string */
function trimstr(original) {
    return original.replace(/(^[\s\xA0]+|[\s\xA0]+$)/g, '');
};