function openPopUp(location, height, width)
{
	window.open(location, '', config='height=' + height + ', width=' + width + ', toolbar=no, menubar=no, scrollbars=no, resizable=yes, location=no, directories=no, status=no');
}


function followLink(evt, name)
{
	evt = (evt) ? evt : event;
			
	var target = (evt.target) ? evt.target : evt.srcElement;
	
	var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
		
	if (charCode == 13 || charCode == 3) {
			WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('ctl00$main$ctrlpagearea$lnkSearch', '', true, '', '', false, true));
			return false;
	}
	
	return true;
}

function logout()
{
    window.location = baseLocation + "admin/login.aspx";
    return false;
}

function changePassword()
{
    window.location = baseLocation + "admin/admin/resetpassword.aspx";
    return false;
}

function displayMenu(menuId, iconId)
{
	var obj = document.getElementById(menuId);
	var img = document.getElementById(iconId);
	
	if(obj == null)
	{
		return;
	}
	
	if(img == null)
	{
		return;
	}
	
	if(obj.style.display == "none")
	{
		img.src = baseLocation +  "images/minus.jpg";
		obj.style.display = "block";
	}
	else
	{
		img.src = baseLocation +  "images/plus.jpg";
		obj.style.display = "none";
	}	
}

function displayVacancy()
{
    displayMenu("vacancyManagement", "vacIcon");
}

function displayApplicant()
{
    displayMenu("applicantManagement", "appIcon");
}

function displayTalentPool()
{
    displayMenu("talentManagement", "talentIcon");
}

function displayRedeploy()
{
    displayMenu("redeployManagement", "redeployIcon");
}

function displayReporting()
{
    displayMenu("reportingManagement", "reportIcon");
}

function displayAdmin()
{
    displayMenu("adminManagement", "adminIcon");
}

function displayUserAdmin()
{
    displayMenu("userAdminManagement", "userAdminIcon");
}

function displayJGPTech()
{
    displayMenu("jgptechManagement", "jgptechIcon");
}

function displayCCAdmin()
{
    displayMenu("ccAdminManagement", "userCCIcon");
}

function viewApplicantList(url, ctrlId)
{
    var ctrl = document.getElementById(ctrlId);
    
    if(ctrl == null)
    {
        return true;
    }
    
    if(ctrl.value == "-1")
    {
        return false;
    }
    
    url = baseLocation + url + ctrl.value;
    
    window.location = url;
    
    return false;
}

function viewVacancyAction(jobId, ctrlId)
{
    var ctrl = document.getElementById(ctrlId);
    
    if(ctrl == null)
    {
        return true;
    }
    
    if(ctrl.value == "-1")
    {
        return false;
    }
    
    window.location = baseLocation + ctrl.value + "?jobid=" + jobId;
   
    return false;
}

function viewApplicantListButton(jobId, url)
{
    window.location = baseLocation + url + "?jobid=" + jobId;
    return false;
}

function viewApplicationAction(qs, ctrlId)
{
    var ctrl = document.getElementById(ctrlId);
    
    if(ctrl == null)
    {
        return true;
    }
    
    if(ctrl.value == "-1")
    {
        return false;
    }
    
    var index = new String(ctrl.value).indexOf("?");
       
    if(index == -1)
    {
        qs = "?" + qs;
    }
    else
    {
        qs = "&" + qs;
    }
    
    window.location = baseLocation + ctrl.value + qs;
   
    return false;
}

function viewApplicantAction(qs, ctrlId)
{
    var ctrl = document.getElementById(ctrlId);
    
    if(ctrl == null)
    {
        return true;
    }
    
    if(ctrl.value == "-1")
    {
        return false;
    }
    
    var index = new String(ctrl.value).indexOf("?");
       
    if(index == -1)
    {
        qs = "?appid=" + qs;
    }
    else
    {
        qs = "&appid=" + qs;
    }
    
    window.location = baseLocation + ctrl.value + qs;
   
    return false;
}

function displayAreaStartup(ctrlArea, ctrlButton)
{
	var obj = document.getElementById(ctrlArea);
	
	if(obj != null)
	{
		obj.style.display = "none";
	}
	
	obj = document.getElementById(ctrlButton);
	
	if(obj != null)
	{
		obj.style.display = "block";
	}
}

function displayArea(ctrlArea, ctrlButton, ctrlClose)
{
	var obj = document.getElementById(ctrlArea);
	var btn = document.getElementById(ctrlButton);
	var close = document.getElementById(ctrlClose);
	
	if(obj == null)
	{
		return;
	}
	
	if(btn == null)
	{
		return;
	}
	
	if(close != null)
	{
	    close.style.display = "inline";
	}
	
	if(obj.style.display == "none")
	{
		obj.style.display = "block";
		btn.style.display = "none";
	}
	else
	{
		obj.style.display = "none";
		btn.style.display = "block";
	}	
}


function printApplications(url)
{
    var ids = "";
    var table = document.getElementById("applicantList");
    
    for(var i = 0; i< table.rows.length;i++)
    {
        var row = table.rows[i];
        var cell = row.cells[row.cells.length - 1];
                
        if(cell.childNodes.length == 5)
        {
            for(var y=0;y<cell.childNodes.length;y++)
            {
                var ctrl = cell.childNodes[y];
                
                if(ctrl.tagName == "INPUT")
                {
                    if(ctrl.type == "checkbox")
                    {
                        if(!ctrl.checked)
                        {
                            break;
                        }
                    }
                    else if(ctrl.type == "hidden")
                    {
                        ids += ctrl.value + ",";
                    }
                }
            }
        }
        else if(cell.childNodes.length == 4)
        {
           for(var y=0;y<cell.childNodes.length;y++)
            {
                var ctrl = cell.childNodes[y];
                
                if(ctrl.tagName == "INPUT")
                {
                    if(ctrl.type == "checkbox")
                    {
                        if(!ctrl.checked)
                        {
                            break;
                        }
                    }
                    else if(ctrl.type == "hidden")
                    {
                        ids += ctrl.value + ",";
                    }
                }
            }
        }
    }
    
    if(new String(ids).length == 0)
    {
        alert("Please select a least one applicant");
        return false;
    }
    
    printSelector(url + ids + "&type=");
    
    return false;
}

var printUrl = "";

function changedPreviewValue()
{
}

function previewHtml()
{
    var value = document.getElementById(previewSelector).value;
    window.open(printUrl + value);
}

function previewPDF()
{
    var value = document.getElementById(previewSelector).value;
    window.location = "applicationformpdf.axd?name=applicationform.pdf&url=" + escape(printUrl) + value;
}


function PreventSubmitOnKeyPress(sObjectID) {
    try {
        if (!document.all) {
            var oObject = document.getElementById(sObjectID);
           
            if (oObject.addEventListener) { 
                oObject.parentNode.addEventListener("keypress",
                    function(e) {
                        if (e && e.keyCode && e.keyCode==13) {
                            e.stopPropagation();
                        }
                    }, false); 
            } 
        }
    } catch (e) {}
}

function attachAllTextAreas()
{
    var items = document.getElementsByTagName("textarea");
    
    for(i=0;i<items.length;i++)
    {
        PreventSubmitOnKeyPress(items[i].id);
    }
}

function toggleLogReg(obj){
    if (obj.id== 'aLogin'){
        document.all.divLoginUi.className='';
        document.all.divSignup.className='invisi';
    }
    else{
        document.all.divSignup.className='';
        document.all.divLoginUi.className='invisi';
    }
    
}