// BEGIN ADDREMOVE CATEGORY CONFIRMATION DIALOG

function confirmSQChange() {
	if (confirm("This requisition is open. Changes could affect current job board postings. Do you wish to proceed anyways?") )
		{alert("Dev Note: The popup would then appear, the modification would then be made, and would be visible on the refreshed parent page.");
		}
}
// END ADD/REMOVE CATEGORY CONFIRMATION DIALOG

// BEGIN CHECK FOR ADD SCREENING QUESTION SHOW/HIDE FIELDS
function showMultiSelect() {
	document.getElementById("multiselect").style.display = "block";
}
function hideMultiSelect() {
	document.getElementById("multiselect").style.display = "none";
}
function checkSelection() {
var pick = addquestionform.typeselect.options[addquestionform.typeselect.selectedIndex].value;
	if (pick == "single-select") {
		showMultiSelect();
	}
	else if (pick == "multi-select") {
		showMultiSelect();
	}
	else {
		hideMultiSelect();
	}
}
	
// END CHECK FOR ADD SCREENING QUESTION POST SHOW/HIDE FIELDS


// BEGIN CHECK FOR HOTJOBS POST SHOW/HIDE FIELDS
function showHotJobsFields() {
	document.getElementById("hotjobsfields").style.display = "block";
}
function hideHotJobsFields() {
	document.getElementById("hotjobsfields").style.display = "none";
}
// END CHECK FOR HOTJOBS POST SHOW/HIDE FIELDS


// BEGIN GO TO URL FROM ACTION MENUS 
function go2PopupNew() {
if (document.candtraform.candtramenu.selectedIndex == 3)
	{window.location=document.candtraform.candtramenu.options[document.candtraform.candtramenu.selectedIndex].value
	}
else 
	{
	window.open(document.candtraform.candtramenu.options[document.candtraform.candtramenu.selectedIndex].value,'popupwindow','height=320,width=400,resizable=yes,scrollbars=yes')
	}
}


function go2PopupTracked() {
if (document.candtraform.candtramenu.selectedIndex == 1)
	{window.location=document.candtraform.candtramenu.options[document.candtraform.candtramenu.selectedIndex].value
	}
else 
	{
	window.open(document.candtraform.candtramenu.options[document.candtraform.candtramenu.selectedIndex].value,'popupwindow','height=420,width=400,resizable=yes,scrollbars=yes')
	}
}



function go2PopupNoInt() {
if (document.candtraform.candtramenu.selectedIndex == 1)
	{window.location=document.candtraform.candtramenu.options[document.candtraform.candtramenu.selectedIndex].value
	}
else 
	{
	window.open(document.candtraform.candtramenu.options[document.candtraform.candtramenu.selectedIndex].value,'popupwindow','height=320,width=400,resizable=yes,scrollbars=yes')
	}
}

function go2ReqInt() {
window.location=document.reqintform.reqintmenu.options[document.reqintform.reqintmenu.selectedIndex].value
}

function go2ReqTra() {
window.location=document.reqtraform.reqtramenu.options[document.reqtraform.reqtramenu.selectedIndex].value
}

function go2ReqNM() {
window.location=document.reqnmform.reqnmmenu.options[document.reqnmform.reqnmmenu.selectedIndex].value
}

function go2CandInt() {
window.location=document.candintform.candintmenu.options[document.candintform.candintmenu.selectedIndex].value
}

function go2CandTra() {
window.location=document.candtraform.candtramenu.options[document.candtraform.candtramenu.selectedIndex].value
}

// END GO TO URL FROM ACTION MENUS 

// BEGIN FIND REQ
function findReq(){
var pick = headerform.findreq.value;
	if (pick == "PROD123")
		{window.location="req_home.html";} 
	else if (pick == "prod123")
		{window.location="req_home.html";} 
	else if (pick == "Prod123")
		{window.location="req_home.html";} 
	else if (pick == "PROD122")
		{window.location="req_home_2.html";}
	else if (pick == "prod122")
		{window.location="req_home_2.html";} 
	else if (pick == "Prod122")
		{window.location="req_home_2.html";} 
}
// END FIND REQ

// BEGIN FIND CAND
function findCand(){
var pick = headerform.findcand.value;
	if (pick == "Booth")
		{window.location="cand_home.html";} 
	else if (pick == "booth")
		{window.location="cand_home.html";} 
	else if (pick == "BOOTH")
		{window.location="cand_home.html";} 
	else if (pick == "Smith")
		{window.location="cand_home_2.html";}
	else if (pick == "SMITH")
		{window.location="cand_home_2.html";}
	else if (pick == "smith")
		{window.location="cand_home_2.html";}
}
// END FIND CAND

//  BEGIN JAVASCRIPT TRACK CONFIRM DIALOG - POPUP
// part one, popup the Bryan Booth window
var newwindow = '';

function popitup(url)
{
	if (!newwindow.closed && newwindow.location)
	{
		newwindow.location.href = url;
	}
	else
	{
		newwindow=window.open(url,'name','height=600,width=800,screenX=0,left=0,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0');
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
}

// part two, change the location of the parent window
function trackConfirmPopup() {
var answer = confirm ("Candidate Bryan Booth has been tracked to PROD123. Please click OK to perform an activity on Bryan Booth now, or Cancel to stay on the current page.");
if (answer)
	{
	opener.location.href="cand_track_detail.html";
	this.window.close();
	}
else {
	this.window.close();
	}
}
//  END JAVASCRIPT TRACK CONFIRM DIALOG - POPUP

//  BEGIN JAVASCRIPT NO INTEREST CONFIRM DIALOG - POPUP

function noInterestConfirmPopup() {
alert ("You have indicated No Interest in Gene Gomez. This candidate will be moved to under the No Interest tab.");
window.close();
}
//  END JAVASCRIPT NO INTEREST CONFIRM DIALOG - POPUP

//  BEGIN JAVASCRIPT NO INTEREST CONFIRM DIALOG 2 - POPUP

function noInterestConfirmPopup2() {
alert ("You have indicated No Interest in Rachel Munica. This candidate will be moved to under the No Interest tab.");
window.close();
}
//  END JAVASCRIPT NO INTEREST CONFIRM DIALOG 2 - POPUP

//  BEGIN JAVASCRIPT TRACK CONFIRM DIALOG - COMPARE CANDIDATES

function trackConfirm() {
var answer = confirm ("Candidate Bryan Booth has been tracked to PROD123. Please click OK to perform an activity on Bryan Booth now, or Cancel to stay on the current page.");
if (answer)
	{
	window.location="cand_track_detail.html";
	}
}
//  END JAVASCRIPT TRACK CONFIRM DIALOG - COMPARE CANDIDATES


//  BEGIN JAVASCRIPT NO INTEREST CONFIRM DIALOG - COMPARE CANDIDATES

function noInterestConfirm() {
var answer = confirm ("You have indicated No Interest in Gene Gomez. This candidate has been moved to under the No Interest tab in the Candidate Pool. Please click OK to return to the Req PROD123 Candidate Pool, or Cancel to stay on the current page.");
if (answer)
	{
	window.location="req_cand_pool_new.html";
	}
}
//  END JAVASCRIPT NO INTEREST CONFIRM DIALOG - COMPARE CANDIDATES

//  BEGIN JAVASCRIPT NO INTEREST CONFIRM DIALOG 2 - COMPARE CANDIDATES

function noInterestConfirm2() {
var answer = confirm ("You have indicated No Interest in Rachel Munica. This candidate has been moved to under the No Interest tab in the Candidate Pool. Please click OK to return to the Req PROD123 Candidate Pool, or Cancel to stay on the current page.");
if (answer)
	{
	window.location="req_cand_pool_new.html";
	}
}
//  END JAVASCRIPT NO INTEREST CONFIRM DIALOG 2 - COMPARE CANDIDATES






// BEGIN STYLE SHEET SWITCHER
// http://www.alistapart.com/stories/alternate/
// 
function setActiveStyleSheet(title) {
  var i, a, main;
  if (title == "null")
  {title = "default"};
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

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;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

// END STYLE SHEET SWITCHER

	
// BEGIN GO TO LAST FIVE
function quickSearch(){
var pick = searchform.last5menu.options[searchform.last5menu.selectedIndex].value;
	if (pick == "PROD123")
		{window.location="req_home.html";} 
	else if (pick == "PROD122")
		{window.location="req_home_2.html";}
}
// END GO TO LAST FIVE



// BEGIN AUTOMATIC PULLDOWN MENU
function formHandler(form){
var URL = document.form.site.options[document.form.site.selectedIndex].value;
window.location.href = URL;
}
// END AUTOMATIC PULLDOWN MENU

// BEGIN CHECK INTEREST SELECTION AND SHOW/HIDE NO INTEREST MENU
function showInterest() {
	nointerest.style.display = "inline";
}
function hideInterest() {
	nointerest.style.display = "none";
}
// END CHECK INTEREST SELECTION AND SHOW/HIDE NO INTEREST MENU

// BEGIN LAUNCH NEW WINDOW WITH FOCUS
var newwin;
function launchwin(winurl,winname,winfeatures)
{
	newwin = window.open(winurl,winname,winfeatures);
	setTimeout('newwin.focus();',250);
}
// END LAUNCH NEW WINDOW WITH FOCUS


// BEGIN CALENDAR CONTROL
// Title: Timestamp picker
// Description: See the demo at url
// URL: http://www.geocities.com/tspicker/
// Version: 1.0.a (Date selector only)
// Date: 12-12-2001 (mm-dd-yyyy)
// Author: Denis Gritcyuk <denis@softcomplex.com>; <tspicker@yahoo.com>
// Notes: Permission given to use this script in any kind of applications if
//    header lines are left unchanged. Feel free to contact the author
//    for feature requests and/or donations
function show_calendar4(str_target, str_datetime) {
   show_calendar('', str_target, str_datetime);
}

function show_calendar(image_dir, str_target, str_datetime) {
        var app = navigator.appVersion;
        var safari = false;
        if(app.indexOf('Safari') != -1) {
          safari  = true;
        }
	var arr_months = ["January", "February", "March", "April", "May", "June",
		"July", "August", "September", "October", "November", "December"];
	var week_days = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
	var n_weekstart = 0; // day week starts from (normally 0 or 1)


/**************BEGIN JOHN CHANG FIX FOR SAFARI*****************************/
        var dt_datetime;
        if(!safari) {
            dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt4(str_datetime,safari));
        } else {
            if(str_datetime==null || str_datetime=="") {
                tempDate = new Date();
                str_datetime = (tempDate.getMonth()+1) + "/" + tempDate.getDate() + "/" + (1900+tempDate.getYear());
            } 
            dt_datetime = str2dt4( str_datetime,safari );
        }
/**************END JOHN CHANG FIX FOR SAFARI*****************************/

	var dt_prev_month = new Date(dt_datetime);
/**************BEGIN JOHN CHANG FIX FOR SAFARI*****************************/
        if(!safari) {
	    dt_prev_month.setMonth(dt_prev_month.getMonth()-1);
        } else {
            if(dt_prev_month.getMonth() != 0) {
                dt_prev_month.setMonth(dt_prev_month.getMonth()-1);
            } else {
                dt_prev_month.setMonth(11);
                dt_prev_month.setYear(dt_prev_month.getYear()-1);
            }
        }
/**************END JOHN CHANG FIX FOR SAFARI*****************************/
	var dt_next_month = new Date(dt_datetime);
	dt_next_month.setMonth(dt_datetime.getMonth()+1);
	var dt_firstday = new Date(dt_datetime);
	dt_firstday.setDate(1);
	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
	var dt_lastday = new Date(dt_next_month);
	dt_lastday.setDate(0);
	
	// html generation (feel free to tune it for your particular application)
	// print calendar header
	var str_buffer = new String (
		"<html>\n"+
		"<head>\n"+
		"	<title>Calendar</title>\n"+
		"</head>\n"+
		"<body bgcolor=\"White\">\n"+

		"<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
		"<tr><td bgcolor=\"#000000\">\n"+
		"<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
		"<tr>\n	<td bgcolor=\"#000000\"><a href=\"javascript:window.opener.show_calendar('"+image_dir+"','" +
		str_target+"', '"+ dt2dtstr4(dt_prev_month)+"');\">"+
		"<img src=\""+image_dir+"prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"previous month\"></a></td>\n"+

		"	<td bgcolor=\"#000000\" colspan=\"5\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
		+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n"+
		"	<td bgcolor=\"#000000\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('" + image_dir+"','" +
		str_target+"', '"+dt2dtstr4(dt_next_month)+"');\">"+
		"<img src=\""+image_dir+"next.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"next month\"></a></td>\n</tr>\n"
	);

	var dt_current_day = new Date(dt_firstday);
	// print weekdays titles
	str_buffer += "<tr>\n";
	for (var n=0; n<7; n++)
		str_buffer += "	<td bgcolor=\"#A797B4\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+
		week_days[(n_weekstart+n)%7]+"</font></td>\n";
	// print calendar table
	str_buffer += "</tr>\n";
	while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
		dt_current_day.getMonth() == dt_firstday.getMonth()) {
		// print row header
		str_buffer += "<tr>\n";
		for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
				if (dt_current_day.getDate() == dt_datetime.getDate() &&
					dt_current_day.getMonth() == dt_datetime.getMonth())
					// print current date
					str_buffer += "	<td bgcolor=\"#EEE7CC\" align=\"right\">";
				else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
					// weekend days
					str_buffer += "	<td bgcolor=\"#999999\" align=\"right\">";
				else
					// print working days of current month
					str_buffer += "	<td bgcolor=\"white\" align=\"right\">";

				if (dt_current_day.getMonth() == dt_datetime.getMonth())
					// print days of current month
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr4(dt_current_day)+"'; window.close();\">"+
					"<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
				else 
					// print days of other months
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr4(dt_current_day)+"'; window.close();\">"+
					"<font color=\"#999999\" face=\"tahoma, verdana\" size=\"2\">";
				str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
				dt_current_day.setDate(dt_current_day.getDate()+1);
		}
		// print row footer
		str_buffer += "</tr>\n";
	}
	// print calendar footer
	str_buffer +=
		"</table>\n" +
		"</tr>\n</td>\n</table>\n" +
		"</body>\n" +
		"</html>\n";

	var vWinCal = window.open("", "Calendar", 
		"width=200,height=250,status=no,resizable=yes,top=200,left=200");
	vWinCal.opener = self;
	vWinCal.focus();
	var calc_doc = vWinCal.document;
	calc_doc.write (str_buffer);
	calc_doc.close();

}
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt4 (str_datetime,safari) {
/**************BEGIN JOHN CHANG FIX FOR SAFARI*****************************/
/**when you try to instantiate a date in after about year, 2036 safari  ***/
/**will hang.  So, we have to catch that & force dates to current  day  ***/
/**John Chang's work-around below******************************************/
    if(!safari) {
            var re_date = /^(\d+)\/(\d+)\/(\d+)$/;
            if (!re_date.exec(str_datetime)) { 
                return new Date();
                //return alert("Invalid Datetime format: "+ str_datetime);
            }
            return (new Date (RegExp.$3, RegExp.$1-1, RegExp.$2));
    } else {
            var year = "";
            var month = "";
            var date = "";
            slashFound = 0;
            for(var i=0;i<str_datetime.length;i++) {
                if('/' == str_datetime.charAt(i)) {
                    slashFound++;
                    continue;
                }
                if(slashFound==0) {
                    month = month + str_datetime.charAt(i);  
                } else if(slashFound==1) {
                    date = date + str_datetime.charAt(i);  
                } else {
                    year = year + str_datetime.charAt(i);  
                }
            }
            month = month-1;
            if(isNaN(year)) {
                return new Date();
            } else {
                if(year > 2035 || year < 1970) {
                    return new Date();
                }
            }
            return (new Date (year, month , date ));
    }
}
function dt2dtstr4 (dt_datetime) {
// format return date as mm/dd/yyyy
//	return (new String (
//			(dt_datetime.getMonth()+1)+"/"+dt_datetime.getDate()+"/"+dt_datetime.getFullYear()));
 var mm = new String(dt_datetime.getMonth()+1) ;
 if(mm.length==1) mm = "0" + mm;
 var dd = new String(dt_datetime.getDate());
 if(dd.length==1) dd= "0" + dd;
 var ret =new String(mm + "/" + dd + "/" + dt_datetime.getFullYear());
 return ret;
 
}

// END CALENDAR CONTROL


