function popup(url, name, w, h, t, l, s) {
	newwindow = window.open(url, name, 'height=' + h + ',width=' + w + ',top=' + t + ',left=' + l + ',scrollbars=' + s);
	if (window.focus) {
		newwindow.focus()
	}
	return false;
}

function inputOnFocus(obj, defVal) {
	if(obj.value == defVal) {
		obj.value = '';
		obj.style.color = '#000';
	}
}

function inputOnBlur(obj, defVal) {
	if(obj.value == '') {
		obj.value = defVal;
		obj.style.color = '#999';
	}
}

function uncheck() {
	var chb = document.getElementById("chb_agree");
	if (chb.getAttribute("checked")) {
		chb.removeAttribute("checked");
	}
}

function agree() {
	var btn = document.getElementById("btn_submit");
	if (btn.getAttribute("disabled")) {
		btn.removeAttribute("disabled");
	}
	else {
		btn.setAttribute("disabled", "disabled");
	}
}


//for comments

function checkLength(id) {
	var post = document.getElementById(id);
	var postLength = post.value.length;
	if (postLength <= 3) {
		alert("შეიყვანეთ სამზე მეტი სიმბოლო");
		return false;
	}
	else {
		return true;
	}
}


function checkWords() {

	var words = [];
	words = document.getElementById("txt_comment").value.split(' ');

	var maxchar = 30;

	for (var i = 0; i < words.length; i++) {
		if (words[i].length > maxchar) {

			document.getElementById("txt_comment").value = "";

			for (var j = 0; j < words.length; j++) {
				if (words[j].length > maxchar)
					document.getElementById("txt_comment").value += words[j].substring(0, 27) + "... ";
				else
					document.getElementById("txt_comment").value += words[j] + " ";
			}
		}
	}
}

