function t_ob(obj_id){return document.getElementById(obj_id);}
function show_o(id, show){if (show) show = 'block'; else show = 'inline'; t_ob(id).style.display = show;}
function hide_o(id){t_ob(id).style.display = 'none';}
function sh_o(id, show){if (t_ob(id).style.display == 'none') show_o(id, show); else hide_o(id);}

function wr(str){return document.writeln(str);}
function confirm_entry(b, d){
	input_box=confirm(d);
	if (input_box == true){
		window.location.href = b;
	}
}
function checkit(box){
	box = t_ob(box);
	if (box && box.checked){
		if (box.type != 'radio') box.checked = false;
	}else{
		box.checked = true;
	}
	box.focus();
}

function ins_uml(ao){
	if (ao == 'a') ao = auml; else ao = ouml;

	var act_obj = t_ob(act_inp_id);
	act_obj.focus();
	if (document.selection){
		document.selection.createRange().text = ao;
	}else{
		if (act_obj.selectionStart || act_obj.selectionStart == "0"){
			var startPos = act_obj.selectionStart;
			var endPos = act_obj.selectionEnd;
			var chaineSql = act_obj.value;
			act_obj.value = chaineSql.substring(0, startPos) + ao + chaineSql.substring(endPos, chaineSql.length);
			act_obj.setSelectionRange(startPos+1,endPos+1);
		}else{
			act_obj.value += ao;
		}
	}
}

var w_width = 0;
function get_w_size(){
	var win_width = 0;

	if(typeof(window.innerWidth) == 'number'){
		win_width = window.innerWidth;
	}else{
		if(document.documentElement && document.documentElement.clientWidth){
			win_width = document.documentElement.clientWidth;
		}else{
			if(document.body && (document.body.clientWidth))
				win_width = document.body.clientWidth;
		}
	}
	w_width = win_width;
}

function mouse_pos(){
	//
}

var curtop, curleft;
curleft = curtop = 0;
function obj_pos(obj){
	curleft = curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop;
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
}

function show_hint(me){
	show_o('hint',1);
	
	obj_pos(me);
	t_ob('hint').style.top = curtop - 26;

	if (w_width && w_width < curleft+150+36) curleft = w_width-150-36;
	t_ob('hint').style.left = curleft+6;

	t_ob('hint').innerHTML = me.title;
	me.title = '';
}

function hide_hint(me){
	hide_o('hint');

	t_ob('hint').style.top = '0';
	t_ob('hint').style.left = '0';

	me.title = t_ob('hint').innerHTML;
	t_ob('hint').innerHTML = '';
}

function hint_acronyms(){
	var all_acrs = document.getElementsByTagName('acronym');
	for (var i=0;i<all_acrs.length;i++){
	    	if (all_acrs[i].title){
				all_acrs[i].onmouseover = function(){show_hint(this);}
				all_acrs[i].onmouseout = function(){hide_hint(this);}
	    	}
	}
}

var s_preload;
s_preload = new Image;
var divs_id;
var imgs_nu;
function photos_show(hr,num){
	var params = hr.id.split('wmw');

	for (var i=1;i<=num;i++){
		if (i <= 9) 
			t_ob(params[0]+'wmw'+i).className = 'light_blue';
	}
	hr.className = 'dark_blue';
	t_ob(params[0]).style.borderColor = '#999';
	t_ob(params[0]).innerHTML = '';
	
	s_preload = new Image;
	s_preload.src = '/photo_store/'+params[0]+'/'+params[1]+'_s.jpg';
	divs_id = params[0];
	imgs_nu = params[1];
	load_show();
}

function load_show(){
	if (s_preload.complete){
		t_ob(divs_id).style.borderColor = '#fff';
		t_ob(divs_id).innerHTML = '<a href="/photos/index.php?photos='+divs_id+'&i_id='+imgs_nu+'"><img src="'+s_preload.src+'"></a>';
	}else setTimeout('load_show()',300);
}

function http_links(){
	var all_links = document.getElementsByTagName('a');
	for (var i=0;i<all_links.length;i++){
	    	if (all_links[i].href.indexOf("#http://") > 0){
				all_links[i].href = 'http://'+all_links[i].href.substr(all_links[i].href.indexOf("#http://")+8);
				all_links[i].target = '_blank';
				all_links[i].className = 'out';
	    	}
	}
	hint_acronyms();
	get_w_size();
	if (typeof improve_ans == 'function') improve_ans();
}
window.onload = http_links;
window.onresize = get_w_size;
