// JavaScript Document


// this is the common file for the Prairie Global Management website
//
// Author: Jacques J. Bosc
// Date:   November, 2007
// Project: Create javascript to be used for the site.
//

// this code would normally by placed in a external javascript file to handle any
// errors that would come up.
onerror=handleErr;
var txt="";

// this array is outside the functions to allow it to be used by
// multiple functions, it makes it global

var report_array = new Array();

report_array[0] = "../polling_images/report-types_blank.jpg";
report_array[1] = "../polling_images/report-types_3D_pie.jpg";
report_array[2] = "../polling_images/report-types_3D_column.jpg";
report_array[3] = "../polling_images/report-types_2D_column.jpg";
report_array[4] = "../polling_images/report-types_2D_pie.jpg";



function handleErr(msg,url,l) {
  txt="There was an error in the logic of this page.\n\n";
  txt+="Error: " + msg + "\n";
  txt+="URL: " + url + "\n";
  txt+="Line: " + l + "\n\n";
  txt+="Click OK to continue.\n\n";
  alert(txt);
  return true;
}



// this code will light up the button on a mouseover
if (document.images) {
    pic1on= new Image(41,17);
    pic1on.src="images/navigation_btns/home_grey.jpg";  
    pic2on= new Image(61,17);
    pic2on.src="images/navigation_btns/philosophy_grey.jpg";  
    pic3on= new Image(42,17);
    pic3on.src="images/navigation_btns/history_grey.jpg";  
    pic4on= new Image(50,17);
    pic4on.src="images/navigation_btns/services_grey.jpg";  
    pic5on= new Image(51,17);
    pic5on.src="images/navigation_btns/contact_us_grey.jpg";
    pic6on= new Image(47,17);
    pic6on.src="images/navigation_btns/portofolio_grey.jpg";
    pic7on= new Image(44,17);
    pic7on.src="images/navigation_btns/awards_grey.jpg";
    pic8on= new Image(34,17);
    pic8on.src="images/navigation_btns/news_grey.jpg";
    pic9on= new Image(35,17);
    pic9on.src="images/navigation_btns/login_grey.jpg";

    pic1off= new Image(41,17);
    pic1off.src="images/navigation_btns/home_white.jpg";
    pic2off= new Image(61,17);
    pic2off.src="images/navigation_btns/philosophy_white.jpg";
    pic3off= new Image(42,17);
    pic3off.src="images/navigation_btns/history_white.jpg";
    pic4off= new Image(50,17);
    pic4off.src="images/navigation_btns/services_white.jpg";
    pic5off= new Image(51,17);
    pic5off.src="images/navigation_btns/contact_us_white.jpg";
    pic6off= new Image(47,17);
    pic6off.src="images/navigation_btns/portofolio_white.jpg";
    pic7off= new Image(44,17);
    pic7off.src="images/navigation_btns/awards_white.jpg";
    pic8off= new Image(34,17);
    pic8off.src="images/navigation_btns/news_white.jpg";
    pic9off= new Image(35,17);
    pic9off.src="images/navigation_btns/login_white.jpg";
}


// this is for the portfolio page which is one directory down
if (document.images) {
    picport1on= new Image(41,17);
    picport1on.src="../images/navigation_btns/home_grey.jpg";  
    picport2on= new Image(61,17);
    picport2on.src="../images/navigation_btns/philosophy_grey.jpg";  
    picport3on= new Image(42,17);
    picport3on.src="../images/navigation_btns/history_grey.jpg";  
    picport4on= new Image(50,17);
    picport4on.src="../images/navigation_btns/services_grey.jpg";  
    picport5on= new Image(51,17);
    picport5on.src="../images/navigation_btns/contact_us_grey.jpg";
    picport6on= new Image(47,17);
    picport6on.src="../images/navigation_btns/portofolio_grey.jpg";
    picport7on= new Image(44,17);
    picport7on.src="../images/navigation_btns/awards_grey.jpg";
    picport8on= new Image(34,17);
    picport8on.src="../images/navigation_btns/news_grey.jpg";
    picport9on= new Image(35,17);
    picport9on.src="../images/navigation_btns/login_grey.jpg";

    picport1off= new Image(41,17);
    picport1off.src="../images/navigation_btns/home_white.jpg";
    picport2off= new Image(61,17);
    picport2off.src="../images/navigation_btns/philosophy_white.jpg";
    picport3off= new Image(42,17);
    picport3off.src="../images/navigation_btns/history_white.jpg";
    picport4off= new Image(50,17);
    picport4off.src="../images/navigation_btns/services_white.jpg";
    picport5off= new Image(51,17);
    picport5off.src="../images/navigation_btns/contact_us_white.jpg";
    picport6off= new Image(47,17);
    picport6off.src="../images/navigation_btns/portofolio_white.jpg";
    picport7off= new Image(44,17);
    picport7off.src="../images/navigation_btns/awards_white.jpg";
    picport8off= new Image(34,17);
    picport8off.src="../images/navigation_btns/news_white.jpg";
    picport9off= new Image(35,17);
    picport9off.src="../images/navigation_btns/login_white.jpg";
}


function lightup(imgName) {
   if (document.images)
    {
      imgOn=eval(imgName + "on.src");
      document[imgName].src= imgOn;
    }
 }

function turnoff(imgName) {
   if (document.images)
    {
      imgOff=eval(imgName + "off.src");
      document[imgName].src= imgOff;
    }
 }
 
function loadDetails(set, div) {
	var block = top.document.getElementById(div);
	if (set =='open') {
		block.style.display = "block";
	  } else {
	    block.style.display = "none";
	  }
 }
 
 
 // create a method of switching the flash on the main page
function random_flash_link(){

// put url's for randomly selected graphics here, as in the example
  
  var gfx = new Array();

  gfx[0] = 'flash/SWJ-Intro1.swf';
  gfx[1] = 'flash/SWJ-Intro2.swf';
/*
  gfx[2] = '../images/home2_new3.jpg';
  gfx[3] = '../images/home3_new3.jpg';
  gfx[4] = '../images/home4_new3.jpg';
  gfx[5] = '../images/home5_new3.jpg';
*/

  var ry=Math.floor(Math.random()*gfx.length)

//  document.writeln('<a href="'+linkInfo[ry]+'" target="_blank"><img src="'+gfx[ry]+'" width="106" height="389" alt="Strategic info image" /></a>')

	document.writeln('   <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
    document.writeln('            codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"'); 
	document.writeln('			width="748"'); 
	document.writeln('			height="366"'); 
	document.writeln('			id="IntroMovie"'); 
	document.writeln('			align="bottom">');
    document.writeln('      <param name="allowScriptAccess" value="sameDomain" />');
    document.writeln('      <param name="movie" value="'+gfx[ry]+'" />');
	document.writeln('	    <param name="quality" value="high" />');
	document.writeln('	    <param name="bgcolor" value="#ffffff" />');
	document.writeln('	    <embed src="'+gfx[ry]+'" quality="high"'); 
	document.writeln('	         bgcolor="#ffffff"'); 
	document.writeln('	         width="748"'); 
	document.writeln('			 height="366"'); 
	document.writeln('			 name="IntroMovie" align="bottom" allowScriptAccess="sameDomain"'); 
	document.writeln('			 type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.writeln('    </object>');




}
//  random_imglink()  this call to random_imglink needs to be put in the actual file to work properly.



// build a footer so that I only have to update this to make the footer the same on all pages
function create_footer() {
    var current_date = new Date().getFullYear();
    document.write('Web site design and integration by SWJ Strategic Marketing &amp; Advertising<br /> Copyright '+current_date+'. All rights reserved.');
}



// verify that the name and email from the news page has data when subscribe entered
function verify_email(da_reg_form) {

  var register_req_array = new Array();
  register_req_array[0] = document.getElementById("username_data").value;
  register_req_array[1] = document.getElementById("email_data").value;
  
// check the first array to make sure that the info is there
  for (i = 0; i < register_req_array.length; i++) {
    if (register_req_array[i] == "") {
      alert('You have not filled in either the name or email prompt, please check and rekey.');
	  document.receive_mail.name_to_sendto.focus();	      
	  return false;
    }
  }
  

}


