/*
 Start of prototype addons
 */
String.prototype.trim = function(){
    return this.replace(/^\s+|\s+$/g, "");
}

String.prototype.ltrim = function(){
    return this.replace(/^\s+/, "");
}

String.prototype.rtrim = function(){
    return this.replace(/\s+$/, "");
}
/*
 End of prototype addons
 */

/*
 Start of menu rollover/rollout function
 */
	function rollover(id, flag) {		
		$(id).removeClassName('noact');
		$(id).addClassName('act');
		
		$(id + 'img').removeClassName('noactimg');			
		$(id + 'img').addClassName('actimg');
		
		$(id + 'imgsrc').src = 'http://www.sportnet.com.ua/images/'+id+'_icon_over.png';		
		if (!flag)
			$(id + 'imgsrc').src = 'http://www.sportnet.com.ua/images/'+id+'_icon_over.png';
		else
			$(id + 'imgsrc').src = 'http://www.sportnet.com.ua/images/square_icon_over.png';								
		
	}
	
	function rollout(id, flag) {
		$(id).removeClassName('act');
		$(id).addClassName('noact');
		
		$(id + 'img').removeClassName('actimg');
		$(id + 'img').addClassName('noactimg');
		
		if (!flag)
			$(id + 'imgsrc').src = 'http://www.sportnet.com.ua/images/'+id+'_icon.png';
			else
			$(id + 'imgsrc').src = 'http://www.sportnet.com.ua/images/square_icon.png';								
	}
/*
 End of menu rollover/rollout function
 */


/*
 Start of Comments functions
 */

function clearLoginForm() {
	$('usrlgn').value = '';
	$('usrpwd').value = '';
	$("addComment").hide();
}

function clearCommentForm() {
		$('error').update('');
		$('comment_textarea').value = '';
		$('parent_id').value = '';
		if ($("addComment").style.display == 'block')
		$("comment_textarea").focus();	
}

function toggleComment(){
	if ($("addComment").style.display == "") {
		$("addComment").hide();
	}
    else {
        $("addComment").show();        
    }
}

function toggleCommentAnswer(id){
	$("addComment").show();
	if ($('comment_textarea')) {
		$('comment_textarea').value = '';
		$("parent_id").value = id;
		$("comment_textarea").focus();
		$('error').update();
	}
	else {
		$("usrlgn").value = '';
		$("usrpwd").value = '';
		$("usrlgn").focus();
	}
}

function checkCommentForm(){
    err = '';
    $('send_btn').hide();
	if ($('comment_textarea').value.trim() == '') err  = 'Поле обязательно для заполнения!';
	
	if (err.trim()!='') {
		$('error').style.display = '';
		$('send_btn').show();
		$('error').update('<b>Обнаружены следующие ошибки:</b><ul><li>' + err + '</li></ul>');
		return false;
	}
	
	return true;
}

/*
 End of Comments functions
 */

function javascriptemail(u, d, s, w, subj){
	addon = '';
	if (subj != '') addon = '?subject=' + subj;
	document.write('<a href="' + 'mailto:' + u + '@' + d + '.' + s + addon+'">' + w + '</a>');
}

function changeClass(obj) {
	$('photobank_image').style.width = '502px';
	$('photobank_image').style.height = '377px';
	$('photobank_image').style.textAlign = 'center';	
	$('photobank_image').update('<br/><br/><br/><br/><br/><br/><br/><br/><br/><img src="http://www.sportnet.com.ua/images/update.gif" />');
	$$('#photobank_image_box a').each(function(node){		
		node.removeClassName('current');
		node.addClassName('list');
	});
		
	obj.removeClassName('list');
	obj.addClassName('current');
	
}


function showTvprogram(day) {
	for(i=0;i<7;i++) {
		$('day' + i).style.display = 'none';
		$('header' + i).style.backgroundColor = '#FFFFFF';
	}

	$('day' + day).style.display = 'block';
	$('header' + day).style.backgroundColor = '#bcbdd2';
}

function divOver(obj) {
	$$('#' + obj + ' TD').each(function(node) {
		node.style.backgroundColor = '#E8E8F0';
		node.style.cursor = 'hand';
		node.style.cursor = 'pointer';
	});
}

function divOut(obj) {
	$$('#' + obj + ' TD').each(function(node) {
		node.style.backgroundColor = '#FFFFFF';
	});
}

function doKey(e, ourform) {
  e = (window.event) ? event : e;
  var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;   
  if (keyCode == 13) ourform.submit(); else return true;
}

