﻿var AjaxUrl = "Ajax.aspx";

function popMaslul(item)
{
    window.open("popMaslul.aspx?id="+item,"popMaslul","toolbars=no,width=580,height=500");
}

function checkAdd(type)
{
    if (type == 1)
    {
        if ($("checkme").checked == true)
            location.href = "busiboardadd.aspx";
        else
            alert("נא אשר את תנאי הפרסום");
    }
    else
    {
        if ($("checkme").checked == true)
            location.href = "boardadd.aspx";
        else
            alert("נא אשר את תנאי הפרסום");
    }
}

function popTerms()
{
    window.open("popTerms.aspx","popTerms","toolbars=no,width=550,height=500");
}

//-------------------------------------------- POLL: -----------------------------------------//

var pollAns1;
var pollAns2;
var pollAns3;
var pollAns4;
var pollAns5;
var pollRes1 = 0;
var pollRes2 = 0;
var pollRes3 = 0;
var pollRes4 = 0;
var pollRes5 = 0;
var strResTbl = "";
var resAll;

function getCheckedValue(radioObj)
{
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++)
	{
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function sendPoll()
{
	var pars = "strPoll=" + $("pollID").value + "&strResult=" + getCheckedValue(document.getElementsByName("lstPoll"));
	
	GetAjaxValue("Send.Poll", pars, pollVote_result);
}

function pollVote_result(originalRequest)
{
    if (originalRequest.responseText == "true")
    {
        if (getCheckedValue(document.getElementsByName("lstPoll")) == "1")
	    {
	        pollRes1 = pollRes1 + 1;
	    }
	    if (getCheckedValue(document.getElementsByName("lstPoll")) == "2")
	    {
	        pollRes2 = pollRes2 + 1;
	    }
	    if (getCheckedValue(document.getElementsByName("lstPoll")) == "3")
	    {
	        pollRes3 = pollRes3 + 1;
	    }
	    if (getCheckedValue(document.getElementsByName("lstPoll")) == "4")
	    {
	        pollRes4 = pollRes4 + 1;
	    }
	    if (getCheckedValue(document.getElementsByName("lstPoll")) == "5")
	    {
	        pollRes5 = pollRes5 + 1;
	    }
    }
    else
    {
        alert("!מותר להצביע פעם אחת בלבד");
    }
    
    showRes();
}

function showRes()
{
    resAll = pollRes1 + pollRes2 + pollRes3 + pollRes4 + pollRes5;
	
	pollRes1 = (pollRes1*100)/resAll;
	pollRes2 = (pollRes2*100)/resAll;
	pollRes3 = (pollRes3*100)/resAll;
	pollRes4 = (pollRes4*100)/resAll;
	pollRes5 = (pollRes5*100)/resAll;
	
	pollRes1 = pollRes1.toString().split('.')[0];
	pollRes2 = pollRes2.toString().split('.')[0];
	pollRes3 = pollRes3.toString().split('.')[0];
	pollRes4 = pollRes4.toString().split('.')[0];
	pollRes5 = pollRes5.toString().split('.')[0];
	
    strResTbl = strResTbl + "<table style='font-size:11px;' cellpadding='0' cellspacing='5'>";
                        
    if (pollAns1 != "")
    {
        strResTbl = strResTbl + "<tr><td>" + pollAns1 + "<br /><img src='images/pollRes.gif' width='" + pollRes1 + "' height='15' style='vertical-align: middle;' /><br />" + pollRes1 + "%</td></tr>";
    }
    if (pollAns2 != "")
    {
        strResTbl = strResTbl + "<tr><td>" + pollAns2 + "<br /><img src='images/pollRes.gif' width='" + pollRes2 + "' height='15' style='vertical-align: middle;' /><br />" + pollRes2 + "%</td></tr>";
    }
    if (pollAns3 != "")
    {
        strResTbl = strResTbl + "<tr><td>" + pollAns3 + "<br /><img src='images/pollRes.gif' width='" + pollRes3 + "' height='15' style='vertical-align: middle;' /><br />" + pollRes3 + "%</td></tr>";
    }
    if (pollAns4 != "")
    {
        strResTbl = strResTbl + "<tr><td>" + pollAns4 + "<br /><img src='images/pollRes.gif' width='" + pollRes4 + "' height='15' style='vertical-align: middle;' /><br />;" + pollRes4 + "%</td></tr>";
    }
    if (pollAns5 != "")
    {
        strResTbl = strResTbl + "<tr><td>" + pollAns5 + "<br /><img src='images/pollRes.gif' width='" + pollRes5 + "' height='15' style='vertical-align: middle;' /><br />" + pollRes5 + "%</td></tr>";
    }
    
    strResTbl = strResTbl + "</table>";
    
	$("divResult").innerHTML = strResTbl;
	
	$("divPoll").style.display = "none";
	$("divResult").style.display = "block";
}

function openBoard(item)
{
    $("trBoard"+item).style.display = "block";
}

function closeBoard(item)
{
    $("trBoard"+item).style.display = "none";
}

function showArticleByCat(item)
{
    location.href = "ViewArticles.aspx?cid=" + item;
}

function showNewsByCat(item)
{
    location.href = "ViewNews.aspx?cid=" + item;
}

function showBoardByCat(item)
{
    location.href = "ViewBoardItems.aspx?cid=" + item;
}

function showBannerByLoc(item)
{
    location.href = "ViewBanners.aspx?blocid=" + item;
}

function showBusiBoardByCat(item, parent)
{
    location.href = "ViewBusiBoardItems.aspx?cid=" + parent + "&sid=" + item;
}

function showCatByParent(item)
{
    location.href = "ViewBusiBoardItems.aspx?cid=" + item;
}

//-------------------------------------------- TALKBACKS: -----------------------------------------//

var AjaxShow = false;

function showTB(item)
{
    document.getElementById("talkbackDiv"+item).style.display = "block";
}
function hideTB(item)
{
    document.getElementById("talkbackDiv"+item).style.display = "none";
}

function showTBadd()
{
    if (AjaxShow == false)
    {
        new Effect.SlideDown("talkbackDivAdd");
        
        AjaxShow = true;
    }
}

function hideTBadd()
{
    new Effect.SlideUp("talkbackDivAdd");
    
    AjaxShow = false;
}

function hideTBaddOK()
{
    new Effect.SlideUp("talkbackDivAddOK");
    
    AjaxShow = false;
}

function sendTB()
{
    if ($("txtName").value == "")
    {
        alert("נא מלא שם");
        return;
    }
    if ($("txtCity").value == "")
    {
        alert("נא מלא שכונה");
        return;
    }
    if ($("txtTitle").value == "")
    {
        alert("נא מלא כותרת");
        return;
    }
    if ($("txtContent").value == "")
    {
        alert("נא מלא תוכן");
        return;
    }
    
	var pars = "strID=" + $("txtID").value + "&strName=" + $("txtName").value + "&strCity=" + $("txtCity").value + "&strTitle=" + $("txtTitle").value + "&strContent=" + $("txtContent").value;
	$("talkbackDivAdd").style.display = "none";
	$("talkbackDivAddOK").style.display = "block";
	
	GetAjaxValue("Send.TalkBack", pars, null);
	
	$("txtName").value = "";
	$("txtCity").value = "";
	$("txtTitle").value = "";
	$("txtContent").value = "";
}

function sendTB_Result(originalRequest)
{
	alert(originalRequest.responseText);
}

//-------------------------------------------- SEND TO FRIEND: -----------------------------------------//

var AjaxShowFS = false;

function showFsend()
{
    if (AjaxShowFS == false)
    {
        new Effect.SlideDown("divFsend");
        
        AjaxShowFS = true;
    }
}

function hideFsend()
{
    new Effect.SlideUp("divFsend");
    
    AjaxShowFS = false;
}

function hideFsendOK()
{
    new Effect.SlideUp("divFsendOK");
    
    AjaxShowFS = false;
}

function sendFS()
{
    if ($("txtSName").value == "")
    {
        alert("נא מלא שם");
        return;
    }
    if ($("txtFName").value == "")
    {
        alert("נא מלא שם החבר");
        return;
    }
    if ($("txtFEmail").value == "")
    {
        alert("נא מלא כתובת דוא''ל");
        return;
    }
    
	var pars = "strID=" + $("txtID").value + "&strName=" + $("txtSName").value + "&strFriend=" + $("txtFName").value + "&strEmail=" + $("txtFEmail").value;
	$("divFsend").style.display = "none";
	$("divFsendOK").style.display = "block";
	
	GetAjaxValue("Send.Fsend", pars, null);
	
	$("txtSName").value = "";
	$("txtFName").value = "";
	$("txtFEmail").value = "";
}

function sendFS_Result(originalRequest)
{
	alert(originalRequest.responseText);
}

//-------------------------------------------- GET SUB CATEGORY: -----------------------------------------//

function showCatByParentAdd(cid)
{
    var pars = "strID=" + cid;
	
	GetAjaxValue("Send.getSubCat", pars, getSubCat_Result);
}

function getSubCat_Result(originalRequest)
{
	populateCatCombo(originalRequest.responseText);
}

//-------------------------------------------- ADV SEARCH: -----------------------------------------//

var AjaxSearch = false;

function showSearch()
{
    if (AjaxSearch == false)
    {
        new Effect.SlideDown("divSearch");
        
        AjaxSearch = true;
    }
}

function hideSearch()
{
    new Effect.SlideUp("divSearch");
    
    AjaxSearch = false;
}

function sendSearch(searchValue)
{
    var strCr;
    
    strCr = "?";
    
    if (document.googleadv.search1.checked == true)
        strCr = strCr + "sa=" + searchValue + "&";
        
    if (document.googleadv.search2.checked == true)
        strCr = strCr + "sb=" + searchValue + "&";
        
    if (document.googleadv.search3.checked == true)
        strCr = strCr + "sbb=" + searchValue + "&";
        
    if (document.googleadv.search4.checked == true)
        strCr = strCr + "ss=" + searchValue + "&";
        
    if (document.googleadv.search5.checked == true)
        strCr = strCr + "g=" + searchValue;
    else
        strCr = strCr + "g=0";
        
    location.href = "searchres.aspx" + strCr;
}

//-------------------------------------------- Minisite: -----------------------------------------//

var MinisiteAboutShow = true;
var MinisiteProductsShow = false;
var MinisiteContactShow = false;

function showAbout()
{
    if (MinisiteProductsShow == true)
        hideProducts();
    if (MinisiteContactShow == true)
        hideContact();
        
    if (MinisiteAboutShow == false)
    {
        setTimeout("new Effect.SlideDown('dvAbout');$('tdAbout').className = 'minisite_tabs_on';",1000);
        
        MinisiteAboutShow = true;
    }
}
function hideAbout()
{
    new Effect.SlideUp("dvAbout");
    $("tdAbout").className = "minisite_tabs";
    
    MinisiteAboutShow = false;
}

function showProducts()
{
    if (MinisiteContactShow == true)
        hideContact();
    if (MinisiteAboutShow == true)
        hideAbout();
        
    if (MinisiteProductsShow == false)
    {
        setTimeout("new Effect.SlideDown('dvProducts');$('tdProducts').className = 'minisite_tabs_on';",1000);
        
        MinisiteProductsShow = true;
    }
}
function hideProducts()
{
    new Effect.SlideUp("dvProducts");
    $("tdProducts").className = "minisite_tabs";
    
    MinisiteProductsShow = false;
}

function showContact()
{
    if (MinisiteProductsShow == true)
        hideProducts();
    if (MinisiteAboutShow == true)
        hideAbout();
        
    if (MinisiteContactShow == false)
    {
        setTimeout("new Effect.SlideDown('dvContact');$('tdContact').className = 'minisite_tabs_on';",1000);
        
        MinisiteContactShow = true;
    }
}
function hideContact()
{
    new Effect.SlideUp("dvContact");
    $("tdContact").className = "minisite_tabs";
    
    MinisiteContactShow = false;
}

function hideMinisiteEmailOK()
{
    new Effect.SlideUp("divMinisiteEmailOK");
}

function sendMinisiteEmail()
{
    if ($("txtName").value == "")
    {
        alert("נא מלא שם");
        return;
    }
    if ($("txtPhone").value == "")
    {
        alert("נא מלא טלפון");
        return;
    }
    if ($("txtEmail").value == "")
    {
        alert("נא מלא כתובת דוא''ל");
        return;
    }
    
	var pars = "siteID=" + $("siteID").value + "&intContact=" + $("intContact").value + "&strTitle=" + $("txtTitle").value + "&strName=" + $("txtName").value + "&strPhone=" + $("txtPhone").value + "&strEmail=" + $("txtEmail").value + "&strBody=" + $("txtBody").value + "&strToEmail=" + $("txtToEmail").value;
	$("divMinisiteEmail").style.display = "none";
	$("divMinisiteEmailOK").style.display = "block";
	
	GetAjaxValue("Send.MinisiteEmail", pars, null);
	
	$("txtName").value = "";
	$("txtPhone").value = "";
	$("txtEmail").value = "";
	$("txtBody").value = "";
}

function sendMinisiteEmail_Result(originalRequest)
{
	alert(originalRequest.responseText);
}

//-------------------------------------------- ??????????????: -----------------------------------------//
