function isInt (str) {
	var i = parseInt (str);
	if (isNaN (i)) return false;
	i = i . toString ();
	if (i != str) return false;
	return true;
}

function buildOnLoad() {
	for (lf=0 ; lf<loadFunctions.length ; lf++) {
		oldonLoad = window.onload;
		if (typeof(oldonLoad) == "function") eval("window.onload = function() {oldonLoad();" + loadFunctions[lf] +"};");
		else eval("window.onload = function() {" + loadFunctions[lf] +"};");
	}
}

function playFlv(width,height,flvId,objId) {
	if (!width) width = 320;
	if (!height) height = 240;
	height = eval(height) + 20;
	var s1 = new SWFObject("jwplayer/flvplayer.swf","single",width,height,"7");
	s1.addParam("allowfullscreen","true");
	s1.addVariable("enablejs","true");
	s1.addVariable("javascriptid",objId);
	//s1.addVariable("autostart","true");
	
	s1.addVariable("showdigits","total");
	s1.addVariable("file","../videos/flv/" + flvId + ".flv");
	//s1.addVariable("image","../showPhoto.php?cat=thumbs&photoId=" + flvId + "&width=" + width + "&height=" + height);
	s1.write(objId);
}

function sure(url) {
	if (confirm("Oletko varma?")) document.location.href = url;
}

function toggleDisp(obj,index) {
	if (index) {
		obj = obj.nextSiblings();
		obj = obj[0];
	}
	obj.style.display = obj.style.display == "block" ? "none" : "block";
}

function toggleVis(obj) {
	obj.style.visibility = obj.style.visibility == "hidden" ? "visible" : "hidden";
}

function hilite(obj,statex,bg) {
	if (!bg) obj.style.backgroundColor = statex ? "#f0f0f0" : "";
	else obj.style.backgroundImage = statex ? "url("+bg+")" : "";
}

function activateButton(obj,state) {
	params = obj.src.split("?");
	
	if (state) {
		obj.src = params[0] + "?" + params[1] + "&active=1";
 	}
	else {
		
		obj.src = params[0] + "?" + params[1].replace("&active=1","");
	}
}

function autoSuggest(obj,dbTable,dbCol,minChars) {
	var options = {
		script: "includes/autosuggest.php?dbTable=" + dbTable + "&dbCol=" + dbCol + "&",
		varname: "curVal",
		json: true,
		maxresults: 35,
		minchars: minChars ? minChars : 2
	};
	var as = new bsn.AutoSuggest(obj, options);
}

buildOnLoad();
