

function change(){
	document.AddForm.buttoncheck.setAttribute("disabled","true")
}

function checkAddNewOpinion(){
	title = document.AddForm.title.value;
    rates = document.AddForm.rates.value;
	//elm1 =  document.AddForm.elm1.value;
	
	if (title.length == 0)
		{
		alert('יש לכתוב כותרת');
		document.AddForm.title.focus();
		}
	else
	
/*	if (elm1.length == 0)
		{
		alert(elm1.length);
		alert('יש למלא תוכן לחוות הדעת שלך.\nבאפשרותך לכתוב מה דעתך, מה אהבת ומה לא אהבת.');
		document.AddForm.elm1.focus();
		}
	else*/
	
	if (rates==0 || rates=='')
		{
		alert('יש לדרג');
		document.AddForm.title.focus();
		}
	else{
		change();
		// addNewOpinionForm();
		document.AddForm.submit();
		}

}

function CheckAdding() {

	title = document.AddForm.title.value;
    rates = document.AddForm.rates.value;
	//elm1 =  document.AddForm.elm1.value;
	
	if (title.length == 0)
		{
		alert('יש לכתוב כותרת');
		document.AddForm.title.focus();
		}
	else
	
/*	if (elm1.length == 0)
		{
		alert(elm1.length);
		alert('יש למלא תוכן לחוות הדעת שלך.\nבאפשרותך לכתוב מה דעתך, מה אהבת ומה לא אהבת.');
		document.AddForm.elm1.focus();
		}
	else*/
	
	if (rates==0 || rates=='')
		{
		alert('יש לדרג');
		document.AddForm.title.focus();
		}
	else{
		change();
		document.AddForm.submit();
		}
		
	}
	
function addFV()	{
	if (document.all)
	window.external.AddFavorite(bookmarkurl,bookmarktitle)
}
	
	function sendIT(i) {
	window.open("../../$mails/?url=http://www.opinion.co.il/results/01/?w=movies,i="+i,"pop","width=350,height=380,resizable=no,status=yes,scrollbars=no");
	}
	
	// Notice: The simple theme does not use all options some of them are limited to the advanced theme
	// Powered By tinyMCE
	tinyMCE.init({
		mode : "textareas",
		theme : "simple",
		width : "100%", // 500
		height : "165",
		force_p_newlines : true
	});


	function changeFormSourceValue() {
		AddForm.userSource.value = AddForm.userSourceOnGs.value;
	}

var amount2=0;
function reloadOpinions(id, idDesc){
	if(amount2==0) {
		set_DEFAULT_orderBy(2);
		set_DEFAULT_otype(1);
	} amount2++;
	
	if(idDesc=="orderBy") {
			set_DEFAULT_orderBy(id);
			document.getElementById("opinionsList").innerHTML="";
			showOpinions(DEFAULT_id, DEFAULT_w, id, get_DEFAULT_otype(), DEFAULT_query, get_DEFAULT_sMin(), get_DEFAULT_sAge());
	} else 
		{ 
		if(idDesc=="otype") {
			set_DEFAULT_otype(id);
			document.getElementById("opinionsList").innerHTML="";
			showOpinions(DEFAULT_id, DEFAULT_w, get_DEFAULT_orderBy(), id, DEFAULT_query, get_DEFAULT_sMin(), get_DEFAULT_sAge());
		}else{
		if(idDesc=="twitter") {
			set_DEFAULT_otype(id);
			document.getElementById("opinionsList").innerHTML="";
			showTwitter(DEFAULT_id, DEFAULT_w, get_DEFAULT_orderBy(), id, DEFAULT_query, get_DEFAULT_sMin(), get_DEFAULT_sAge());
} else {
				document.getElementById("opinionsList").innerHTML="";
				showOpinions(DEFAULT_id, DEFAULT_w, get_DEFAULT_orderBy(), get_DEFAULT_otype(), DEFAULT_query, get_DEFAULT_sMin(), get_DEFAULT_sAge());
		}
		}
		}
	
}


function doAdvanceOpinions(sMin, sAge){
	if((sMin==0 || sMin==1 || sMin==2) && (sAge==0 || sAge==1 || sAge==2)) showOpinions(DEFAULT_id, DEFAULT_w, get_DEFAULT_orderBy(), get_DEFAULT_otype(), DEFAULT_query, sMin, sAge);
}

var urlOpinions = "http://www.opinion.co.il/results/global/showOpinions/default.asp"
function showOpinions(itemId, wid, orderBy, otype, query){
	var getTodayDate=new Date();
		curr_open=0;
		document.getElementById("opinionsList").innerHTML="";
		getInfo(urlOpinions + '?i=' + itemId + '&otype=' + otype + '&orderBy=' + orderBy + '&query=' + query + '&rand='+getTodayDate+'&w=' + wid,"block","opinionsList");	
}

var urlTwitter = "http://www.opinion.co.il/results/global/showOpinions/twitter.asp"
function showTwitter(itemId, wid, orderBy, otype, query){
	var getTodayDate=new Date();
		curr_open=0;
		document.getElementById("opinionsList").innerHTML="";
		getInfo(urlTwitter + '?i=' + itemId + '&otype=' + otype + '&orderBy=' + orderBy + '&query=' + query + '&rand='+getTodayDate+'&w=' + wid,"block","opinionsList");	
}

function showOpinions(itemId, wid, orderBy, otype, query, sMin, sAge){
	var getTodayDate=new Date();
		curr_open=0;
		document.getElementById("opinionsList").innerHTML="";
		getInfo(urlOpinions + '?i=' + itemId + '&otype=' + otype + '&orderBy=' + orderBy + '&query=' + query + '&smin='+sMin+'&sage='+sAge+'&rand='+getTodayDate+'&w=' + wid,"block","opinionsList");	
}

var urlRate = "http://www.opinion.co.il/results/global/rating/do.asp"
var amcount=0;
function rateThis(rateId, wid, sid){
	if(amcount==0){
		getInfo(urlRate + '?rateId=' + rateId + '&i=' + sid + '&w=' + wid,"block","thisRating");
		OpenOptions('i_thisRating');
	}
	amcount++;
}


var urlTodoUsers = "http://www.opinion.co.il/results/global/todo/do.asp"
function todoThis(statusId, itemId, wid){
		getInfo(urlTodoUsers + '?statusId=' + statusId + '&i=' + itemId + '&w=' + wid,"block","thisTodoUsers");
		//OpenOptions('i_thisRating');
}

var oneComment = "http://www.opinion.co.il/results/global/opinionpage_glb.asp"
function showOneComment(i, id, wid){
	var getTodayDate=new Date();
		getInfo(oneComment + '?sc=true&parm=1&rand='+getTodayDate+'&i=' + i + '&id=' + id + '&w=' + wid,"block","thisOneComment");
}

	var urlThumbUp = "http://www.opinion.co.il/results/global/thumbup/default.asp"
	var TUamcount=0;
	function thumbUpForComment(ic, wid, sid, acount){
		if(TUamcount==0){
			getInfo(urlThumbUp + '?ic=' + ic + '&i=' + sid + '&acount=' + acount + '&w=' + wid,"block","thumbup"+ic);
			OpenOptions('i_thisThumbup'+ic);
		}
	//	TUamcount++;
	}

	var urlAbuse = "http://www.opinion.co.il/results/global/abuse/default.asp"
	var ABSamcount=0;	
	function abuseComment(ic, wid, sid){
		if(ABSamcount==0){
			getInfo(urlAbuse + '?ic=' + ic + '&i=' + sid + '&w=' + wid,"block","abuse"+ic);
			OpenOptions('i_thisAbuse'+ic);
		}
	//	TUamcount++;
	}
	function disapp(dis_id){ 
	dis_id.style.display = "none";
	} 

	function appdiv(dis_id){ 
	dis_id.style.display = "block";
	} 
	

	function AddIcon1(area){
		area.focus();
		area.value += "[הדגש]";
	}

	function AddIcon2(area){
		area.focus();
		area.value += "[סדגש]";
	}

	function FormsAdd(some){
		if (some.value == ""){
				 some.value = "לא חובה למלא שדה זה";
				 some.className="reg_inpt_blur";
				 } else {
				 some.className='reg_inpt_focus';
		}	
	}

	function FormsAdds(some){
		if (some.value == "לא חובה למלא שדה זה"){
		some.value='';
		}
		some.className='reg_inpt_focus';
	}

	function rateValue(id){
		AddForm.rates.value=id;
	}
	

	function disdiv(dis_id){ 
	dis_id.style.display = dis_id.style.display == "none" ? "" : "none" 
	} 

	function commentUnMarkAll(id){
				// reset stars
		for (i=1;i<=5;i++){
			document.getElementById(id.substring(0,id.length-1) + i).src = "http://www.opinion.co.il/results/includes/_overstar.gif";
		}	
				// make stars
		for (i=1;i<=AddForm.rates.value;i++){
			document.getElementById(id.substring(0,id.length-1) + i).src = "http://www.opinion.co.il/results/includes/_star.gif";
		}
	}
	
	function markStars(id){
		for (i=1;i<=5;i++){
			document.getElementById(id.substring(0,id.length-1) + i).src = "http://www.opinion.co.il/results/includes/_overstar.gif";
		}
		
		var basicId = id.substring(0,id.length-1);
		for (i=1;i<=id.substring(id.length-1,id.length);i++){
			document.getElementById(basicId + i).src = "http://www.opinion.co.il/results/includes/_star.gif";
		}
	}




function unMarkAlls(id){
				// reset stars
		for (i=1;i<=5;i++){
			document.getElementById(id.substring(0,id.length-1) + i).src = "http://www.opinion.co.il/results/includes/_overstar.gif";
		}	
	}

function ReplaceIT(string){
		var newString = string.replace('"', '%22');
		return newString;
}

var urladdNew = "http://www.opinion.co.il/results/global/add.asp"
function addNew(title, rating, content, itemId, item_wid, isActiveMiniForum, status, source, validcode){
	var getTodayDate=new Date();
	//title = title.replace('&quot;', '´´');
	//title = title.replace('&nbsp;', ' ');
	//content = content.replace('&quot;', '´´');
	//content = content.replace('&nbsp;', ' ');
	//content = content.replace('&', ' ');
	//content = content.replace(' quot;', '´´');
	//content = content.replace('"', '´´');
	//content = content.replace('nbsp;', ' ');
	//content = content.replace('quot;', ' ');
	//content = content.replace(';', ' ');
	//content = content.replace('/', ' ');
	var str="/";
	
	while(content.indexOf(str)!=-1){
		content = content.replace("/", "§");
	}
	
	content = escape(content);
	title =escape(title);

		getInfo(urladdNew + '?title=' + title + '&rates=' + rating + '&isActiveMiniForum=' + isActiveMiniForum + '&status=' + status + '&elm1=' + content + '&rand='+getTodayDate+'&userSource='+source+'&sid='+itemId+'&act=true&validcode='+validcode+'&wid=' + item_wid,"block","addNewOpinionDiv");
		document.getElementById("addNewOpinionDiv").innerHTML = "<div class='addNewOpinionDiv'>תודה! חוות הדעת נוספה בהצלחה לאופיניון.</div>";
}

var curr_open = 0;
var url = "http://www.opinion.co.il/results/global/opinionpage_glb.asp"
var getTodayDate=new Date()

function $(id){return (document.getElementById(id));}

function writeComment(comment_id,i,w,sc,bs){
	var num = comment_id;
	// prev close
	if (curr_open != 0){
	$("comment_title_" + curr_open).style.display = "block";
	$("comment_text_" + curr_open).style.display = "none";
	}
	if (curr_open == num){
		curr_open = 0;
		return;
	}
	if (!$("comment_text_" + num)){
		// do ajax
	getInfo("http://www.opinion.co.il/results/global/opinionpage_glb.asp" + '?rand='+getTodayDate+'&id=' + num + '&i=' + i + '&w=' + w + '&sc=' + sc + '&bs=' + bs,"block","comment_id_" + num);
	$("comment_title_" + num).style.display = "none";
	} else {
		// comment opened before. just open
		$("comment_text_" + num).style.display = "block";
		$("comment_title_" + num).style.display = "none";
	}
	curr_open = num;
}