function getObj(id,d)
{
	var i,x;  if(!d) d=document; 
	if(!(x=d[id])&&d.all) x=d.all[id]; 
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][id];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=getObj(id,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(id); 
	return x;
};


function ShowHideObject(obj, show){
	if (show == true){
		// getObj(obj).style.display = document.all ? "block" : "table-row";
		if (getObj(obj).tagName.toLowerCase() == "table"){
			getObj(obj).style.display = "table";
		} else {
			getObj(obj).style.display = "block";
		}
	} else {
		getObj(obj).style.display = "none";
	}
};

function TogleShowHideObject(obj){
	show = IsObjectHidden(obj);
	return ShowHideObject(obj, show);
}

function IsObjectHidden(obj){
	return (getObj(obj).style.display == "none");
}

function DisableEnableObject(obj, disabled){
	obj = getObj(obj);
	obj.disabled = disabled;
};

function DisableEnableObjectItem(obj, itemNameIndex, nextItemIndex, disabled){
	obj = getObj(obj);
	objItem = getObj(itemNameIndex);
	
	objItem.disabled = disabled;
	if (disabled){
		objItem.style.color = "gray";
		obj.onchange = "if (this.selectedIndex || this.options[this.selectedIndex].id == " + itemNameIndex + ") { this.selectedIndex = " + nextItemIndex + " };";
	} else {
		objItem.style.color = "";
		obj.onchange = "";
	}

};

function ShowHideObjectItem(obj, itemId, show){
	// obj = getObj(obj);
	objItem = getObj(itemId);

	if (show){
		objItem.style.display = "";
	} else {
		objItem.style.display = "none";
	}

};


function SlikaUp() {
        ba=arguments.length;
        URL=arguments[0];
        eval("page7 = window.open(URL, '" + 7 + "', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=1');");
}

function PopUp() {
        URL=arguments[0];
        nid=3;
        eval("page" + nid + " = window.open(URL, '" + nid + "', 'toolbar=0,location=0,statusbar=0,menubar=0,scrollbars=2,resizable=1,width=" + 600 + ",height=" + 500 + "');");
}

function PopUpCustom() {
        URL=arguments[0];
        HSIZE=arguments[1];
        VSIZE=arguments[2];
        nid=33;
        eval("page" + nid + " = window.open(URL, '" + nid + "', 'toolbar=0,location=0,statusbar=0,menubar=0,scrollbars=2,resizable=0,width=" + HSIZE + ",height=" + VSIZE + "');");
}

function move_in(slimg, img_name) {
	slimg.src=img_name;
}

function move_out(slimg, img_name) {
	slimg.src=img_name;
}

function DANES_goTo( url ) {
	window.location.href = url;
}

function floodprotect() {
alert("banned");
}

function GetParentNode(thisNode, parentLevel){
	if (parentLevel == null || parentLevel == 0) parentLevel = 1;

	returnNode = thisNode;
	var nodeCounter;
	
	for(nodeCounter = 0; nodeCounter < parentLevel; nodeCounter++){
		returnNode = returnNode.parentNode;
	}
	return returnNode;
}
  
function validate(pid, check_email, check_name)
{
	var emailcheck = true;
	var namecheck = true;
	if(check_email == 1)
		emailcheck = validateemail(document.getElementById('txt_email' + pid).value);
   		
	if(check_name == 1)
		namecheck = document.getElementById('txt_commenter' + pid).value?true:false;
   		
	if(emailcheck && namecheck){
		xajax_SubmitComment(xajax.getFormValues('comments_form' + pid));
	}
	else {
		if(!namecheck)
			document.getElementById('txt_commenter' + pid).style.background = '#FF0000';

		if(!emailcheck)
			document.getElementById('txt_email' + pid).style.background = '#FF0000';
	}
}
   
function validateemail(str) {
	var at="@";
	var dot=".";
	var lat = str.indexOf(at);
	var lstr = str.length;
	var ldot = str.indexOf(dot);
	if (str.indexOf(at)==-1){
		return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false;
	}

	if (str.indexOf(at,(lat+1))!=-1){
		return false;
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false;
	}

	if (str.indexOf(dot,(lat+2))==-1){
		return false;
	}
		
	if (str.indexOf(" ")!=-1){
		return false;
	}

	return true;
}
