/*------------------------------------------------------------------------
File Name: EmersonClimate.js
Purpose: Javascript file for all the master pages.
Created By: Infosys Technologies Ltd.
Created Date:20-08-09
Modification history:
Description       Modified By       Modified Date
------------------------------------------------------------------------*/


 /* This function is to set the style of the bread crumb. */
 function windowload() 
 {
     if(document.getElementById("ctl00_PlaceHolderTitleBreadcrumb_siteMapPath")!= null)
     {
          var spanMain = document.getElementById("ctl00_PlaceHolderTitleBreadcrumb_siteMapPath");
          var spanCurrentSpan = spanMain.getElementsByTagName("span");
          spanCurrentSpan[spanCurrentSpan.length-1].style.color = '#f7941d';
      }
 }
    
 /* This function is to open a page in the same window
  or new window depending on the url. If the url is absolute, it opens in new window.*/
 function OpenSite(brandsURL)
 {
    if(brandsURL != "-1" && brandsURL != "" && brandsURL != null )
    {
        if(brandsURL.indexOf("http:") == -1)
        {
            window.location = brandsURL;
        }
        else
        {
            window.open(brandsURL);
        }
    }
 }
	
 /* This function is to display the drop down menu, to set the top, left and width of the menu. */
 function OnMenuComplete(args, ctx)
 {   
    //To display the Market Solutions menu.
    	if(ctx == "MarketSolutions")
    	{
    	    PrimaryNav.style.top = "20px";
    	    PrimaryNav.style.left = "20px";
    	    PrimaryNav.style.width = "300px";
    	    PrimaryNav.style.border = "1px solid #999999";
     	    PrimaryNav.innerHTML  = args;
            PrimaryNav.style.display = "block";
            return;
       	}
       	//To display the Products menu.
       	if (ctx == "Products")
       	{
       	    PrimaryNav.style.top = "20px";
    	    PrimaryNav.style.left = "-60px";
    	    PrimaryNav.style.width = "750px";
    	    PrimaryNav.style.border = "1px solid #999999";
    				      
     	    PrimaryNav.innerHTML  = args;
       	    PrimaryNav.style.display = "block";
       	    return;
       	}
       	//To display the Services menu.
      	if (ctx == "Services")
      	{
       	    PrimaryNav.style.top = "20px";
    	    PrimaryNav.style.left = "297px";
    	    PrimaryNav.style.width = "350px";
    	    PrimaryNav.style.border = "1px solid #999999";
    				      
     	    PrimaryNav.innerHTML  = args;
       	    PrimaryNav.style.display = "block";
       	    return;
    }
    //To display the Resources menu.
    if (ctx == "Resources")
   	{
  	    PrimaryNav.style.top = "20px";
	    PrimaryNav.style.left = "190px";
	    PrimaryNav.style.width = "500px";
	    PrimaryNav.style.border = "1px solid #999999";
				      
 	    PrimaryNav.innerHTML  = args;
   	    PrimaryNav.style.display = "block";
   	    return;
   	}
   	//To display the About Us menu.
    if (ctx == "AboutUs")
   	{
   	    PrimaryNav.style.top = "20px";
	    PrimaryNav.style.left = "400px";
	    PrimaryNav.style.width = "300px";
	    PrimaryNav.style.border = "1px solid #999999";
				      
 	    PrimaryNav.innerHTML  = args;
   	    PrimaryNav.style.display = "block";
   	}
 }

/* This function hides the menu. */    
function hideDiv()
{	
    
  	if(PrimaryNav.style.display = "block")
    {
    	PrimaryNav.style.display = "none";
    }	
}

/* This function displays the menu. */    
function showDiv()
{    
       
      PrimaryNav.style.display = "block";
      PrimaryNav.style.border = "1px solid #999999";
}

/*
CoctUsEmail Form js logic
*/

// Items to be displayed in Comments are about dropdown are changed based on value selected in Country dropdown
subb = new Array(
// for United States
new Array(
new Array("Please select one", ""),
new Array("Air Conditioning", "ac_info@emersonclimate.com"),
new Array("Refrigeration", "ref_info@emersonclimate.com"),
new Array("Customer Portal Support", "web_support@emersonclimate.com"),
new Array("Online Product Information Support", "web_support@emersonclimate.com"),
new Array("General Inquiry", "other_info@emersonclimate.com")
),

// Asia
new Array(
new Array("General Inquiry", "asiainfo@copeland-corp.com"),
new Array("Customer Portal Support", "web_support@emersonclimate.com"),
new Array("Online Product Information Support", "web_support@emersonclimate.com")
),

//Latin America
new Array(
new Array("General Inquiry", "Fernando.Pujalt@emerson.com"),
new Array("Customer Portal Support", "web_support@emersonclimate.com"),
new Array("Online Product Information Support", "web_support@emersonclimate.com")
),

//Middle East
new Array(
new Array("General Inquiry", "MEAMarketing@emersonclimate.com"),
new Array("Customer Portal Support", "web_support@emersonclimate.com"),
new Array("Online Product Information Support", "web_support@emersonclimate.com")
),

//Europe
new Array(
new Array("Customer Portal Support", "web_support@emersonclimate.com"),
new Array("General Inquiry", "ecommerce.ecommerce@emerson.com"),
new Array("Online Product Information Support", "web_support@emersonclimate.com")
),

//Other
new Array(
new Array("General Inquiry", "other_info@emersonclimate.com"),
new Array("Customer Portal Support", "web_support@emersonclimate.com"),
new Array("Online Product Information Support", "web_support@emersonclimate.com")
),

//not in use
new Array(
new Array("Select One", "none"),
new Array("Copeland", "Copeland"),
new Array("Design Services Network", "dsn"),
new Array("Distribution Services", "distribution"))
);

function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {

	var i, j;
	var prompt;
	// empty existing items
	for (i = selectCtrl.options.length; i >= 0; i--) {
		selectCtrl.options[i] = null; 
	}
	prompt = (itemArray != null) ? goodPrompt : badPrompt;
	if (prompt == null) {
		j = 0;
	}
	else {
		selectCtrl.options[0] = new Option(prompt);
		j = 1;
	}
	if (itemArray != null) {
		// add new items
		for (i = 0; i < itemArray.length; i++) {
			selectCtrl.options[j] = new Option(itemArray[i][0]);
			if (itemArray[i][1] != null) {
				selectCtrl.options[j].value = itemArray[i][1]; 
			}
			j++;
		}
		// select first item (prompt) for sub list
		selectCtrl.options[0].selected = true;
   	}
}

// Change the submit to e-mail id based on value selected in Comments are about dropdown
function change_form_id(){
	if(document.aspnetForm.submit_to.options[document.aspnetForm.submit_to.selectedIndex].value == "web_support@emersonclimate.com")
		document.aspnetForm.form_id.value = "OPI and Portal Support";
	else if (document.aspnetForm.submit_to.options[document.aspnetForm.submit_to.selectedIndex].value == "ecommerce@ecopeland.com")
		document.aspnetForm.form_id.value = "webrequest:";
	else if (document.aspnetForm.submit_to.options[document.aspnetForm.submit_to.selectedIndex].value == "other_info@emersonclimate.com")
		document.aspnetForm.form_id.value = "Other Info - Contact Us";
	else if (document.aspnetForm.submit_to.options[document.aspnetForm.submit_to.selectedIndex].value == "ac_info@emersonclimate.com")
		document.aspnetForm.form_id.value = "AC Info - Contact Us";
	else if (document.aspnetForm.submit_to.options[document.aspnetForm.submit_to.selectedIndex].value == "ref_info@emersonclimate.com")
		document.aspnetForm.form_id.value = "Ref Info - Contact Us";
	else
	   	document.aspnetForm.form_id.value = "Contact Us";

}

    
function Reset1_onclick(formObj) {
formObj.firstname.value = "";
formObj.lastname.value = "";
formObj.submit_by.value = "";
formObj.phone.value = "";
formObj.company.value = "";
formObj.address.value = "";
formObj.city.value = "";
formObj.state.value = "";
formObj.zip.value = "";
formObj.job.value = "";
formObj.type.value = "";
formObj.comments.value = "";
}

function submitPage(formObj)
{

formObj.action = 'http://form.emersonclimate.com/ctppub/servlet/Submit';
formObj.method='post';
formObj.submit();
}
