﻿// JavaScript Document

/*function changeURL(url, note)
{
	var root = url.substring(0,15);
	var lang_choose = url.substring(15,17);
	var last = url.substring(17);
	
	if ( lang_choose == "en")
	{
		document.getElementById("english").setAttribute("class", "current");
	} else if ( lang_choose == "in")
			{
				document.getElementById("bahasa").setAttribute("class", "current");
			} else if ( lang_choose == "cn")
					{
						document.getElementById("chinese").setAttribute("class", "current");
					}
	
	if (note=="")
	{
		document.getElementById('bahasa').href=root+"in"+last;
		document.getElementById('bahasa').innerHTML="Bahasa";
		document.getElementById('chinese').href=root+"cn"+last;
		document.getElementById('chinese').innerHTML="Chinese";
		document.getElementById('english').href=root+"en"+last;
		document.getElementById('english').innerHTML="English";
	}
	else
	{
		document.getElementById('bahasa').href=root+"in"+last+"?"+note;
		document.getElementById('chinese').href=root+"cn"+last+"?"+note;
		document.getElementById('english').href=root+"en"+last+"?"+note;
		document.getElementById('bahasa').innerHTML="Bahasa";
		document.getElementById('chinese').innerHTML="中文";
		document.getElementById('english').innerHTML="English";
	}		
	return add_url;
}*/
function changeURL()
{ 
	document.getElementById("language").style.display="none";
	//alert(document.getElementById("language").innerHTML);
	url2 = window.location.href;//alert(url2);
	if(url2.match(/\tapisteknik.com(.+)/)){
		//alert(cop);
		cop = url2.match(/\tapisteknik.com(.+)/)[1];
		document.getElementById("english").setAttribute("class", "current");
		addURL(cop);
	}else if(url2.match(/\tapisteknik.com\/in(.+)/)){
		cop = url2.match(/\tapisteknik.com\/in(.+)/)[1];
		//alert(cop);
		document.getElementById("bahasa").setAttribute("class", "current");
		addURL(cop);
	}else if(url2.match(/\tapisteknik.com\/cn(.+)/)){
		cop = url2.match(/\tapisteknik.com\/cn(.+)/)[1];
		document.getElementById("chinese").setAttribute("class", "current");
		addURL(cop);
	}
}
function addURL(cop){
	document.getElementById('bahasa').href="/in"+cop;
	document.getElementById('chinese').href="/cn"+cop;
	document.getElementById('english').href=cop;
	document.getElementById('bahasa').innerHTML="Bahasa";
	document.getElementById('chinese').innerHTML="中文";
	document.getElementById('english').innerHTML="English";
}


/*collapse-expand*/
var Site = {
	
	start: function(){
		if($('vertical')) Site.vertical();
	},
	
	vertical: function(){
		var list = $$('#vertical .collapse-head div.collapse');
		var headings = $$('#vertical .collapse-head p.subtitle');
		var collapsibles = new Array();
		
		headings.each( function(heading, i) {

			var collapsible = new Fx.Slide(list[i], { 
				duration: 500, 
				transition: Fx.Transitions.linear,
				onComplete: function(request){ 
					var open = request.getStyle('margin-top').toInt();
					//if(open >= 0) new Fx.Scroll(window).toElement(headings[i]);
				}
			});
			
			collapsibles[i] = collapsible;
			
			heading.onclick = function(){
				var span = $E('span', heading);

				if(span){
					var newHTML = span.innerHTML == '[+]' ? '[&ndash;]' : '[+]';
					span.setHTML(newHTML);
				}
				
				collapsible.toggle();
				return false;
			}
			
			collapsible.hide();
			
		});			
	}
};
window.addEvent('load',function(){
    //alert('load');
	Site.start;
    changeURL();
}); 