﻿/***********************************************************************/
/********************** Script for HomePage ****************************/
/***********************************************************************/
/* Developed by SOGETI USA LLC - Hardik Shah [Guru], Abhijeet Khopade **/
/***********************************************************************/


// Function to call when the SearchBox gets FOCUS //

function SearchBox_OnFocus()
{   
    var Search_Box = document.getElementById("SearchBox");

    if ((Trim(Search_Box.value) == '') || (Search_Box.value == 'Search KCS')) 
    {   
        Search_Box.focus();
        Search_Box.value = '';
        Search_Box.style.color = 'Black';
    }   
}

// Function to call when the SearchBox looses FOCUS //

function SearchBox_OnBlur() 
{
    
    var Search_Box = document.getElementById("SearchBox");
    
    if (Trim(Search_Box.value) == '') 
    {   
        Search_Box.value = 'Search KCS';
        Search_Box.style.color = 'Gray';
    }

}


// Function to call when the SearchBox gets FOCUS in Spanish Master Page //

function SearchBoxMX_OnFocus()
{   
    var Search_Box = document.getElementById("SearchBox");

    if ((Trim(Search_Box.value) == '') || (Search_Box.value == 'Búscar en KCS')) 
    {   
        Search_Box.focus();
        Search_Box.value = '';
        Search_Box.style.color = 'Black';
    }   
}

// Function to call when the SearchBox looses FOCUS in Spanish Master Page//

function SearchBoxMX_OnBlur() 
{
    
    var Search_Box = document.getElementById("SearchBox");
    
    if (Trim(Search_Box.value) == '') 
    {   
        Search_Box.value = 'Búscar en KCS';
        Search_Box.style.color = 'Gray';
    }

}



// Function to TRIM a String. Reurns a TRIMMED value //

function Trim(str) 
{
    
    while (str.substring(0, 1) == ' ') // check for white spaces from beginning
    {
        str = str.substring(1, str.length);
    }
    
    while (str.substring(str.length - 1, str.length) == ' ') // check white space from end
    {
        str = str.substring(0, str.length - 1);
    }
    
    return str;
}

// Function to search in the site //

function Search(SearchText)
{
	//alert(SearchText);
	
	window.location = "../Results.aspx?k=" + SearchText;
	
}

// Function to switch to English Site //

function ToEnglish(URL)
{
	var p1 = URL.toString();
	
	window.location = p1.replace("es-mx", "en-us");
}

// Function to switch to Spanish Site //

function ToSpanish(URL)
{
	var p1 = URL.toString();
	
	window.location = p1.replace("en-us", "es-mx");
}



