

function changebuttoncheckREGISTER() {
    document.AddForm.buttoncheckREGISTER.setAttribute("disabled", "true")
}


function change() {
    document.AddForm.buttoncheck.setAttribute("disabled", "true")
}


function checkAddNewOpinion(){
	isDone="true";
	title = document.AddForm.title.value;
    rates = document.AddForm.rates.value;
	feel_1 = document.AddForm.feel_1.checked;
	feel_2 = document.AddForm.feel_2.checked;
	feel_3 = document.AddForm.feel_3.checked;
	feel_4 = document.AddForm.feel_4.checked;
	feel_5 = document.AddForm.feel_5.checked;
	feel_6 = document.AddForm.feel_6.checked;
	feel_7 = document.AddForm.feel_7.checked;
	feel_8 = document.AddForm.feel_8.checked;
	feel_9 = document.AddForm.feel_9.checked;
	feel_10 = document.AddForm.feel_10.checked;
	feel_11 = document.AddForm.feel_11.checked;
	feel_12 = document.AddForm.feel_12.checked;
	feel_13 = document.AddForm.feel_13.checked;
	feel_14 = document.AddForm.feel_14.checked;
	feel_15 = document.AddForm.feel_15.checked;
	feel_16 = document.AddForm.feel_16.checked;
	feel_17 = document.AddForm.feel_17.checked;
	
	//elm1 =  document.AddForm.elm1.value;
	
	if (title.length == 0){
		alert('יש לכתוב כותרת');
		isDone="false"
		document.AddForm.title.focus();
		}

	if (rates==0 || rates==''){
		alert('יש לדרג');
		isDone="false"
		document.AddForm.title.focus();
		}
	
		if (feel_1==false && feel_2==false && feel_3==false && feel_4==false && feel_5==false && feel_6==false && feel_7==false && feel_8==false && feel_9==false && feel_10==false && feel_11==false && feel_12==false && feel_13==false && feel_14==false && feel_15==false && feel_16==false && feel_17==false){
		alert('נא לסמן לפחות תגית אחת');
		isDone="false"
		document.AddForm.feel_1.focus();
		}
	
		if(isDone=="true"){
			change();
			//alert(isDone);
			
			document.AddForm.submit();
			return true;
		}
		
return false;
		
}

function CheckAddingGuest() {
    isDone = "true";
    guest_userName = document.AddForm.guest_userName.value;
    title = document.AddForm.title.value;
    rates = document.AddForm.rates.value;
    feel_1 = document.AddForm.feel_1.checked;
    feel_2 = document.AddForm.feel_2.checked;
    feel_3 = document.AddForm.feel_3.checked;
    feel_4 = document.AddForm.feel_4.checked;
    feel_5 = document.AddForm.feel_5.checked;
    feel_6 = document.AddForm.feel_6.checked;
    feel_7 = document.AddForm.feel_7.checked;
    feel_8 = document.AddForm.feel_8.checked;
    feel_9 = document.AddForm.feel_9.checked;
    feel_10 = document.AddForm.feel_10.checked;
    feel_11 = document.AddForm.feel_11.checked;
    feel_12 = document.AddForm.feel_12.checked;
    feel_13 = document.AddForm.feel_13.checked;
    feel_14 = document.AddForm.feel_14.checked;
    feel_15 = document.AddForm.feel_15.checked;
    feel_16 = document.AddForm.feel_16.checked;
    feel_17 = document.AddForm.feel_17.checked;

    //elm1 =  document.AddForm.elm1.value;

    if (guest_userName.length == 0) {
        alert('יש לכתוב שם מלא');
        isDone = "false"
        document.AddForm.guest_userName.focus();
    }

    if (title.length == 0) {
        alert('יש לכתוב כותרת');
        isDone = "false"
        document.AddForm.title.focus();
    }

    if (rates == 0 || rates == '') {
        alert('יש לדרג');
        isDone = "false"
        document.AddForm.title.focus();
    }

    if (feel_1 == false && feel_2 == false && feel_3 == false && feel_4 == false && feel_5 == false && feel_6 == false && feel_7 == false && feel_8 == false && feel_9 == false && feel_10 == false && feel_11 == false && feel_12 == false && feel_13 == false && feel_14 == false && feel_15 == false && feel_16 == false && feel_17 == false) {
        alert('נא לסמן לפחות תגית אחת');
        isDone = "false"
        document.AddForm.feel_1.focus();
    }

    if (isDone == "true") {
        change();
        //alert(isDone);

        document.AddForm.submit();
        return true;
    }

    return false;
}


function CheckAdding() {
	isDone="true";
	title = document.AddForm.title.value;
    rates = document.AddForm.rates.value;
	feel_1 = document.AddForm.feel_1.checked;
	feel_2 = document.AddForm.feel_2.checked;
	feel_3 = document.AddForm.feel_3.checked;
	feel_4 = document.AddForm.feel_4.checked;
	feel_5 = document.AddForm.feel_5.checked;
	feel_6 = document.AddForm.feel_6.checked;
	feel_7 = document.AddForm.feel_7.checked;
	feel_8 = document.AddForm.feel_8.checked;
	feel_9 = document.AddForm.feel_9.checked;
	feel_10 = document.AddForm.feel_10.checked;
	feel_11 = document.AddForm.feel_11.checked;
	feel_12 = document.AddForm.feel_12.checked;
	feel_13 = document.AddForm.feel_13.checked;
	feel_14 = document.AddForm.feel_14.checked;
	feel_15 = document.AddForm.feel_15.checked;
	feel_16 = document.AddForm.feel_16.checked;
	feel_17 = document.AddForm.feel_17.checked;
	
	//elm1 =  document.AddForm.elm1.value;
	
	if (title.length == 0){
		alert('יש לכתוב כותרת');
		isDone="false"
		document.AddForm.title.focus();
		}

	if (rates==0 || rates==''){
		alert('יש לדרג');
		isDone="false"
		document.AddForm.title.focus();
		}
	
		if (feel_1==false && feel_2==false && feel_3==false && feel_4==false && feel_5==false && feel_6==false && feel_7==false && feel_8==false && feel_9==false && feel_10==false && feel_11==false && feel_12==false && feel_13==false && feel_14==false && feel_15==false && feel_16==false && feel_17==false){
		alert('נא לסמן לפחות תגית אחת');
		isDone="false"
		document.AddForm.feel_1.focus();
		}
	
		if(isDone=="true"){
		    changebuttoncheckREGISTER();
			//alert(isDone);
			
			document.AddForm.submit();
			return true;
		}
		
return false;
	}
	
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 {
		if(idDesc=="news") {
			set_DEFAULT_otype(id);
			document.getElementById("opinionsList").innerHTML="";
			showNews(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");	
}

var urlNews = "http://www.opinion.co.il/results/global/showOpinions/google_news.asp"
function showNews(itemId, wid, orderBy, otype, query){
	var getTodayDate=new Date();
		curr_open=0;
		document.getElementById("opinionsList").innerHTML="";
		getInfo(urlNews + '?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++;
}


function twitterWindow(itemId, wid, orderBy, otype, query){
	var getTodayDate=new Date();
		document.getElementById("window_twitter").innerHTML="";
		getInfo2(urlTwitter + '?i=' + itemId + '&otype=5&orderBy=' + orderBy + '&query=' + query + '&rand='+getTodayDate+'&w=' + wid,"block","window_twitter");	
}


function newsWindow(itemId, wid, orderBy, otype, query){
	var getTodayDate=new Date();
		document.getElementById("window_news").innerHTML="";
		getInfo3(urlNews + '?i=' + itemId + '&otype=5&orderBy=' + orderBy + '&query=' + query + '&rand='+getTodayDate+'&w=' + wid,"block","window_news");	
}

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;
}
