function switchLang(lang, pos){
	var objEn = document.getElementById('lang_en');
	var objBm = document.getElementById('lang_bm');
	var objBEn = document.getElementById('langb1');
	var objBBm = document.getElementById('langb2');
	if(lang == 'en'){
		objEn.style.display = 'block';
		objBm.style.display = 'none';
		objBEn.setAttribute("class", "en ena");
		objBBm.setAttribute("class", "bm");
	}else{
		objEn.style.display = 'none';
		objBm.style.display = 'block';
		objBEn.setAttribute("class", "en");
		objBBm.setAttribute("class", "bm bma");
	}
	window.scrollTo(0, pos);
}

function hideNews(){
	document.getElementById('news').style.display = 'none';
	if(document.getElementById('flash') != null)
		document.getElementById('flash').style.display = 'block';
}
function showNews(){
	document.getElementById('news').style.display = 'block';
	if(document.getElementById('flash') != null)
			document.getElementById('flash').style.display = 'none';
}

function showCat(cur, max){
	for(var x = 1; x < max; x++){
		document.getElementById("pro_cat_list_"+x).style.display = x == cur ? "block" : "none"; // this is list layer
		document.getElementById("pro_cat_"+x).setAttribute("class", x == cur ? "pro_cat_over" : "pro_cat"); // this is button
		// change view
		if(cur == x){
				var tmp = document.getElementById("cat_first_item_"+x).value;
				var tmp2 = document.getElementById("max_item").value;
				showItem(tmp, tmp2);
		}
	}
	window.scrollTo(0,0);
}

function showItem(cur, max){
	if(document.getElementById("pro_cat_view_"+cur) != null){
	for(var x = 1; x <= max; x++){
		document.getElementById("pro_cat_view_"+x).style.display = x == cur ? "block" : "none"; // this is view
		document.getElementById("pro_cat_item_"+x).setAttribute("class", x == cur ? "pro_cat_item_over" : "pro_cat_item"); // this is button
	}
	}else{
		for(var x = 1; x <= max; x++){
			document.getElementById("pro_cat_view_"+x).style.display = "none"; // this is view
			document.getElementById("pro_cat_item_"+x).setAttribute("class", "pro_cat_item"); // this is button
		}
	}
	window.scrollTo(0,0);
}

//==========================================================================

function showBox(str){
	document.getElementById('pop_msg').innerHTML = str + "";
	fade('float', 600, 'show', 'display');
}

function hideBox(){
	fade('float', 600, 'hide', 'display');
	document.getElementById('pop_msg').innerHTML = "";
}

//==========================================================================

var __interval = .5;
var __DIR = 1;
var __HOLD = 0;
var __CUR = 1;
var __MAX = 1;
var __DELAY = 10000;

function slideL(){
	if(__HOLD == 0){
		__HOLD = 1;
		// do sliding to LEFT side
		if(__CUR != __MAX){
			//stop = -((960 * (__CUR - 1)) + 766); // the easing.............
			var myAnim = new YAHOO.util.Motion('slider', { points: { by: [-958, 0] } }, __interval);
			myAnim.animate();
			__CUR++;
		}else{
			//stop = 194; // the easing.............
			var stop = 958 * (__CUR - 1);
			var myAnim = new YAHOO.util.Motion('slider', { points: { by: [stop, 0] } }, __interval);
			myAnim.animate();
			__CUR = 1;
		}
		setTimeout("cont()", 1000);
	}
}

function slideR(){
	if(__HOLD == 0){
		__HOLD = 1;
		if(__CUR > 1){
			//stop = -(960 * (__CUR - 2)) + 194; // the easing.............
			var myAnim = new YAHOO.util.Motion('slider', { points: { by: [958, 0] } }, __interval);
			myAnim.animate();
			__CUR--;
		}else{
			//stop = -(960 * (__MAX - 1)) + 194; // the easing.............
			var stop = -(958 * (__MAX - 1));
			var myAnim = new YAHOO.util.Motion('slider', { points: { by: [stop, 0] } }, __interval);
			myAnim.animate();
			__CUR = __MAX;
		}
		setTimeout("cont()", 1000);
	}
}

function ani(){
	if(document.getElementById('slider') != null){
		setTimeout("getMax();", 1000);
		setTimeout("ani_run();", __DELAY);
	}
}

function getMax(){
		__MAX = parseInt(document.getElementById('sCount').value);
}

function ani_run(){
	if(document.getElementById('slider') != null){
		slideL();
	}
	setTimeout("ani_run()", __DELAY);
}

function hold(){
	__HOLD = 1;
}

function cont(){
	__HOLD = 0;
}

//============================================================

var __MAX_ = 1;
var __CUR_ = 1;

function ani2(){
	if(document.getElementById('slide_small') != null)
	setTimeout("getMax2();", 1000);
}

function getMax2(){
	__MAX_ = parseInt(document.getElementById('sCountR').value);
	if(__MAX_ > 1)
	startFade();
}

function startFade(){
	var _next = __CUR_ + 1;
	if(_next > __MAX_)
		_next = 1;
	//fade("sitem_"+ _next, 500, "show", "display");
	//fade("sitem_"+ __CUR_, 500, "hide", "display");
	document.getElementById("sitem_"+ _next).style.display = "block";
	document.getElementById("sitem_"+ __CUR_).style.display = "none";
	__CUR_ = _next;
	setTimeout("startFade()", 2500);
}

function slideUp(){
		if(__CUR_ != __MAX_){
			var myAnim = new YAHOO.util.Motion('slide_small', { points: { by: [0, -175] } }, __interval);
			myAnim.animate();
			__CUR_++;
		}else{
			//stop = 194; // the easing.............
			var stop = 175 * (__CUR_ - 1);
			var myAnim = new YAHOO.util.Motion('slide_small', { points: { by: [0, stop] } }, __interval);
			myAnim.animate();
			__CUR_ = 1;
		}
		setTimeout("slideUp()", 2500);
}









function fade(id, interval, action, type){	
	var obj = document.getElementById(id)
	if(type == 'display'){
		var cur_vis = (obj.style.display == null) ? 'block' : obj.style.display
	}else{
		type = 'visibility'; // set DEFAULT value in case of NULL
		var cur_vis = (obj.style.visibility == null) ? 'visible' : obj.style.visibility
	}
	var on = (type == 'display') ? 'block' : 'visible'	 // prepare value
	var off = (type == 'display') ? 'none' : 'hidden' // prepare value
	var next_vis, domath, next				
	if ( isIE() == true ){		// we call for IE fade filter
		switch (action){
			case 'tonggle':
				next_vis = ( cur_vis == 'block' || cur_vis == 'visible' ) ? off : on
			break;
			case 'show':
				if ( cur_vis == 'block' || cur_vis == 'visible' ) { return; }
				next_vis = on
			break;
			case 'hide':
				if( cur_vis == 'none' || cur_vis == 'hidden' ) { return; }
				next_vis = off
			break;	
		}
		var duration = interval / 1000 / 4		 // milisec to sec // BAHAGI 4 cuz IE VERY SLOW ... ???
		obj.setAttribute("style","filter:progid:DXImageTransform.Microsoft.Fade(duration="+duration+"); "+type+":"+cur_vis+";")
		obj.filters[0].apply()
		if(type == 'display'){
			obj.style.display = next_vis
		}else{
			obj.style.visibility = next_vis
		}
		obj.filters[0].play()	
	} else {	// we make a custom fading
		interval = (isNetscape() == true) ? interval * 2 : interval; // Firefox is abit faster ... ???
		switch (action){
			case 'tonggle':
				if ( cur_vis == 'block' || cur_vis == 'visible' ) {
					obj.setAttribute('alt','1')
					domath = 'minus'
				} else {
					obj.setAttribute('alt','0')
					domath = 'plus'
				}
			break;
			case 'show':
				if( cur_vis == 'block' || cur_vis == 'visible' ) { return; }
				obj.setAttribute('alt','0')
				obj.setAttribute('style','opacity:1;')	// put this, cuz obj maybe just HIDDEN, not transparent
				changeVis(id, on)
				domath = 'plus'
			break;
			case 'hide':
				if( cur_vis == 'none' || cur_vis == 'hidden' ) { return; }		
				obj.setAttribute('alt','1')
				changeVis(id, on)
				domath = 'minus'
			break;	
		}
		next = 1 / (interval / 400) // ???
		next.toFixed(2)
		customFade(id, next, domath, on, off)
	}				
}
//---------------------------------------------------------------------------------------------------------
function changeVis(id, value){
	if(value == 'block' || value == 'none'){
		document.getElementById(id).setAttribute('style', 'display:'+value+';')
	}else{
		document.getElementById(id).setAttribute('style', 'visibility:'+value+';')
	}
}

function isIE(){
	return ( navigator.appName == 'Microsoft Internet Explorer' ) ? true : false;
}

function isNetscape(){
	return ( navigator.appName == 'Netscape' ) ? true : false;
}
//---------------------------------------------------------------------------------------------------------
function customFade(id, next, domath, on, off){
	var obj = document.getElementById(id)
	var cur = parseFloat(obj.getAttribute('alt'))
	var opacity
	if ( domath == 'plus' ) {
		//obj.style.display = on // ??? why xtra ?
		opacity = cur - 0 + next					
		if( cur < 1 ){									
			obj.setAttribute('alt',opacity)
			obj.setAttribute('style','opacity:' + opacity + ';')				
			setTimeout("customFade('"+id+"',"+next+",'"+domath+"', '"+on+"' ,'"+off+"')",10)
		}
	} else {
		opacity = cur - next
		if( cur > next ){									
			obj.setAttribute('alt',opacity)
			obj.setAttribute('style','opacity:' + opacity + ';')				
			setTimeout("customFade('"+id+"',"+next+",'"+domath+"', '"+on+"' ,'"+off+"')",10)
		} else {
			changeVis(id, off)
		}
	}
	return
}
//---------------------------------------------------------------------------------------------------------
function ieFade(id, next_vis){
	var obj = document.getElementById(id)
	obj.filters[0].apply()
	changeVis(id, next_vis)
	obj.filters[0].play()
	return
}			
//---------------------------------------------------------------------------------------------------------
