// BEGIN Date Functions 

var tDays = new Array();
tDays[0] = "Sunday";
tDays[1] = "Monday";
tDays[2] = "Tuesday";
tDays[3] = "Wednesday";
tDays[4] = "Thursday";
tDays[5] = "Friday";
tDays[6] = "Saturday";

var tMons = new Array();
tMons[0] = "January";
tMons[1] = "February";
tMons[2] = "March";
tMons[3] = "April";
tMons[4] = "May";
tMons[5] = "June";
tMons[6] = "July";
tMons[7] = "August";
tMons[8] = "September";
tMons[9] = "October";
tMons[10] = "November";
tMons[11] = "December";


function writeDate( whatToReturn ) {
	var dDate = new Date();
	var today;
	
	// append day
	today = tDays[dDate.getDay()];
	// append short month
	today += ", " + tMons[dDate.getMonth()];
	// append date
	today += " " + dDate.getDate();
	// append long year
	
	today += (dDate.getYear()<2000) ? " " + (dDate.getYear()+1900) : " " + dDate.getYear();
		
	if ( whatToReturn == "year" ) {
	  document.write( (dDate.getYear()<2000) ? " " + (dDate.getYear()+1900) : " " + dDate.getYear() );
	} else {	
	  document.write( today );
	}
}
// END Date Functions

// quick-search directing  
function submitSearch() {
      document.forms['college_search'].submit();
}

function submitKeywordSearch() {
	changeSearchOptions();	
	var qField = document.forms['keywordSearch'].searchWhat.value;
	if ( qField == 'Job Titles' ) {
	  qField = 'Title';
	} else {
          qField = 'All';
        }

	var submitString = "http://cjcol.careercast.com/texis/js?"
			+ "q=" + escape( document.forms['keywordSearch'].keywords.value ) 
			+ "&qField=" + qField 
			+ "&dominantKey=" + escape( document.forms['keywordSearch'].jobTypes.value );

	location.href = submitString;
}

function changeSearchOptions() {
	document.forms['keywordSearch'].searchWhat.value = document.forms['keywordSearchOptions'].searchWhat.value;	
	
	if ( document.forms['keywordSearchOptions'].jobTypes != null ) {	
	  document.forms['keywordSearch'].jobTypes.value = document.forms['keywordSearchOptions'].jobTypes.value;	
	}
}

// sidebar pop-up windows
function popSidebar(url) {
	var target = url;
	var winName = 'cjSidebar';
	var winParams = 'WIDTH=410,HEIGHT=500,SCROLLBARS=yes,TOOLBAR=0,PERSONALBAR=0,STATUSBAR=1,RESIZABLE';
	//var winParams = 'WIDTH=410,HEIGHT=500,SCROLLBARS=yes,TOOLBAR=0,PERSONALBAR=0,STATUSBAR=1,NORESIZE';
   
   window.open( target, winName, winParams);
}

// resume pop-up windows
function popResSidebar(url) {
	var target = url;
	var winName = 'cjSidebar';
	var winParams = 'WIDTH=700,HEIGHT=700,SCROLLBARS=yes,TOOLBAR=0,PERSONALBAR=0,STATUSBAR=1,RESIZABLE';
	//var winParams = 'WIDTH=700,HEIGHT=700,SCROLLBARS=yes,TOOLBAR=0,PERSONALBAR=0,STATUSBAR=1,NORESIZE';
   
   window.open( target, winName, winParams);
}

// franchise pop-up windows
function popFranchise(url) {
	var target = 'http://www.collegejournal.com/franchise/companies/'+url;
	var winName = 'sjFranchise';
	var winParams = 'WIDTH=330,HEIGHT=330,SCROLLBARS=yes,TOOLBAR=0,PERSONALBAR=0,STATUSBAR=1,RESIZABLE';
	//var winParams = 'WIDTH=410,HEIGHT=430,SCROLLBARS=yes,TOOLBAR=0,PERSONALBAR=0,STATUSBAR=1,NORESIZE';
   
   window.open( target, winName, winParams);
}

// email pop-up window
function popEmail() {
	var target = 'http://www.collegejournal.com/forms/emailForm.asp?url='+escape(document.location);
	var winName = 'print';
	var winParams = 'WIDTH=440,HEIGHT=354,SCROLLBARS=no,TOOLBAR=0,PERSONALBAR=0,STATUSBAR=1,NORESIZE';
	
	window.open( target, winName, winParams);
}

// print pop-up window
function popPrint() {
	var target = 'http://www.collegejournal.com/forms/printContent.asp?url='+escape(document.location);
	var winName = 'print';
	var winParams = 'WIDTH=660,SCROLLBARS=yes,TOOLBAR=1,PERSONALBAR=0,STATUSBAR=1,RESIZABLE';
	
	window.open( target, winName, winParams);
}

// content pop-up windows
function popContent(url,width,height) {
	var target = url;
   var w;
   var h;

   w = ( width ) ? width : 410;
   h = ( height ) ? height : 430;

	var winName = 'cjContent';
	var winParams = 'WIDTH='+w+',HEIGHT='+h+',SCROLLBARS=yes,TOOLBAR=0,PERSONALBAR=0,STATUSBAR=1,RESIZABLE';
   
   window.open( target, winName, winParams);
}

// sidebar for bskool03 top ten list
function topTen(url) {
	var target = url;
	var winName = 'MyTopTen';
	var winParams = 'WIDTH=630,HEIGHT=500,SCROLLBARS=yes,TOOLBAR=0,PERSONALBAR=0,STATUSBAR=1,RESIZABLE';
   
   window.open( target, winName, winParams);
}

function breakFrameset() {
   // ditch out if partner is including
   if ( location.hostname != "www.startupjournal.com" 
   &&  location.hostname != "startupjournal.com" ) {
      return;
   }

   if ( top.location.href != self.location.href ) {
      top.location.href = self.location.href;
   }
   return;
}
