﻿// Jobs.roanoke.com JavaScript
// Created 12/03/06

/*Jobs Page-Tabs*/
function setJobFocus(b){
    var bxs=['seekerlogin','emplogin','product'];
    for (var i=0;i<bxs.length;i++) {
        var bx=document.getElementById('jobtabs-'+bxs[i]);
        var lk=document.getElementById(bxs[i]+'-lnk');
        if (b==bxs[i]){
            bx.style.display='block';
            lk.className='current';
         }else{
            bx.style.display='none';
            lk.className='';
        }
    }
}

//Employer Profile Videos - ****Employers with Videos only
	currentIndx=0;
	//all the images and their urls 
	//this is the only section that needs to be modified
	imgArray = new Array()
	imgArray[0] = ['http://www.roanoke.com/images/v2005/richfield.jpg', 'http://www.roanoke.com/job/employerProfile/employer/211247'];
	imgArray[1] = ['http://www.roanoke.com/images/v2005/express.jpg', 'http://www.roanoke.com/job/employerProfile/employer/213649'];
	imgArray[2] = ['http://www.roanoke.com/images/v2005/bner.jpg', 'http://www.roanoke.com/job/employerProfile/employer/211358'];
	imgArray[3] = ['http://www.roanoke.com/images/v2005/brightservices.jpg', 'http://www.roanoke.com/job/employerProfile/employer/213640'];
	imgArray[4] = ['http://www.roanoke.com/images/v2005/blueridge2.jpg', 'http://www.roanoke.com/job/employerProfile/employer/212485'];
	imgArray[5] = ['http://www.roanoke.com/images/v2005/RTjobsSponsor.jpg', 'http://www.roanoke.com/job/employerProfile/employer/210886'];
	imgArray[6] = ['http://www.roanoke.com/images/v2005/vt_employment_sponsor.JPG', 'http://www.roanoke.com/job/employerProfile/employer/211357'];
	imgArray[7] = ['http://www.roanoke.com/images/v2005/warmHearth.jpg', 'http://www.roanoke.com/job/employerProfile/employer/212482'];
	imgArray[8] = ['http://www.roanoke.com/images/v2005/Sentara_Stacked.gif', 'http://www.roanoke.com/job/employerProfile/employer/253577'];
	//imgArray[] = ['http://www.roanoke.com/images/v2005/townofblacksburg.JPG', 'http://www.roanoke.com/job/employerProfile/employer/213646'];
    //imgArray[] = ['http://www.roanoke.com/images/v2005/roanoke_city.jpg', 'http://www.roanoke.com/job/employerProfile/employer/213647'];
    //imgArray[] = ['http://www.roanoke.com/images/v2005/wytheCountyHospital.jpg', 'http://www.roanoke.com/job/employerProfile/employer/213648'];
	
	
	
	//randomly select the order of the 
	var imgOrderArray = new Array();
	
	while (imgOrderArray.length != imgArray.length) {
	    intSeed = (Math.round(Math.random()*(imgArray.length-1)));
	    blnFound = false;
	    for (i=0; i<imgOrderArray.length; i++) {
	        if (imgOrderArray[i] == intSeed) {
	            i = imgOrderArray.length;
	            blnFound = true;
	        }
	    }
	    
	    if (!blnFound) imgOrderArray[imgOrderArray.length] = intSeed;
	}
	
	//load the images into the arrays
	var MyImagesVideo = new Array();
	//var MyImagesVideo2 = new Array();
	
	var Links = new Array();
	//var Links2 = new Array();
	
	//var blnLeft = true;
	
	for (i=0; i<imgOrderArray.length; i++) 
	
	    {
	        MyImagesVideo[i] = imgArray[imgOrderArray[i]][0];
	        Links[i] = imgArray[imgOrderArray[i]][1];
	        blnLeft = true;
	       
	    } 
	
	
	
	//preload images
	imagesPreloaded = new Array();
	 
	for (var i = 0; i < MyImagesVideo.length  ; i++) 	{
	    imagesPreloaded[i] = new Image(180,145)	
	    imagesPreloaded[i].src=MyImagesVideo[i]
	 
	 }
	 
	function init(){
	
	document.theImageVideo.src=imagesPreloaded[0].src	
	document.getElementById('imageLinkVideo').href=Links[0];	
	}
	
	function NexterVideo(){ 
	if (currentIndx < imagesPreloaded.length-1){
	
	
	/* the length of our array is 2. But the images go from 0 to 1, so we take one off the count. (We made currentIndx equal 0 right at the beginning of our script!) */
	
	currentIndx=currentIndx+1;
	
	/* To go forward, we add one, providing the number is less than the number of images */
	
	document.theImageVideo.src=imagesPreloaded[currentIndx].src
	
	/* The NAME of the image in our slide show is theImageVideo. We can change the image loaded here as above */
	
	document.getElementById('imageLinkVideo').href=Links[currentIndx];
	
	}
	
	else {
	
	currentIndx=0
	
	/* Otherwise, we go back to the beginning, if currentIndx is too big */
	
	document.theImageVideo.src=imagesPreloaded[currentIndx].src
	
	
	document.getElementById('imageLinkVideo').href=Links[currentIndx];
	
	}
	
	}
	
	/* The function Backer() is similar to the previous function, so it contains no comments */
	
	function BackerVideo(){
	
	if (currentIndx>0){
	
	currentIndx=currentIndx-1;
	
	document.theImageVideo.src=imagesPreloaded[currentIndx].src
	
	
	document.getElementById('imageLinkVideo').href=Links[currentIndx];
	
	}
	
	else {
	
	currentIndx=1
	
	document.theImageVideo.src=imagesPreloaded[currentIndx].src
	
	document.getElementById('imageLinkVideo').href=Links[currentIndx];
	
	}
	    }
    
//End Sponsored Jobs

    
//Job Clips
    /***********************************************
* Teaser Scroll Media Player Script - Copyright World Wide Broadcast Network,Inc. (www.wwbn.com)
* This notice MUST stay intact for legal use
* Visit World Wide Broadcast Network,Inc. at http://wwbn.com
***********************************************/
	//Variables Begin
	//Box Variables
	function jobclips(){
		WWBN_BoxWidth = "280";															// Set the player width here
	WWBN_BoxHeight = "545";															// Set the player height here
	WWBN_BoxOutlineSize = "2px";													// Set the box outline size in pixels here
	WWBN_BoxOutlineColor = "#FFFFFF";												//Set the box outline color here
	WWBN_BoxBGNDColor = "#FFFFFF";													//Set the box backgroung color here
	WWBN_BoxBGNDImageURL = "";														//Set the box backgroung image here
	//Banner Variables
	WWBN_ShowBanner = true;															// Show Image Banner  (true, false)
	WWBN_BannerTop = "1px";															// Set the top position of the Image Banner here
	WWBN_BannerLeft = "2px";														//Set the left position of the Image Banner here
	WWBN_BannerImageURL = "http://adfare09.adfare.com/ads/roanoke/jobclips/topper.jpg";		//Set the URL to the banner image here
	//Title Variables
	WWBN_ShowTitle = false;															// Show Title Bar (true, false)
	WWBN_TitleTextColor = "#000000";												// Set the Title text Color here
	WWBN_TitleText = "Your title here"; 											// Type the Title Text here
	WWBN_TitleTextSize = "3";
	WWBN_TitleTextFont = "arial";
	WWBN_TitleBGNDColor = "#FFFFFF";
	WWBN_TitleBGNDSize = "116px";
	WWBN_TitleBGNDPad = "2px";
	WWBN_TitleAlignment = "Left";
	WWBN_TitleTopPos = "0";
	WWBN_TitleLeftPos = "0";
	//Header Variables
	WWBN_ShowHeader = false;														// Show Header Bar (true, false)
	WWBN_HeaderText = "Your header here"; 											// Type the Header Text here
	WWBN_HeaderTextSize = "2"; 														// Set the Header Text Size
	WWBN_HeaderTextFont = "arial";
	WWBN_HeaderTextColor = "#0000ff";
	WWBN_HeaderBGNDColor = "#000000";
	WWBN_HeaderBGNDSize = "116px";
	WWBN_HeaderBGNDPad = "2px";
	WWBN_HeaderAlignment = "center";
	WWBN_HeaderTopPos = "20px";
	WWBN_HeaderLeftPos = "0px";
	//Video Variables
	WWBN_ShowVideo = true; 														// Display the Video
	WWBN_VideoWidth = "275px"; 														// Set the Video Width
	WWBN_VideoHeight = "206px"; 														// Set the Video Height
	WWBN_VideoTopPos = "42px";
	WWBN_VideoleftPos = "2px";
	//Video Link Results Variables
	WWBN_ResultsWidth = "275px"; 													// Set the Results Width
	WWBN_ResultsHeight = "260px"; 													// Set the Results Height
	WWBN_Results = "99"; 															// Set the # of Videos Results here
	WWBN_ResultsTopPos = "250px";
	WWBN_ResultsLeftPos = "2px";
	WWBN_Play_Button = "http://wwbn.com/images/icons/control_play_blue.png";
	WWBN_ResultsBGNDColor = "#ffffff";													//Set the results backgroung color here
	WWBN_ResultsLinkColor = "#000000";
	WWBN_ResultsPopoutWindow = false;  //Pops up the Player or when Combined with WWBN_ResultsLinkExternal opens the Product URL
	WWBN_ResultsLinkExternal = true;  //Opens the Website of the Player with the Video being Played 
	WWBN_PopoutWindowWidth="572";  //  Popup Box Width
	WWBN_PopoutWindowHeight="380";  // Popup Box height
	WWBN_ResultsLinkSize = "2";
	WWBN_ResultsLinkFont = "arial";
	WWBN_ResultsTag = true;
	WWBN_ResultsTagCompany = true;
	WWBN_ResultsTagColor = "#ff0000";
	WWBN_ResultsTagSize = "1";
	WWBN_ResultsTagFont = "arial";
	//More Videos Link variables
	WWBN_AllVideos_Top = 518;
	WWBN_AllVideos_Left = 90;
	WWBN_ShowButton = true;															//Activate Button = true  Link = false
	//Button Variables
	WWBN_ShowButtonBGNDColor ="#283548";
	WWBN_ShowButtonBorderColor = "#CCCCCC";
	WWBN_ShowButtontextColor = "#ffffff";
	WWBN_ShowButtonTextFont = "tahoma, arial, verdana, ms sans serif";
	WWBN_ShowButtonTextWight = "bold";
	WWBN_ShowButtonTextSize = "8pt";
	WWBN_ShowButtonTextAlign = "middle";
	//Link Variables
	WWBN_MoreVideosText = "More Videos";
	WWBN_MoreVideosTextSize = "2"; 													// Set the Link To Product Text Size
	WWBN_MoreVideosTextFont = "arial";
	//Footer Image Variables  (Please Note That: Image must be 40 pixels in height.  No Exeptions!)
	WWBN_ShowFooter = false;
	WWBN_Footer_Top = 550;
	WWBN_Footer_Left = 0;
	WWBN_Footer_ImageURL = "http://wwbn.com/images/Templates/SanDiego/sd_logo.jpg";
	WWBN_FooterAlignment = "center";
	}
	//End Of Variables


//Featured Jobs
	function featured(){
		var myFeaturedFrame = new xmlFetcher();
		myFeaturedFrame.setOutPutElement('first');
		myFeaturedFrame.setOutputFormat('customHTML');
		
		myFeaturedFrame.setItemUrlTag('Url');
		
		myFeaturedFrame.setItemRoot('Job', '<div onmouseover="this.style.background=\'#E5E9F5\';" onmouseout="this.style.background=\'\';" onclick=window.open(\'itemUrlTagValue\') style="cursor:hand;cursor:pointer;padding:2px;margin-bottom:5px;">', '<' + '/' + 'div>\n\n');
		
		myFeaturedFrame.addOutputTag('Title', '<span class="title"><b style="color:#003399">', '</b></span><br>');
		myFeaturedFrame.addOutputTag('Employer', '<span class="employer">', '</span>   -   ');
		myFeaturedFrame.addOutputTag('Location', '<span class="location">', '</span> <br>');
		
		//myFeaturedFrame.setRootHTML('<div style="height:10px"><' + '/' + 'div>', '<div style="height:10px">' + '<' + '/' + 'div>');
		
		//myFeaturedFrame.setScrollSpeed(30);
		myFeaturedFrame.disableScroll();
		myFeaturedFrame.initFromString(xmlString);
	}
//End Featured Jobs

//To Radomly Select Divs on a Page
//Created 1/9/09 by Mary-Chris Hirsch

function randomizeContent(classname){
var contents=randomizeContent.collectElementbyClass(classname)
contents.text.sort(function() {return 0.5 - Math.random();})
var tbodyref=contents.ref[0].tagName=="TR"? contents.ref[0].parentNode : new Object()
for (var i=0; i<contents.ref.length; i++){
if (tbodyref.moveRow) //if IE
tbodyref.moveRow(0, Math.round(Math.random()*(tbodyref.rows.length-1)))
else
contents.ref[i].innerHTML=contents.text[i]
contents.ref[i].style.visibility="visible"
}
}

randomizeContent.collectElementbyClass=function(classname){ //return two arrays containing elements with specified classname, plus their innerHTML content
var classnameRE=new RegExp("(^|\\s+)"+classname+"($|\\s+)", "i") //regular expression to screen for classname within element
var contentobj=new Object()
contentobj.ref=new Array() //array containing references to the participating contents
contentobj.text=new Array() //array containing participating contents' contents (innerHTML property)
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (var i=0; i<alltags.length; i++){
if (typeof alltags[i].className=="string" && alltags[i].className.search(classnameRE)!=-1){
contentobj.ref[contentobj.ref.length]=alltags[i]
contentobj.text[contentobj.text.length]=alltags[i].innerHTML
}
}
return contentobj
}
//End Random Div
var defaulttext = "Job title, skills or company";
	function clickclear(thisfield, color) {
			if (thisfield.value == defaulttext) {
				thisfield.value = "";
			}
		}
		function clickrecall(thisfield, color) {
			if (thisfield.value == "") {
				thisfield.value = defaulttext;
			}
		}
		// specify the name of your form
		var thisForm = "jobsearch";
		// clear all defaults when form is submitted
		function ClearAll(thisfield) {
			if (thisfield.value == defaulttext) {
				thisfield.value = "";
		}}
	

