<!--Created by Le Hoang Nhan-->
<!--Dated: 06/10/2008-->
<!--Support for index-->

function chooseMenu(menu, text) {
	document.getElementById('menu_'+menu_selected).className = 'left_menu';
	document.getElementById(menu).className = 'left_menu_selected';
	menu_selected = text;
}

function changeLanguage(mod, lang) {
		str = new String(mod);			
		if ( str.indexOf('#') == -1 ) {
			str = 'home';
		}
		var str_mod = str.substr(str.indexOf('#')+1, str.length);	
		/*alert(str_mod.indexOf('/'));	*/	
		if ( str_mod.indexOf('/') != -1 ) {	// 		
			var str_mod1 = str_mod.substr(0, str_mod.indexOf('/'));				
			if ( str_mod1 != 'products' ) {						
				str_mod = str_mod.substr(0, str_mod.indexOf('/'));
			}			
			if ( str_mod1 == 'search' ) {					
				str_mod = str.substr(str.indexOf('#')+1, str.length);				
			}
			if ( str_mod1 == 'product_details' ) {					
				str_mod = str.substr(str.indexOf('#')+1, str.length);				
			}			
		}		
		
		location.href = "language.php?str_mod="+str_mod+"&str_lang="+lang;		
		
		
	}

function validate(myfield, e)
{
	var key;
	var keychar;

	if (window.event) {
   		key = window.event.keyCode;
	}
	else if (e) {
	   key = e.which;
	}
	else {
	   return true;
	}
	keychar = String.fromCharCode(key);

	// control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) {
   		return true;
	}
	// letters or numbers
	else if ((("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_@").indexOf(keychar) > -1)) {
	   return true;
	}
	else {
   		return false;
	}
}
function change_style(flag, mod) {
	//document.getElementById('td_home').className = "main_menu_home";	
	var arr_links = new Array("home", "fashtion", "cafe", "cakes", "baby", "intro");	
	for ( j = 0; j < arr_links.length; j++ ) {
		document.getElementById('td_'+arr_links[j]).className = 'menu_'+arr_links[j];
	}
	var class_name = "menu_"+mod;
	var class_name_over = "menu_"+mod+"_selected";
	var obj = eval("document.getElementById('td_"+mod+"')");
	if ( flag == 1 ) {
		obj.className = class_name_over;
	}
	if ( flag == 0 ) {
		
		document.getElementById('td_'+selected_menu).className = "_menu_"+selected_menu+"_selected";
	}
}

function doEnter(evt){
	// IE					// Netscape/Firefox/Opera
	if(evt.keyCode == 13 || evt.which == 13){
		doSearch();
	}
}
function doSearch() {
		var key = document.frmSearch.txtSearch.value;
		location.href = "./#result_search/"+key.replace("/", "&frasl;");
		loadPage(document.location);		
}

function displayNews() {
	if(document.getElementById("div_news").style.display == "inline") {
		document.getElementById("div_news").style.display = "none";
	}
	else {
		document.getElementById("div_news").style.display = "inline";
	}
}

function bookmarksite(){
	if (document.all)
	window.external.AddFavorite(location.href, document.title);
	else if (window.sidebar)
	window.sidebar.addPanel(document.title, location.href, "");
}

function mailtofriend(links) {
	new_win = window.open("mail2friend.php?url="+encodeURIComponent(links.href),"win2","toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=490,height=300,left = 200,top = 100");
	new_win.focus();
}

