//// *********************************** ////
//// State of California master template ////
////             Version 1.20            ////
////       Last Updated 08/26/2010       ////
////                                     ////
//// PCIP                                ////
//// scripts here.                       ////
//// *********************************** ////

// breadcrumbs
// This function populates the breadcrumb section of the page.
// breadcrumbs
// This function populates the breadcrumb section of the page.
function getSpanish(str){
	if(str=='2009 FIGs are Still In Effect'){
		str='Las FIGs del 2009 siguen en efecto'
	}



return(str);
}


//Get English breadcrumb text if it is different from the folder name My_PCIP
function getEnglish(str){
	if(str=='My PCIP'){
		str='myPCIP'
	}
	if(str=='About'){
		str='About PCIP'
	}
	if(str=='Contact'){
		str='Contact PCIP'
	}
	if(str=='Privacy'){
		str='PCIP Privacy Notification'
	}
	if(str=='Privacy MRMIP'){
		str='MRMIP Privacy Notification'
	}
	if(str=='FAQs'){
		str='Frequently Asked Questions'
	}	
	if(str=='Social Media'){
		str='Facebook and Twitter Available Now'
	}

return(str);
}

function breadcrumbs()
{
	var rootUrl = 'http://www.PCIP.ca.gov/';
	//var rootUrl = "http://10.2.2.36/";
	var virtualDir = '';
	if ((document.getElementById) && document.getElementById('breadcrumb_dynamic')) { // Make sure browser supports getElementById and breadcrumb_dynamic exists
		var wrkLocation = location.href;
		var wrkLength = wrkLocation.indexOf("#");  // Find the begining of any anchor reference
		if(wrkLength != -1){
			var wrkLocation = wrkLocation.substr(0,wrkLength);  // Extract the anchor reference
		}	
		var wrkLength = wrkLocation.indexOf("?");  // Find the begining of the query string
		if(wrkLength != -1){
			var wrkLocation = wrkLocation.substr(0,wrkLength);  // Extract the query string
		}	
 
		var arrURL=wrkLocation.split("/"); // Array containing the current location, split at the slashes
		if (arrURL[arrURL.length-2] != "Home"){
			if (thisLang=='es'){
				var output='&nbsp;&nbsp;<a href="' + rootUrl + 'Home/default.aspx?lang=es">P&aacute;gina principal</a>'; // The string which will be output to the browser, starts with a link to the home page
			}else{
				var output='&nbsp;&nbsp;<a href="' + rootUrl + 'Home/default.aspx">Home</a>'; // The string which will be output to the browser, starts with a link to the home page
		
			}
		}else {
			var output='';
			
		}
		
		var path = ''; // Link for the crumbs


		// If last item is blank or index.* or default.*, remove it
		if (arrURL[arrURL.length-1] == '' || arrURL[arrURL.length-1].match(/^index\.|^default\./i) ) {
			arrURL.length--;
		}

		if (arrURL.length > 3) {
			for (counter = 3;counter < arrURL.length-1;counter++) {  // Loop to display the links
				if(path.length == 0){  
					//path = '/';
					path= rootUrl;
				}
				if (arrURL[counter] != virtualDir){
					path += arrURL[counter] 
					if (counter == arrURL.length-2) {
						path  += '/default.aspx';  // always end links to folder with '/' 
					}else{
						path  += '/';  // always end links to folder with '/' 
					}
					if (thisLang=='es'){
							output += ' <img src="../images/ca_department/bullet_blue.gif" alt="" /> <a href="' + path + '?lang=es">' + getSpanish(arrURL[counter].replace(/_/g,' ')) + '</a>';
					}else{
							output += ' <img src="../images/ca_department/bullet_blue.gif" alt="" /> <a href="' + path + '">' + getEnglish(arrURL[counter].replace(/_/g,' ')) + '</a>';
					}
				}
			}

			// Display the name of the current page in bold
				if (thisLang=='es'){
					output += ' <img src="../images/ca_department/bullet_blue.gif" alt="" /> <strong>' + getSpanish(arrURL[arrURL.length-1].replace(/_/g,' ').replace(/\.\w{3,5}$/,'')) + '</strong>';
				}else{
					output += ' <img src="../images/ca_department/bullet_blue.gif" alt="" /> <strong>' + getEnglish(arrURL[arrURL.length-1].replace(/_/g,' ').replace(/\.\w{3,5}$/,'')) + '</strong>';
				}
}
document.getElementById('breadcrumb_dynamic').innerHTML = output;  // Display the breadcrumbs
	}
}

addLoadEvent(breadcrumbs);  // Add breadcrumbs to the page onload event handler


// End of breadcrumbs javascript

// selectSearch - If you are not using DTS site search you may delete lines 10-to-25
// Choose between the statewide search and your own local site search.

function selectSearch() { 
	if (document.getElementById("control").which[0].checked) {
	  document.getElementById("ca_form").q.value = document.getElementById("search").value;
	  document.getElementById("ca_form").submit();
	} else {
		// Change the 'q' to the parameter your search engine uses for its text field
	  document.getElementById("local_form").q.value = document.getElementById("search").value;
	  document.getElementById("local_form").submit();
	}
  return false;
}

// End of selectSearch javascript
/////////////////////////
//// tabpanel_module ////
/////////////////////////


//// tabpanel_mouseover
//// This function is called when a tabpanel tab is hovered

function tabpanel_mouseover(node)
{
  var panel_1_width = document.getElementById("tabpanel_1_sublist").offsetWidth; // Needed for IE
  document.getElementById("tabpanel_1").className = ""; // De-activate default item
  node.className = "tabpanel_default"; // Activate the hovered item
  if (panel_1_width) {
    if (document.getElementById("tabpanel_2_sublist"))
      document.getElementById("tabpanel_2_sublist").style.width = (panel_1_width - 2) + "px"; // Needed for IE
    if (document.getElementById("tabpanel_3_sublist"))
      document.getElementById("tabpanel_3_sublist").style.width = (panel_1_width - 2) + "px"; // Needed for IE
  }
}

//// tabpanel_mouseout
//// This function is called on mouseout

function tabpanel_mouseout(node)
{
  node.className = ""; // De-activate this item
  document.getElementById("tabpanel_1").className = "tabpanel_default"; // Activate default item
}

// End of tabpanel_module javascript

// Begin javascript enabled page navigation. Using this setup enables
// javascript to better control page-level navigation, but still allow users
// that may not have javascript enabled to still successfully navigate the
// page. The idea is that both basic navigation controls and a javascipt
// enabled navigation controls are embedded in a page. This set of controls
// then make sure that the initial settings are performed. Specific page-level
// controls are left for each page to perform.

// Create a class that allows us to access the set of CSS rules for the page.
//function CSSRules() {
//  this.cssRules = new Array();

  // Collect the set of CSS rules for the document.
//  if (document.styleSheets[0].cssRules) {
    // Standards compliant
//   this.cssRules = document.styleSheets[0].cssRules;
//  } 
//  else if (document.styleSheets[0].rules) {
    // MSIE
//    this.cssRules = document.styleSheets[0].rules;
//  }
//}

// Using the set of discovered rules, find a specific CSS rule.
//CSSRules.prototype.FindRule = function (rule) {
//  var retval = null

//  if (this.cssRules.length > 0) {
//    for (counter = 0; counter < this.cssRules.length; counter++) {
//      if(this.cssRules[counter].selectorText.toLowerCase() == rule) {
//        retval = this.cssRules[counter];
//        break;
 //     }
//    }
//  }

//  return retval;
//}
// End CCSRules class declaration
//
// instantiate an instance of the CSSRules object.
// var cssRules = new CSSRules();

// find the javascript controlled rules, and get their instances.
// var jscontrolRule = cssRules.FindRule(".jscontrol");
// var nojscontrolRule = cssRules.FindRule(".nojscontrol");

// Change the selected CSS style settings. 
// if(jscontrolRule) {jscontrolRule.style.display="inline";}
// if(nojscontrolRule) {nojscontrolRule.style.display="none";}

// End javascript enabled page navigation.


