

function showhide_elem(num, parentobj_id){

	for(var i=0; i<$(parentobj_id).childNodes.length; i++){
		$(parentobj_id).childNodes[i].style.display='none';
	}
	$(parentobj_id).childNodes[num].style.display='block';
}

function make_active(obj, parent_obj){

var temp = new Array();

	for(var i=0; i<parent_obj.childNodes.length; i++){
		temp = parent_obj.childNodes[i].className.split(' ');
		if(temp[1]=='active'){
			parent_obj.childNodes[i].className=temp[0];
		}
	}
	obj.className = obj.className+' active';
}

function logIn()
{
	$('login_form').set ('send', {onSuccess: ansLogin});
	$('login_form').send();
}

function ansLogin (res)
{
	ret = JSON.decode (res);
	if (ret['msg']) {
		alert (ret['msg']);
	}
	if (ret['success'] == 1) {
		window.location.reload();
	}
}

function logOut(domain)
{
	url = domain + '/user/?a=logout';
	var myAjax = new Request({
		method: 'get',
		url: url,
		onSuccess: logoutAnswer
	}).send();

}

function logoutAnswer(res)
{
	ret = JSON.decode (res);
	if (ret['msg']) {
		alert (ret['msg']);
	}
	if (ret['success'] == 1) {
		window.location.reload();
	}

}

function checkNIP( inputVal )
{
 	 if ( !inputVal.match( /^[0-9]{3}-[0-9]{3}-[0-9]{2}-[0-9]{2}$/ ) ){
 	 	return false;
 	 }
 	 var ar = inputVal.replace(/-/g,'');
	 var arg = inputVal.replace(/-/g,'');
 	 var coefficients = "657234567";
 	 var sum=0;
 	 var index=8;
 	 for (index=8; index>=0 ;index--){
 		 sum += (parseInt(coefficients.charAt(index)) * parseInt(arg.charAt(index)));
 	 }
 	 if ( (sum % 11) == 10 ? false : ((sum % 11) == parseInt(arg.charAt(9))) ){
   	 	return true;
  	 }

  return false;
}

function popap(link, width, height) {
  window.open(link, '_blank', 'channelmode=0,directories=0,fullscreen=0,height='+height+',left=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,top=0,width='+width);
}

function tweenObj(objId, param, paramVal){
	//var myFx = new Fx.Tween($(objId), {duration:200});
	//myFx.start(param, paramVal);
	$(objId).setStyle(param, paramVal);
}	
