
var CurPic;
function StartPage() {
   //CurPic = 0;
   CurPic = Math.floor(Math.random() * ($("#rotated img").length));
   //alert(CurPic);
   $("#rotated img:eq("+CurPic+")").show();
   setInterval('Swapper('+CurPic+')',5000)
}
function StartPage_DM() {
   CurPic = 0;
   //CurPic = Math.floor(Math.random() * ($("#rotated img").length));
   //alert(CurPic);
   $("#rotated img:eq("+CurPic+")").show();
   setInterval('Swapper('+CurPic+')',5000)
}


function Swapper(){
   //alert('fading: ' + CurPic);
   $("#rotated img:eq("+CurPic+")").fadeOut(3000);
   CurPic++;
   if (CurPic == ($("#rotated img").length)) { CurPic = 0; }
   $("#rotated img:eq("+CurPic+")").fadeIn(3000);
   return true;  
}

function shufflye(o) {
	for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
	return o;
};


// Clears all checkboxes on the page, except for the calling element. Useful for "None of the above" type answers.
//	Usage: 	<input type="checkbox" id="checkbox42" name="foo42" value="1" onclick="ClearAll(checkbox42, this.form);">
//				Clears all checkboxes on the form, except for id="checkbox42"
function ClearAll(me, form){
	if( me.checked == true )
		for(i = 0; i < form.elements.length; i++)
			if(form.elements[i].type == "checkbox" && form.elements[i].name != me.name)
				form.elements[i].checked = false;
}

// Clears one checkbox.  Useful for clearing out the "None..." answer when selecting something else.
// Usage: 	<input type="checkbox" id="checkbox1" name="foo1" value="1" onclick="ClearOne('checkbox42');">
//				Clears id="checkbox42"
function ClearOne(control){
	document.getElementById(control).checked = false;    // the 'None' control
}

// Clears the contents of one textbox.  When clearing out a series of radios/checks, clear out the textbox
// attached to the "other"" response as well.
// Usage: 	<input type="checkbox" id="checkbox1" name="foo1" value="1" onclick="ClearAll('checkbox42', this.form); ClearText('text2');">
//				Clears all checkboxes on the page, and the textbox with id="text2"
function ClearText(control){
   if (document.getElementById(control))
   	document.getElementById(control).value = '';    // the 'None' control
}

// Clears a range of checkboxes.  Useful when you need to clear a few checkboxes, but not all of them!
// Usage: 	<input type="checkbox" id="checkbox1" name="foo1" value="1" onclick="ClearRange(2, 10);">
//				Clears id="checkbox2", id="checkbox3" ... id="checkbox9", id="checkbox10"
function ClearRange(start, end){
	var foo;
	for(i = start; i <= end; i++) {
		foo = 'checkbox' + i;
		if (document.getElementById(foo))
         document.getElementById(foo).checked = false;
	}
}

function toggleTDHighlight(qNum,row, me) {
	var i
	// blank out all span background colors
	for (i = 1; document.getElementById('td'+qNum+'_'+row+'_'+i); i++) {
		document.getElementById('td'+qNum+'_'+row+'_'+i).style.backgroundColor = "";
	}
	document.getElementById('td'+qNum+'_'+row+'_'+me).style.background = "#86B1EF";
	document.getElementById('radio'+qNum+'_'+row+'_'+me).checked = true;
}

//onload highlight the right boxes
function reHighlightTDs(numQs) {
	var i, j, k
	i = 1;
	j = 1;
	k = 1;
	q = 1;	// for the question number!
	for(q = 1; q<=numQs; q++) {	// loop through the number of questions..., provided in the body tag of the page
		if (document.getElementById('td'+q+'_'+i+'_'+j)) {
			for(k = q; document.getElementById('td'+k+'_'+i+'_'+j); k++) {
				for(i = 1; document.getElementById('td'+k+'_'+i+'_'+j); i++) {
					for(j = 1; document.getElementById('td'+k+'_'+i+'_'+j); j++) {
						if (document.getElementById('radio'+k+'_'+i+'_'+j).checked == true)
							document.getElementById('td'+k+'_'+i+'_'+j).style.backgroundColor="#86B1EF";
					}	//for
					j = 1
				} //for
				i = 1
			} //for k
		} //if
	} //for q
} // function

// * * * * * * * * * * * * * * * * * * * * * * * * * 
// Toggle the visibility of div id="whereseek" on yourprofilemagazines.asp
// usableforms.js doesnt work well with checkboxes?!  I need the whereseek to
// display for any checkbox, but it toggles for every check instead.  Quick function
// to show and hide it, complete with fade!
function ToggleWhereSeek() {

   if (document.getElementById('checkbox32').checked == true) {
      ClearRange(41,48);
      ClearText('whereseek8x')
      document.getElementById('whereseek').style.display = 'none';
   }
   else {
      document.getElementById('whereseek').style.display = 'block';
      //new Effect.Highlight('wherseek', {startcolor: '#99ff80', endcolor: '#EDF7F8', duration: 2});
      // this ensures that the div we just added ends up with a whtie background - bug in nested rel's?
      //Elements[i].style.backgroundColor='#EDF7F8';
   } //else
      
}

$(document).ready(function() {

   // for the your profile page
               
   $("#NotInUSCheck").click(function() {
      if ($("#NotInUSCheck").attr('checked'))
         $("#ProfileZipCode").val('');
   });
   
   $("#ProfileZipCode").keypress(function() {
      $("#NotInUSCheck").attr('checked', '')
   });

   $("#addmorechildrenbox").click(function() {
      if ($("#addmorechildrenbox").attr('checked'))
         $("#addmorechildren").slideDown();
      else
         $("#addmorechildren").slideUp();
   });
   
   $("#expecting").click(function() {
      if ($("#expecting").attr('checked'))
         $("#showduedate").slideDown();
      else
         $("#showduedate").slideUp();
   });
   
   // on select full time (1), part time (2), onleave (3)
   $("#ProfileWorkSit option").click( function() {
      EmployMover();
   });
   // on select full time (1), part time (2), onleave (3)
   $("#ProfileWorkSit").click( function() {
      EmployMover();
   });   
   
   function EmployMover() {
      if ($("#ProfileWorkSit option:selected").attr('value') < 4)
         $("#employ").slideDown();
      else
         $("#employ").slideUp();
   } //employmover
   EmployMover();

   if ($("#addmorechildrenbox").attr('checked'))
      $("#addmorechildren").slideDown();      
   else
      $("#addmorechildren").hide();

   if ($("#expecting").attr('checked'))
      $("#showduedate").slideDown();
   else
      $("#showduedate").hide();
   
   if ($("#ProfileWorkSit option:selected").attr('value') < 4)
      $("#employ").slideDown();
   else
      $("#employ").hide();
   

   $("#employ").hide();

   // now, fire the click event...

   
   
   
   
})  // document.ready
