var CONTENT_TOP =
	'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'
		+ '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
		+ '<html xmlns="http://www.w3.org/1999/xhtml">'
		+ '<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />'
		+ '<link rel="stylesheet" href="/css/pHelpCenterPrinter.css" />'
		+ '</head><body>'
		+ '<div id="headerPrint">'
		+ '<a href="javascript:window.print();" id="print-button-1" class="clvPrint">print</a>'
		+ '<a href="javascript:window.close();" class="clvClose">close</a></div>';


function getHelpCenterInnerHtml(width,height,name)
{

	if (document.getElementById("DivHelpCenter").className=="DivSelected")
		contentbody = document.getElementById("DivHelpCenter").innerHTML;

	contentbody = contentbody.replace(/DISPLAY: none/g,"display: ''");
    contentbody = contentbody.replace(/display: none/g,"display: ''");
	contentbody = contentbody.replace(/<SPAN>Print/g,"<SPAN>");
    contentbody = contentbody.replace(/<span>Print/g,"<span>");
    contentbody = contentbody.replace(/IMG /g,"IMG style=\"display:none; \"");
    contentbody = contentbody.replace(/img /g,"img style=\"display:none; \"");

    var content = CONTENT_TOP+contentbody+"</body></html>";
    HCPositionedWin(width,height,name,content);
    return false;
}

function getGlossaryInnerHtml(width,height,name)
{
	contentbody = document.getElementById("letterList").innerHTML;

	contentbody = contentbody.replace(/"BackTop"/g,"\"\"");
	var content = CONTENT_TOP+"<ul><a name='goTop'></a>"+contentbody+"</ul>"+"</body></html>";
	HCPositionedWin(width,height,name,content);
	return false;

}

function getContactUsInnerHtml(width,height,name)
{
	contentbody = document.getElementById("contactSection").innerHTML;
    var content = CONTENT_TOP+"<ul>"+contentbody+"</ul>"+"</body></html>";
    HCPositionedWin(width,height,name,content);
    return false;
}


/*This function select the Request Information Tab on Top Nav*/
function SelectRequestTab()
{
	Namer = "showRequestByEmail";
	if (document.getElementById(Namer) != null){
		var number = document.getElementById(Namer).className.charAt(6);
	try{
		document.getElementById(Namer).className = "option" + number + "Over";
	}catch (err){}
	}

}


/********GLOSSARY SEARCH BUTTON*********/
//search for a term in the glossary
//param word ==
function WordSearch(word, int1)
{
	word= word.trim();
	if(word != " ")
	{
		word= word.toLowerCase();
		var bool= false;

		//82 is the number of the elements in the glossary
		//if a element is add it or delete it, this number must be changed
		while(int1 <= 83)
		{
			selectedElement  = document.getElementById("Title"+ int1);
			var strings = selectedElement.innerHTML;
			strings = strings.toLowerCase();
			var Text = strings.search(word);

			//if the term is found
			if(Text != -1)
			{
				clickTrack({pageName: 'PONTIAC | DIVISIONAL | HELP CENTER | GLOSSARY', prop1:'DIVISIONAL', prop2:'HELP CENTER', prop3:'DIVISIONAL | HELP CENTER', prop4: 'GLOSSARY', prop5:'HELP CENTER | GLOSSARY', prop6: 'DIVISIONAL | HELP CENTER | GLOSSARY', prop7:'RESULTS', prop8: 'GLOSSARY | RESULTS', prop9: 'HELP CENTER | GLOSSARY | RESULTS', prop10: 'DIVISIONAL | HELP CENTER | GLOSSARY | RESULTS', prop11: word.toUpperCase(), prop12: 'RESULTS | ' + word.toUpperCase(), prop13:'GLOSSARY | RESULTS | ' + word.toUpperCase(), prop14: 'HELP CENTER | GLOSSARY | RESULTS | ' + word.toUpperCase(), prop15:'DIVISIONAL | HELP CENTER | GLOSSARY | RESULTS | ' + word.toUpperCase(), prop17:'LEARN MORE', prop18:'RESEARCH', prop19: '', prop22: word.toUpperCase(), prop24:'EN', prop25:'PONTIAC', prop26:(new Date()).getHours(), prop27: weekday[(new Date()).getDay()]});
				document.getElementById('int').value = int1;
				selectedElement.innerHTML =  selectedElement.innerHTML + " " + "<span onClick='return nextMatch()' class='LabelLink' >Next Match</span>";
				location.href = "#" + document.getElementById("Title"+ int1).id;
				bool = true;
				break;
			}
			Text ="";
			int1++;
		}

		//if the term is not found a msg error is displayed
		if(bool == false)
		{
			clickTrack({pageName: 'PONTIAC | DIVISIONAL | HELP CENTER | GLOSSARY', prop1:'DIVISIONAL', prop2:'HELP CENTER', prop3:'DIVISIONAL | HELP CENTER', prop4: 'GLOSSARY', prop5:'HELP CENTER | GLOSSARY', prop6: 'DIVISIONAL | HELP CENTER | GLOSSARY', prop7:'NO RESULTS', prop8: 'GLOSSARY | NO RESULTS', prop9: 'HELP CENTER | GLOSSARY | NO RESULTS', prop10: 'DIVISIONAL | HELP CENTER | GLOSSARY | NO RESULTS', prop11: word.toUpperCase(), prop12: 'NO RESULTS | ' + word.toUpperCase(), prop13:'GLOSSARY | NO RESULTS | ' + word.toUpperCase(), prop14: 'HELP CENTER | GLOSSARY | NO RESULTS | ' + word.toUpperCase(), prop15:'DIVISIONAL | HELP CENTER | GLOSSARY | NO RESULTS | ' + word.toUpperCase(), prop17:'LEARN MORE', prop18:'RESEARCH', prop19: '', prop22: word.toUpperCase(), prop24:'EN', prop25:'PONTIAC', prop26:(new Date()).getHours(), prop27: weekday[(new Date()).getDay()]});
			alert("Your search returned no results.  Please modify your request and search again");
		}
	}
	return false;
}

//each time the user click Glossary search, this function removes the "next match" word if exist
function FirstSearch(word, int1)
{
	DeleteLabel(int1);
	//set the word of the item
	document.getElementById('int').value = 1;
	WordSearch(word, 1);
	return false;
}

//when the user clicks on the "next match", the next match word is removed and the next word is selected
function nextMatch()
{
	var int1 = document.getElementById('int').value;
	DeleteLabel(int1);
	int1++;
	WordSearch(document.getElementById('TextSearch').value, int1);
	return false;
}



//Remove the label "Next Match"
function DeleteLabel(int1)
{
	var text = document.getElementById("Title"+ int1).innerHTML;
	text = text.split("<");
	document.getElementById("Title"+ int1).innerHTML = text[0];
}

/*Request Thanks links*/
function buildLink(model){
	var link = BASE_CONTEXT + "/showModelOverview";
	var modelWithoutSpaces=model.replace(/[ ]+/g, "");
	if (modelWithoutSpaces=="GrandPrix"){
		modelWithoutSpaces='Grandprix';
	}
	window.location = link + modelWithoutSpaces + ".do";
}


function  changeClass(Element){
//  var  current_class = Element.className.split(' ').slice(-1)
   var  current_class = Element.className;

  if(current_class=='openlanguage'){
       Element.removeClass("openlanguage");
       Element.addClass("closedlanguage");
   }
    if(current_class=='closedlanguage'){
        Element.removeClass("closedlanguage");
     	Element.addClass("openlanguage");
     }
}
function loadAll(){

	try{
		new MultipleOpenAccordion($$('.closedlanguage'), $$('.thelanguage'), {
		  openAll: false,wait:true,duration:400,firstElementsOpen:[]
		});
	}catch(err){}

	SelectMenuItem();
}


function download(value){
	var filename = '/content/en/PDF/2008/brochures/' + value;
	$('goLink').href = BASE_CONTEXT + '/fileDownload.do?filename=' + filename;
}

function questionsTracking(section, questionID){
		clickTrack({pageName: 'PONTIAC | DIVISIONAL | HELP CENTER | FAQ', prop1:'DIVISIONAL', prop2:'HELP CENTER', prop3:'DIVISIONAL | HELP CENTER', prop4: 'FAQ', prop5:'HELP CENTER | FAQ', prop6: 'DIVISIONAL | HELP CENTER | FAQ', prop7: section.toUpperCase(), prop8: 'FAQ | ' + section.toUpperCase(), prop9: 'HELP CENTER | FAQ | ' + section.toUpperCase(), prop10: 'DIVISIONAL | HELP CENTER | FAQ | ' + section.toUpperCase(), prop11: readQuestionContent(questionID), prop12: section.toUpperCase() + ' | ' + readQuestionContent(questionID), prop13:'FAQ | ' + section.toUpperCase() + ' | ' + readQuestionContent(questionID), prop14: 'HELP CENTER | FAQ | ' + section.toUpperCase() + ' | ' + readQuestionContent(questionID), prop15:'DIVISIONAL | HELP CENTER | FAQ | ' + section.toUpperCase() + ' | ' + readQuestionContent(questionID), prop17:'LEARN MORE', prop18:'RESEARCH', prop19: '', prop24:'EN', prop25:'PONTIAC', prop26:(new Date()).getHours(), prop27: weekday[(new Date()).getDay()]});
}
function termsTracking(term){
		clickTrack({pageName: 'PONTIAC | DIVISIONAL | HELP CENTER | GLOSSARY', prop1:'DIVISIONAL', prop2:'HELP CENTER', prop3:'DIVISIONAL | HELP CENTER', prop4: 'GLOSSARY', prop5:'HELP CENTER | GLOSSARY', prop6: 'DIVISIONAL | HELP CENTER | GLOSSARY', prop7: 'POP-UP', prop8: 'GLOSSARY | POP-UP', prop9: 'HELP CENTER | GLOSSARY | POP-UP', prop10: 'DIVISIONAL | HELP CENTER | GLOSSARY | POP-UP', prop11: term.toUpperCase(), prop12: 'POP-UP | ' + term.toUpperCase(), prop13:'GLOSSARY | POP-UP | ' + term.toUpperCase(), prop14: 'HELP CENTER | GLOSSARY | POP-UP | ' + term.toUpperCase(), prop15:'DIVISIONAL | HELP CENTER | GLOSSARY | POP-UP | ' + term.toUpperCase(), prop17:'LEARN MORE', prop18:'RESEARCH', prop19: '', prop24:'EN', prop25:'PONTIAC', prop26:(new Date()).getHours(), prop27: weekday[(new Date()).getDay()]});
}

function readQuestionContent(questionId){
	return document.getElementById(questionId).innerHTML.toUpperCase();
}

AttachEvent(window, "load", loadAll);

