/*	 Copyright (c) SEIKO EPSON CORPORATION 2013. All rights reserved. */

var onLoad = false;

var EpUtil =
{
 	ConsoleLog:function (log){
	/* For Debug */
	/*		if(typeof console === 'undefined') 
				return;
	  		console.log(log);
	*/
	}


,	GetBrowserLanguage:function(){
			EpUtil.ConsoleLog('call:GetBrowserLanguage');
			var lang = '';
			if(document.all)
				lang = navigator.browserLanguage;
			else if(document.layers)
				lang = navigator.language;
			else if(document.getElementById)
				lang = navigator.language;

			if((lang.substring(0, 2) == 'zh') || lang.substring(0, 2) == 'ZH')
				lang=lang.replace(/-/g, '_');
			else
				lang = lang.substring(0, 2);

			if(lang == '')
				lang = 'en';

			return lang;
		}

};

var EpDataCtrl =
{
	DataFile:'./js/epson_manual_data.'
,	NeedWindowUpdate:false
,	lang_id:''
,	model_code:''
,	isIEUnder9:false

,	SetModelCode:function(new_model_code){
		if(EpDataCtrl.model_code == new_model_code)
			return;

		EpLeftMenuView.ChangeModelCodeMenu(EpDataCtrl.model_code.replace(/\x2f/g, '_'), new_model_code.replace(/\x2f/g, '_'));

		EpDataCtrl.model_code = new_model_code;

		EpMainManView.CreateMainContents();
		EpMainManView.DsiplayMainContents();

	}

,	SetInitialEnviroment:function(){
		EpUtil.ConsoleLog('call:SetInitialEnviroment');
		var hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		var lang = '';
		var code = '';
		for(var i = 0; i < hashes.length; i++) {
			hash = hashes[i].split('=');
			switch(hash[0]) {
				case 'LANG':
					lang = hash[1];
					break;
				case 'CODE':
					code = hash[1];
					break;
			}
		}

		if(lang == ''){
			lang = EpUtil.GetBrowserLanguage();
			var codestr = '';
			if(code != ''){
				codestr = '&CODE=' + code;
			}
			lang = lang.toLowerCase();
			window.location.href = './index.html?LANG=' + lang + codestr;
		}

		lang = lang.toLowerCase();
		EpDataCtrl.lang_id = lang;
		EpDataCtrl.model_code = code;
		EpDataCtrl.isIEUnder9 = IsIEUnderVersion9();
	}

,	SetLanguageId:function(in_lang_id){
		var isSupportedLang = false;
		if(EpDataCtrl.isEnableModelData()){
			for(var i = 0; i < EpsonSupportLanguageList.length; i++){
				if(EpsonSupportLanguageList[i] == in_lang_id){
					isSupportedLang = true;
					break;
				}
			}
		}
		if(isSupportedLang)
			EpDataCtrl.lang_id = in_lang_id;
		else
			EpDataCtrl.lang_id = 'en';

	}


,	isCommnLangDataLoaded:false
,	JSFile_CommonLang:''
,	LoadCommonLangData:function(){
		EpDataCtrl.isCommnLangDataLoaded = false;
		EpDataCtrl.NeedWindowUpdate = true;
		EpUtil.ConsoleLog('call:LoadCommonLangData');
		EpDataCtrl.JSFile_CommonLang = EpDataCtrl.DataFile + EpDataCtrl.lang_id + '.js'
		EpDataCtrl.JavaScriptLoader(EpDataCtrl.JSFile_CommonLang , 
			function(value) {
				EpUtil.ConsoleLog('INFO:load' + EpDataCtrl.JSFile_CommonLang);
				EpDataCtrl.isCommnLangDataLoaded = true;
				EpDataCtrl.RequestWindowUpdate();
			});
	}
,	isEnableCommonLangData:function(){
		if((typeof LangStrList !== 'undefined')
			&& (LangStrList != "")
			&& (typeof UIIdStrList !== 'undefined')
			& (UIIdStrList != ""))
			return true;
		else
			return false;
	}

,	isModelDataLoaded:false
,	JSFile_Model: ''
,	LoadModelData:function(){
		EpDataCtrl.isModelDataLoaded = false;
		EpDataCtrl.NeedWindowUpdate = true;

		EpDataCtrl.JSFile_Model =EpDataCtrl.DataFile + EP_CD_CODE + '.js';

		EpUtil.ConsoleLog('call:LoadModelData');
		EpDataCtrl.JavaScriptLoader(EpDataCtrl.JSFile_Model, 
			function() {
				EpUtil.ConsoleLog('INFO:load' + EpDataCtrl.JSFile_Model);
				if(EpDataCtrl.isEnableModelData() == true){
					EpDataCtrl.SetLanguageId(EpDataCtrl.lang_id);
					EpDataCtrl.LoadLanguageDataFiles();
					EpDataCtrl.isModelDataLoaded = true;
				}
			});
	}

,	isEnableModelData:function(){
		if((typeof EpsonSupportLanguageList !== 'undefined')
			&& (EpsonSupportLanguageList != '')
			&& (typeof EpsonSpecificationMenuList !== 'undefined')
			&& (EpsonSpecificationMenuList != '')
			&& (typeof EpsonSpecificationCodeList !== 'undefined')
			&& (EpsonSpecificationCodeList != '')
			&& (typeof EpsonManualInfo	!== 'undefined')
			&& (EpsonManualInfo != '')
			&& (typeof DownloadLinkTBLInfo	!== 'undefined')
			&& (DownloadLinkTBLInfo != ''))
			return true;
		else
			return false;
	}

,	isModelLangDataLoaded:false
,	JSFile_ModelLoc: ['']
,	LoadModelLangData:function(){
		EpDataCtrl.isModelLangDataLoaded = false;
		EpDataCtrl.NeedWindowUpdate = true;
		EpUtil.ConsoleLog('call:LoadScriptManualStringData');
		EpDataCtrl.JSFile_ModelLoc = EpDataCtrl.DataFile + EP_CD_CODE +'.'+ EpDataCtrl.lang_id + '.js'
		EpDataCtrl.JavaScriptLoader(EpDataCtrl.JSFile_ModelLoc , 
			function() {
				EpUtil.ConsoleLog('INFO:load' + EpDataCtrl.JSFile_ModelLoc);
				EpDataCtrl.isModelLangDataLoaded = true;
				EpDataCtrl.RequestWindowUpdate();
		});
	}
,	isEnableModelLangData:function(){
		if((typeof EpsonManualFileTitleInfo !== 'undefined')
			&& (EpsonManualFileTitleInfo != '')
			&& (typeof LangDownloadLinkTBLInfo !== 'undefined')
			&& (LangDownloadLinkTBLInfo != ''))
			return true;
		else
			return false;
	}


,	isAllDataLoaded:function(){
		if((EpDataCtrl.isCommnLangDataLoaded == true) 
			&& (EpDataCtrl.isModelDataLoaded == true) 
			&& (EpDataCtrl.isModelLangDataLoaded == true)
			&& (EpDataCtrl.isEnableCommonLangData() == true)
			&& (EpDataCtrl.isEnableModelData() == true)
			&& (EpDataCtrl.isEnableModelLangData() == true)){
			return true;
		}
		else{
			return false;
		}
	}

,	LoadDataFiles:function(){
		EpDataCtrl.LoadModelData();
	}

,	LoadLanguageDataFiles:function(){
		EpDataCtrl.LoadCommonLangData();
		EpDataCtrl.LoadModelLangData();
	}

,	ReplaceLanguageData:function(new_lang_id){

		if(EpDataCtrl.isIEUnder9 == true){
			EpDataCtrl.SetLanguageId(new_lang_id);
			EpDataCtrl.ClearLangData();
			EpDataCtrl.UnloadJavaScript(EpDataCtrl.JSFile_CommonLang);
			EpDataCtrl.UnloadJavaScript(EpDataCtrl.JSFile_ModelLoc);

			EpDataCtrl.isCommnLangDataLoaded = false;
			EpDataCtrl.isModelLangDataLoaded = false;

			EpDataCtrl.LoadLanguageDataFiles();



		}
		else{
			var codestr = '';
			if(EpDataCtrl.model_code != ''){
				codestr = '&CODE=' + EpDataCtrl.model_code;
			}
			window.location.href = './index.html?LANG=' + new_lang_id + codestr;
		}


	}

,	ClearLangData:function(){
		LangStrList = '';
		UIIdStrList = '';
		EpsonManualFileTitleInfo = '';
		LangDownloadLinkTBLInfo = '';
	}

,	RequestWindowUpdate:function(){
		if(EpDataCtrl.NeedWindowUpdate == true){
			if(EpDataCtrl.isAllDataLoaded() == true){
				EpUtil.ConsoleLog('call:RequestWindowUpdate isAllDataLoaded');
				EpMainView.Initialize();
				EpDataCtrl.NeedWindowUpdate = false;
			}
		}
	}


,	UnloadJavaScript:function(jsFileName){
		var allscripts=document.getElementsByTagName('script')
		for (var i=allscripts.length; i>=0; i--){ 
			if (allscripts[i] 
				&& (allscripts[i].getAttribute('src') != null)
				&& (allscripts[i].getAttribute('src').indexOf(jsFileName)!= -1)){
				allscripts[i].parentNode.removeChild(allscripts[i]);
			}
		}

	}

,	JavaScriptLoader:function (jsFileName, callback){
		EpUtil.ConsoleLog('call:JavaScriptLoader:' + jsFileName);
		var sc = document.createElement('script');
		sc.type = 'text/javascript';
		sc.charset='utf-8';

		if(window.ActiveXObject) {
			sc.onreadystatechange = function() {
				if(sc.readyState == 'complete') callback(sc.readyState);
				if(sc.readyState == 'loaded') callback(sc.readyState);
			};
		} else {
			sc.onload = function() {
				callback('onload');
			};
		}
		sc.src = jsFileName;
		document.getElementsByTagName('head')[0].appendChild(sc);

	}


,	GetString_Language:function(langid){
		EpUtil.ConsoleLog('call:GetString_Language:' + langid);

		if((typeof LangStrList[langid] === 'undefined' )
			|| (LangStrList[langid] == '')){
			return langid;
		}
		else{
			return LangStrList[langid];
		}
	}

, 	GetLangMenuList:function(lang_menu){
		if(EpDataCtrl.isEnableModelData() == false)
			return lang_menu;

		jQuery.each(EpsonSupportLanguageList, function(){
				var lang_value = this;
				var lang_list = [];
				if(typeof EpsonDisplayLanguageList[lang_value] !== 'undefined'){
					lang_list[0] = EpsonDisplayLanguageList[lang_value][1];
					lang_list[1] = lang_value;
					lang_menu.push(lang_list);
				}

			});

		lang_menu.sort(function(a, b){
			return Number(a[0]) < Number(b[0]) ? -1 : 1; 
		});
	}

,	GetString_LangMenu:function(id){
		if((typeof EpsonDisplayLanguageList[id] === 'undefined')
			|| (EpsonDisplayLanguageList[id] == '')){
			return id;
		}
		else{
			return EpsonDisplayLanguageList[id][0];
		}
	}

,	GetManualInfo:function(manual_code){
		EpUtil.ConsoleLog('call:GetManualInfo');

		if((typeof EpsonManualInfo[manual_code] === 'undefined' ) 
			|| (EpsonManualInfo[manual_code].length == 0 )){
			EpUtil.ConsoleLog('ERROR:EpsonManualInfo[' + manual_code + '] is undefined');
			return false;
		}
		return EpsonManualInfo[manual_code];
	}

,	GetManualFileTitleInfo:function(manual_code){
		EpUtil.ConsoleLog('call:GetManualFileTitleInfo');

		if((typeof EpsonManualFileTitleInfo === 'undefined' )
			|| (typeof EpsonManualFileTitleInfo[manual_code] === 'undefined' )
			|| (typeof EpsonManualFileTitleInfo[manual_code] === 'undefined' )){
			EpUtil.ConsoleLog('ERROR:EpsonManualFileTitleInfo[' + manual_code + '] is undefined');
			return false;
		}

		return EpsonManualFileTitleInfo[manual_code][0];
	}

,	GetManualCodeList:function(){
		EpUtil.ConsoleLog('call:GetManualCodeList:' + EpDataCtrl.model_code);

		var man_code =[];
		
		if((typeof EpsonSpecificationCodeList === 'undefined')
			|| (EpDataCtrl.model_code == '')) {
			return man_code;
		}
		
		for (var i = 0; i <  EpsonSpecificationCodeList.length; i++){
			if (EpDataCtrl.model_code == EpsonSpecificationCodeList[i][0])	{
				for(var l=1; l < EpsonSpecificationCodeList[i].length; l++){

					if(EpsonSpecificationCodeList[i][l] != '')
						man_code.push(EpsonSpecificationCodeList[i][l]);
				}
			}
		}

		return man_code;
	}

,	GetDownloadLinkBlockCount:function(){
		if(EpDataCtrl.isEnableModelData() == false)
			return 0;

		return DownloadLinkTBLInfo.length;
	}

,	GetDownloadLinkTable:function(block_num,data_num){
		var get_default = false;

		if((EpDataCtrl.isEnableModelLangData())
			&& (typeof LangDownloadLinkTBLInfo[block_num][data_num] !== 'undefined')
			&& (LangDownloadLinkTBLInfo[block_num][data_num] != '')){
				return LangDownloadLinkTBLInfo[block_num][data_num] ;
		}
		else if((EpDataCtrl.isEnableModelData())
			&& (typeof DownloadLinkTBLInfo[block_num][data_num] !== 'undefined')
			&& (DownloadLinkTBLInfo[block_num][data_num] != '')){
			return DownloadLinkTBLInfo[block_num][data_num];
		}
		else{
			return '';
		}
	}

,	GetSpecificationMenuList:function(){
		if(typeof EpsonSpecificationMenuList !== 'undefined'){
			return EpsonSpecificationMenuList;
		}
		else
			return '';
	}

,	GetIdStringList:function(){
		if(typeof UIIdStrList !== 'undefined'){
			return UIIdStrList;
		}
		else
			return '';
	}

}

var EpDDLinkView = {

	CreateDDTable:function(){
		EpUtil.ConsoleLog('call:CreateDDTable');
		if(onLoad != true)
			return ;

		var blockCount = EpDataCtrl.GetDownloadLinkBlockCount();

		for(var i=0; i < blockCount; i++){
			var idname = '#'+ EpDataCtrl.GetDownloadLinkTable(i,0);
			var display = EpDataCtrl.GetDownloadLinkTable(i,1);

			if($(idname).length <= 0)
				continue;

			if(display == 'none' || display == ''){
				$(idname).hide();
				continue;
			}

			EpDDLinkView.WriteDDTableTitle('#dd_table_title_' + (i+1),
								EpDataCtrl.GetDownloadLinkTable(i,2));

			EpDDLinkView.WriteDDTableLink('#dd_table_link_' + (i+1),
								EpDataCtrl.GetDownloadLinkTable(i,3),
								EpDataCtrl.GetDownloadLinkTable(i,4));

			EpDDLinkView.WriteDDTableSupportOS('#dd_table_supportos_' + (i+1),
								EpDataCtrl.GetDownloadLinkTable(i,5));

			EpDDLinkView.WriteDDTableVersion('#dd_table_verstion_' + (i+1),
								EpDataCtrl.GetDownloadLinkTable(i,6));

			 $(idname).show();

		}
		return true;
	}


,	WriteDDTableTitle:function(idname, title){
		EpUtil.ConsoleLog('call:WriteDDTableTitle:' + idname);
		if($(idname).length <= 0)
			return;

		$(idname).html('');
		$(idname).append(title);

	}

,	WriteDDTableLink:function(idname, item, target){
		EpUtil.ConsoleLog('call:WriteDDTableLink:' + idname);
		if($(idname).length <= 0)
			return;

		if(item == '')
			return;

		var str = $(idname).html();
		if(target)
			str = '<a href="'+ item + '" target="' + target + '">' + str + '</a>';
		else
			str = '<a href="'+ item + '">' + str + '</a>';

		$(idname).html(str);

	}

,	WriteDDTableSupportOS:function(idname, os_list){
		EpUtil.ConsoleLog('call:WriteDDTableSupportOS:' + idname);
		if($(idname).length <= 0)
			return;

		var os = os_list.split(':');

		$(idname).html('');
		for(var i=0; i<os.length; i++){
			$(idname).append(os[i].replace(/ /g, '&nbsp'));

			if(i != (os.length - 1))
				$(idname).append('<br>');
		}
	}

,	WriteDDTableVersion:function(idname, version){
		EpUtil.ConsoleLog('call:WriteDDTableVersion:' + idname);
		if($(idname).length <= 0)
			return;

		$(idname).html('');
		$(idname).append(version);

	}

}

var EpMainView = 
{
	Initialize:function(){
		EpUtil.ConsoleLog('call:Initialize');

		if(onLoad != true)
			return false;

		var html_id_string = EpDataCtrl.GetIdStringList();
		jQuery.each(html_id_string, EpMainView.WriteIdLabel);

		// buttom image change

		if($('.bottom_of_content_body p').length){
			var label = $('#main_goto_top').text();
			if(label.length > 15){
	 			$('.bottom_of_content_body p').css(
					{'background' : 'url(css/jump_to_the_top_bg_2.png) no-repeat',
					 'width' : '200px'
					});
			}
			else{
	 			$('.bottom_of_content_body p').css(
					{'background' : 'url(css/jump_to_the_top_bg.png) no-repeat',
					 'text-align' : 'left',
					 'width' : '150px'
					});
			}
		}

		EpDDLinkView.CreateDDTable();

		EpMainManView.CreateMainContents();
		EpMainManView.DsiplayMainContents();

		return true;

	}

,	WriteIdLabel:function(label,string){
		EpUtil.ConsoleLog('call:EpMainView.WriteIdLabel: ' + label);
		if($('#' + label).length){
			$('#' + label).html('');
			$('#' + label).append(string);
		}else{
			EpUtil.ConsoleLog('ERROR:html[#' + label + '] is undefined');
		}
	}

, 	WriteLanguageMenuList:function(){
		EpUtil.ConsoleLog('call:WriteLanguageMenuList');

		$('#language_menus select').html('');

		var lang_menu =[];

		 EpDataCtrl.GetLangMenuList(lang_menu);

		jQuery.each(lang_menu, function(){
			var lang_value = this[1];
			var lang_str = EpDataCtrl.GetString_LangMenu(lang_value);

			var htm_str = '';
			var option_select = '';

			if(EpDataCtrl.lang_id == lang_value){
				option_select = ' selected=""';
			}
			htm_str='<option value="'+ lang_value +'"' + option_select + ' >' + lang_str + '</option>';
			$('#language_menus select').append(htm_str);
		});

	}

}

var EpMainManView = 
{
	CreateMainContents:function(){
		EpUtil.ConsoleLog('call:CreateMainContents');

		if($('#main_um_table .auto_ut_table').length ){	
			$('#main_um_table .auto_ut_table').remove();
		}
		if($('#main_st_table .auto_ut_table').length){	
			$('#main_st_table .auto_ut_table').remove();
		}

		if($('#main_tbl_title').length){
			$('#main_tbl_title').html('');
			$('#main_tbl_title').html(EpDataCtrl.model_code);
		}

		var man_code_list = EpDataCtrl.GetManualCodeList();
		jQuery.each(man_code_list,EpMainManView.WriteManualListTalbe);

		if($('#main_um_table tbody .auto_ut_table').length)
			$('#manual_section').show();
		else
			$('#manual_section').hide();

		if($('#main_st_table tbody .auto_ut_table').length)
			$('#sheets_section').show();
		else
			$('#sheets_section').hide();

	}

,	DsiplayMainContents:function(){
		EpUtil.ConsoleLog('call:DsiplayMainContents');

		if(EpDataCtrl.model_code){
			show_block = '#main_manuals';
			hide_block = '#main_help';
		}
		else{
			show_block = '#main_help';
			hide_block = '#main_manuals';
		}

		if($(show_block).length){
			 $(show_block).show();
		}else{
			EpUtil.ConsoleLog('ERROR:html[#' + show_block + '] is undefined');
		}

		if($(hide_block).length){
			 $(hide_block).hide();
		}else{
			EpUtil.ConsoleLog('ERROR:html[#' + hide_block + '] is undefined');
		}
	}

,	WriteManualListTalbe:function(num, manual_code){
		EpUtil.ConsoleLog('call:WriteManualListTalbe');
		
	 	var manualInfo = EpDataCtrl.GetManualInfo('mc_' + manual_code);
		if(manualInfo == false){
			return;
		}

		var title =  EpDataCtrl.GetManualFileTitleInfo('mc_' + manual_code);
		if(title == false || title == ''){
			return;
		}

		var rev = manualInfo[0];
		var category = manualInfo[1];
		var filename = manualInfo[2];
		var langs = manualInfo[3].split(':');

		var link = '';
		var section_name = ''

		if(category == 'UM'){
			link = '../Manuals/Manuals/';
			section_name = 'main_um_table';

		}
		else if( category == 'ST'){
			link = '../Manuals/Sheets/';
			section_name = 'main_st_table';
		}
		else{
			EpUtil.ConsoleLog('ERROR: UNKNOWN CATEGORY ___' + category);
			return;
		}

		link = link + filename;

		var tr_t = '<a href="' + link + '" target="Manual"><img src="./img/icon_pdf.gif">' + title + '</a>';
		tr_t = '<th>' + tr_t + '</th>';

		var tr_l = EpMainManView.WriteManualLanguage(langs);

		tr_l = '<td>' + tr_l + '</td>';

		var tr_rev = '<td>' + manual_code + rev + '</td>';
		var string = '<tr class="auto_ut_table">' + tr_t + tr_l + tr_rev + '</tr>';
		if($('table#' + section_name  +' tbody').length)
		{	
			$($('#' + section_name +' tbody')).append(string);
		}
	}

, 	WriteManualLanguage:function(langs){
		EpUtil.ConsoleLog('call:WriteManualLanguage:' + langs);

		var strings = '';

		jQuery.each(langs, function(num,instr){
			var langstr = EpDataCtrl.GetString_Language(instr);
			langstr=langstr.replace(/ /g, '&nbsp'); 
			strings = strings +  langstr;
			var lang = langs[num+1];
			if((typeof lang !== 'undefined') && (lang !== "")){
				strings = strings + ', ';
			}
		});

		return strings;
	}
}

var EpLeftMenuView =
{
	Initialize:function(){
		if($('#left_specification_list').length <= 0){
			EpUtil.ConsoleLog('ERROR:html[#' + left_specification_list + '] is undefined');
			return ;
		}

		$('#left_specification_list').html('');
		var MenuList = EpDataCtrl.GetSpecificationMenuList();
		if(MenuList == '')
			return;

		jQuery.each(MenuList,EpLeftMenuView.WriteLeftMenu);

		EpLeftMenuView.SetCurrentLeftMenu(EpDataCtrl.model_code.replace(/\x2f/g, '_'));
	}

,	WriteLeftMenu:function(i,spec_code)
	{
		EpUtil.ConsoleLog('call:WriteLeftMenu');
		var product = spec_code[0];
		var selected = false;

		if(product == '')
			return;

		if(product == EpDataCtrl.model_code)
			selected = true;

		EpLeftMenuView.WriteModelCodeTopMenu(product, selected);

	}

,	WriteModelCodeTopMenu:function(product,selected)
	{

		EpUtil.ConsoleLog('call:WriteModelCodeTopMenu:' + product);


		var id =  product.replace(/\x2f/g, '_'); 

		if($('#' + id).length){	
			return;
		}

		if($('#left_specification_list').length <= 0){
			EpUtil.ConsoleLog('ERROR:html[#' + left_specification_list + '] is undefined');
			return;
		}
		EpUtil.ConsoleLog('INFO:new id = #' + id);

		string = '';
		string += '<li style="position: static;" id="' + id + '">';

		if(EpDataCtrl.isIEUnder9 == true){
			string = string + '<a href="javascript:select_spec_code(\'' + product + '\');">';
		}
		else{
			string = string + '<a href="index.html?LANG=' + EpDataCtrl.lang_id +'&CODE=' + product + '">';
		}

		string += product
		string += '</a>'
		string += '</li>'

		string = string + '</ul></li>';

		$('#left_specification_list').append(string);
	}

,	 ChangeModelCodeMenu:function(currentCode, newCode){
		EpUtil.ConsoleLog('call:ChangeModelCodeMenu  to ' + newCode + ' from ' + currentCode);

		if(currentCode == newCode)
			return ;

		if($('.heroNavigation').length) {
			if($('#' + currentCode).length) {
				$('#' + currentCode).removeClass('current');
			}
		}

		EpLeftMenuView.SetCurrentLeftMenu(newCode);
	}

,	SetCurrentLeftMenu:function(code){

		EpUtil.ConsoleLog('call:SetCurrentLeftMenu');
		
		if($('.heroNavigation').length) {
			if($('#' + code).length) {
				$('#' + code).addClass('current');
			}
		};
	}
} 


function how_to_find_model_code()
{
	EpUtil.ConsoleLog('call:how_to_find_model_code');
	EpDataCtrl.SetModelCode('');

}


function Initialize()
{
	EpUtil.ConsoleLog('call:Initialize');
	
	EpDataCtrl.SetInitialEnviroment();
	EpDataCtrl.LoadDataFiles();

}

function change_html_lang(value)
{
	EpUtil.ConsoleLog('call:change_html_lang');
	EpDataCtrl.ReplaceLanguageData(value)
}

function select_spec_code(spec_code)
{
	EpUtil.ConsoleLog('call:select_spec_code:' + spec_code);
	EpDataCtrl.SetModelCode(spec_code);
}

window.onload = function() {

	EpUtil.ConsoleLog('call:window.onload');
	onLoad = true;

	EpMainView.WriteLanguageMenuList();
	EpLeftMenuView.Initialize();
	EpMainView.Initialize();

}

function IsIEUnderVersion9()
{
	var agnet =navigator.userAgent;  
	var msie,version_end; 
	var browserVersion=6; //default value

	msie = navigator.userAgent.indexOf("MSIE");

	if ( msie != -1 )
	{
	  version_end = agnet.indexOf(";",msie);
	  
	  browserVersion = agnet.substring(msie+5,version_end);
	  
	  if(browserVersion < 9)
		return true;
	}

	return false;

}
