﻿
function openPrintPage(i)
{
    open("ArticlePrint.aspx?ArticleId="+i);

}

function timedRefresh(timeoutPeriod) {
	setTimeout("location.reload(true);",timeoutPeriod);
}



function ChangeUtf(the_string)
	{
		the_string = the_string.replace(/א/gi, "~1~");
		the_string = the_string.replace(/ב/gi, "~2~");
		the_string = the_string.replace(/ג/gi, "~3~");
		the_string = the_string.replace(/ד/gi, "~4~");
		the_string = the_string.replace(/ה/gi, "~5~");
		the_string = the_string.replace(/ו/gi, "~6~");
		the_string = the_string.replace(/ז/gi, "~7~");
		the_string = the_string.replace(/ח/gi, "~8~");
		the_string = the_string.replace(/ט/gi, "~9~");
		the_string = the_string.replace(/י/gi, "~10~");
		the_string = the_string.replace(/כ/gi, "~11~");
		the_string = the_string.replace(/ל/gi, "~12~");
		the_string = the_string.replace(/מ/gi, "~13~");
		the_string = the_string.replace(/נ/gi, "~14~");
		the_string = the_string.replace(/ס/gi, "~15~");
		the_string = the_string.replace(/ע/gi, "~16~");
		the_string = the_string.replace(/פ/gi, "~17~");
		the_string = the_string.replace(/צ/gi, "~18~");
		the_string = the_string.replace(/ק/gi, "~19~");
		the_string = the_string.replace(/ר/gi, "~20~");
		the_string = the_string.replace(/ש/gi, "~21~");
		the_string = the_string.replace(/ת/gi, "~22~");
		the_string = the_string.replace(/ף/gi, "~23~");
		the_string = the_string.replace(/ך/gi, "~24~");
		the_string = the_string.replace(/ץ/gi, "~25~");
		the_string = the_string.replace(/ם/gi, "~26~");
		the_string = the_string.replace(/ן/gi, "~27~");
		return the_string;
	}


function PostIt(i,b)
{

   n = $("*[id$='txtName']").val();
   s = $('#txtSubject').val();
   p = $('#txtPostBackText').val(); 
   
   
   if(n=="")
   {
    alert("נא מלאו שם");
    return false;
   }
   
   if(s=="")
   {
    alert("נא מלאו נושא");
    return false;
   }
 
   n=ChangeUtf(n);
   s=ChangeUtf(s);
   p=ChangeUtf(p);
   
   $('#TalkBackAddContent').hide();   
   $('#TalkBackSend').show();
   
    $.post("http://www.sponser.co.il/Handlers/PostBackAdd.ashx",
    { 
        txtName:n,
        txtSubject:s,
        txtPostBackText:p,
        ArticleId:i,
        IsBlog:b
      },
      function(data){
        if(data != "ERROR")
        {
            $('#TalkBackSend').html("תגובתכם התקבלה ותפורסם בדקות הקרובות");   
        }
        else
        {
            alert("המערכת לא הצליחה לקבל את התגובה שלכם.");
        }
      }
    );
   
}


function chkLoginFrm()
{
    var l = $("*[id$='txtLogin']").val();
    if(jQuery.trim(l)=="")
    {    
        alert("נא למלא שם משתמש");
        return false;
    }
    
    
    var p = $("*[id$='txtPwd']").val();
    if(jQuery.trim(p)=="")
    {    
        alert("נא למלא סיסמה");
        return false;
    }
    return true;
}


function chkRegistrationFrm()
{
   
    var  x = $("*[id$='txtLoginR']").val();
    x=jQuery.trim(x);
    if(x=="")
    {    
        alert("נא למלא שם משתמש");
        return false;
    }
    
    
    x = $("*[id$='txtPwdR']").val();
    x=jQuery.trim(x);
    if(x=="")
    {    
        alert("נא למלא סיסמה");
        return false;
    }
    
    x = $("*[id$='txtPwdR2']").val();
    x=jQuery.trim(x);
    if(x=="")
    {    
        alert("נא למלא אימות סיסמה");
        return false;
    }
    
    x = $("*[id$='txtEmail']").val();
    x=jQuery.trim(x);
    if(x=="")
    {    
        alert("נא למלא אימייל");
        return false;
    }
    if(!ValidateEmail(x))
    {
        alert("נא למלא אימייל תקין");
        return false;
    }
   
   if(!document.getElementById("chkIagree").checked)
   {
        alert("נא לאשר את התקנון");
        return false;
    }
    return true;
    

}

function ValidateEmail(s)
{
    var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(s)) 
        return false;
    else
        return true;
}

function doAction(u)
{
    if(confirm("האם אתה בטוח?"))
    {
        movemsg2 = "";
        if(u.indexOf("MOVE")!=-1)
        {
            a = $("#move2msg").val();
            movemsg2 = "&ToMsgId="+ a;
        }
        location.href=u + movemsg2;
    }
}

function SearchBox()
{
    
   
    var  x = $("#SelectSearchSite").val();
    x=jQuery.trim(x);
    if(x=="0")
    {    
        alert("נא לבחור סוג חיפוש");
        return false;
    }
    
    var s = $("#InputSearchSite").val();
    s=jQuery.trim(s);
    if(s.length<3)
    {    
        alert("חיפוש חייב להיות לפחות 3 תווים");
        return false;
    }
    
    switch(x)
    {
        case "1":
            location.href="http://www.sponser.co.il/SearchResults.aspx?SearchWords=" + escape(s) + "&Type="+x;
            break;
        case "2":
            location.href="http://www.sponser.co.il/ForumSearchResults.aspx?ForumId=1&WordList="+escape(s);
            break;
        case "3":
            location.href="http://www.sponser.co.il/SearchResultsSkirot.aspx?WordList="+escape(s);
            break;
        case "4":
            location.href="http://www.sponser.co.il/Content_ShukHaon.aspx?WordList="+escape(s);
            break;
        case "5":
            location.href="http://www.sponser.co.il/SearchFinance.aspx?WordList="+escape(s);
            break;
         case "6":
            location.href="http://www.sponser.co.il/Blogs/BlogSearchResults.aspx?SearchWords="+escape(s);
            break;
        case "99":
            return getNNGUrl('sponser','InputSearchSite',true);
        default:
            break
    }
    //return false;
}



function InjectBanners()
{
    var p = location.href;
    for (var i in BannerList)
    {	
        switch(i)
        {
            case "1":
                if($('#LeftBanner').length!=0)
                {
                    b = BannerList["1"].split("|")[0];
                    i=  BannerList["1"].split("|")[1];
                    b+="?url=http://www.sponser.co.il/BannerRedirector.aspx?OXK=" + i + "|" + p;
                    
                    FlashReplace.replace("LeftBanner", "http://www.sponser.co.il/BannerSystem/"+ b, "flash-element-LeftBanner", 440, 80, 7,
                    {
                        wmode : "transparent",
                        quality: "high",
                        bgcolor: "#ffffff"
                    })
                }
                break;
            
            case "5":
                if($('#InnerPageBannerRightTop').length!=0)
                {
                    b = BannerList["5"].split("|")[0];
                    i=  BannerList["5"].split("|")[1];
                    b+="?url=http://www.sponser.co.il/BannerRedirector.aspx?OXK=" + i + "|" + p;
                    
                    FlashReplace.replace("InnerPageBannerRightTop", "http://www.sponser.co.il/BannerSystem/"+ b, "flash-element-InnerPageBannerRightTop", 128, 350, 7,
                    {
                        wmode : "transparent",
                        quality: "high",
                        bgcolor: "#ffffff"
                    })
                }
                break;
            case "3":
                if($('#SmallBoxBanner1').length!=0)
                {
                    b = BannerList["3"].split("|")[0];
                    i=  BannerList["3"].split("|")[1];
                    b+="?url=http://www.sponser.co.il/BannerRedirector.aspx?OXK=" + i + "|" + p;
                
                    FlashReplace.replace("SmallBoxBanner1", "http://www.sponser.co.il/BannerSystem/"+ b, "flash-element-SmallBoxBanner1", 128, 92, 7,
                    {
                        wmode : "transparent",
                        quality: "high",
                        bgcolor: "#ffffff"
                    })
                }
                break; 
            case "4":
                 if($('#InnerPageBannerLeftTop').length!=0)
                {
                    b = BannerList["4"].split("|")[0];
                    i=  BannerList["4"].split("|")[1];
                    b+="?url=http://www.sponser.co.il/BannerRedirector.aspx?OXK=" + i + "|" + p;
                
                    FlashReplace.replace("InnerPageBannerLeftTop", "http://www.sponser.co.il/BannerSystem/"+ b, "flash-element-InnerPageBannerLeftTop", 221, 193, 7,
                    {
                        wmode : "transparent",
                        quality: "high",
                        bgcolor: "#ffffff"
                    })
                }
                
                break;            
            case "6":
                if($('#RightBanner').length!=0)
                {
                    
                    b = BannerList["6"].split("|")[0];
                    i=  BannerList["6"].split("|")[1];
                    b+="?url=http://www.sponser.co.il/BannerRedirector.aspx?OXK=" + i + "|" + p;
                    
                    FlashReplace.replace("RightBanner", "http://www.sponser.co.il/BannerSystem/"+ b, "flash-element-RightBanner", 440, 80, 7,
                    {
                        wmode : "transparent",
                        quality: "high",
                        bgcolor: "#ffffff"
                    })
                }
                break;
            case "8":
                if($('#ArticleBanner').length!=0)
                {
                    b = BannerList["8"].split("|")[0];
                    i=  BannerList["8"].split("|")[1];
                    b+="?url=http://www.sponser.co.il/BannerRedirector.aspx?OXK=" + i + "|" + p;
                    
                    FlashReplace.replace("ArticleBanner", "http://www.sponser.co.il/BannerSystem/"+ b, "flash-element-ArticleBanner", 500, 140, 7,
                    {
                        wmode : "transparent",
                        quality: "high",
                        bgcolor: "#ffffff"
                    })
                }
                break;                
            case "9":
                
                if($('#MainPageLeftBanner').length!=0)
                {
                    b = BannerList["9"].split("|")[0];
                    i=  BannerList["9"].split("|")[1];
                    b+="?url=http://www.sponser.co.il/BannerRedirector.aspx?OXK=" + i + "|" + p;
                
                    FlashReplace.replace("MainPageLeftBanner", "http://www.sponser.co.il/BannerSystem/"+ b, "flash-element-MainPageLeftBanner", 300, 250, 7,
                    {
                        wmode : "transparent",
                        quality: "high",
                        bgcolor: "#ffffff"
                    })
                }
                break; 
            case "10":
                if($('#BannerHomePageMain').length!=0)
                {
                
                    b = BannerList["10"].split("|")[0];
                    i=  BannerList["10"].split("|")[1];
                    b+="?url=http://www.sponser.co.il/BannerRedirector.aspx?OXK=" + i + "|" + p;
                    FlashReplace.replace("BannerHomePageMain", "http://www.sponser.co.il/BannerSystem/"+ b, "flash-element-BannerHomePageMain", 580, 90, 7,
                    {
                        wmode : "transparent",
                        quality: "high",
                        bgcolor: "#ffffff"
                    })
                }
                break; 
            case "11":
                if($('#BannerHeaderHomePage').length!=0)
                {
                    b = BannerList["11"].split("|")[0];
                    i=  BannerList["11"].split("|")[1];
                    b+="?url=http://www.sponser.co.il/BannerRedirector.aspx?OXK=" + i + "|" + p;
                    
                    FlashReplace.replace("BannerHeaderHomePage", "http://www.sponser.co.il/BannerSystem/"+ b, "flash-element-BannerHeaderHomePage", 992, 42, 7,
                    {
                        wmode : "transparent",
                        quality: "high",
                        bgcolor: "#ffffff"
                    })
                }
                break; 
            case "12":
                
                if($('#SmallBoxBanner2').length!=0)
                {
                    b = BannerList["12"].split("|")[0];
                    i=  BannerList["12"].split("|")[1];
                    b+="?url=http://www.sponser.co.il/BannerRedirector.aspx?OXK=" + i + "|" + p;
                    
                    FlashReplace.replace("SmallBoxBanner2", "http://www.sponser.co.il/BannerSystem/"+ b, "flash-element-SmallBoxBanner2", 128, 92, 7,
                    {
                        wmode : "transparent",
                        quality: "high",
                        bgcolor: "#ffffff"
                    })
                }
                break;    
            
            case "13":
                
                if($('#ArticleBannerBottom').length!=0)
                {
                    b = BannerList["13"].split("|")[0];
                    i=  BannerList["13"].split("|")[1];
                
                    b+="?url=http://www.sponser.co.il/BannerRedirector.aspx?OXK=" + i + "|" + p;
                    FlashReplace.replace("ArticleBannerBottom", "http://www.sponser.co.il/BannerSystem/"+ b , "flash-element-ArticleBannerBottom", 440, 80, 7,
                    {
                        wmode : "transparent",
                        quality: "high",
                        bgcolor: "#ffffff"
                    })
                }
                break;       
              case "14":
                
                if($('#BannerShovav').length!=0)
                {
                    b = BannerList["14"].split("|")[0];
                    i=  BannerList["14"].split("|")[1];
                
                    b+="?url=http://www.sponser.co.il/BannerRedirector.aspx?OXK=" + i + "|" + p;
                    FlashReplace.replace("BannerShovav", "http://www.sponser.co.il/BannerSystem/"+ b , "flash-element-BannerShovav", 300, 107, 7,
                    {
                        wmode : "transparent",
                        quality: "high",
                        bgcolor: "#ffffff"
                    })
                }
                break;      
               
        }
    }
}


function chkFrmJoinMailingList()
{

    var x = $("*[id$='txtEmail']").val();
    x=jQuery.trim(x);
    if(x=="")
    {    
        alert("נא למלא אימייל");
        return false;
    }
    if(!ValidateEmail(x))
    {
        alert("נא למלא אימייל תקין");
        return false;
    }
    
    
    
    var x = $("*[id$='txtCaptch']").val();
    x=jQuery.trim(x);
    if(x=="")
    {    
        alert("נא למלא קוד");
        return false;
    }
    return true;

}

function chkFrmContactUs()
{
    var x = $("*[id$='txtEmail']").val();
    x=jQuery.trim(x);
    if(x=="")
    {    
        alert("נא למלא אימייל");
        return false;
    }
    if(!ValidateEmail(x))
    {
        alert("נא למלא אימייל תקין");
        return false;
    }
    
    var x = $("*[id$='txtFullName']").val();
    x=jQuery.trim(x);
    if(x=="")
    {    
        alert("נא למלא שם");
        return false;
    }
    
    var x = $("*[id$='txtCaptch']").val();
    x=jQuery.trim(x);
    if(x=="")
    {    
        alert("נא למלא קוד");
        return false;
    }
    return true;

}

function ChkFrmSendToFriend()
{
     var e = $("#txtEmail").val();
     e=jQuery.trim(e);
     
     if(e=="" || !ValidateEmail(e))
     {
        alert("אימייל לא תקין");
        return false;
     }
     var n = $("#txtFullName").val();
     n=jQuery.trim(n);
     
     if(n=="")
     {
        alert("יש למלא שם שולח");
        return false;
     } 
     
     var t = $("#txtText").val();
     
   
    n=ChangeUtf(n);
    t=ChangeUtf(t);
   
   
   
    $.post("http://www.sponser.co.il/Handlers/SendEmail.ashx",
    { 
        txtEmail:e,
        txtName:n,
        txtText:t
      },
      function(data){
        if(data != "ERROR")
        {
            jQuery(document).trigger('close.facebox');
        }
        else
        {
            alert("המערכת לא הצליחה לבצע את השליחה.");
            jQuery(document).trigger('close.facebox');
        }
      }
    );
}


function get_definition( str ){
    return dictionary[ str ] ? '<a href=http://finance.sponser.co.il/finance/indices/indices_componetnts.php?s=' + dictionary[ str ] + '">' + str + '<\/a>':str;
};

function convert2Usa(s)
{
    try
    {
        a = s.split("/");
        return a[1]+"/"+a[0]+"/"+a[2];    
    }
    catch(err)
    {
        return "";
    }
}
function querySt(ji) 
{
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i=0;i<gy.length;i++) 
    {
        ft = gy[i].split("=");
        if (ft[0] == ji) 
        {
            return ft[1];
        }
    }
}

function AddToFavorites() 
{
    if (window.sidebar) 
    { // Mozilla Firefox Bookmark
        window.sidebar.addPanel('אתר ספונסר - הספונסר שלך בשוק ההון', 'http://www.sponser.co.il', "");
    } 
    else
        if (window.external) // IE Favorite
            window.external.AddFavorite('http://www.sponser.co.il', 'אתר ספונסר - הספונסר שלך בשוק ההון');
}


function SendReminder()
{
    var x =  $("#txtEmailReminder").val();
    x=jQuery.trim(x);
    if(x=="")
    {    
        alert("נא למלא אימייל");
        return false;
    }
    if(!ValidateEmail(x))
    {
        alert("נא למלא אימייל תקין");
        return false;
    }

     $.post("Handlers/SendForgotEmail.ashx",
    { 
        txtEmail:x
      },
      function(data){
        if(data != "ERROR")
        {
            $('#Stage2Txt').html("ברגעים אלו נשלח אליכם מייל עם הסיסמה"); 
            $('#Stage1').hide();  
        }
        else
        {
            $('#Stage1').hide();
            $('#Stage2Txt').html("אימייל לא קיים במערכת");
        }
      }
    );

}


function catchEvent(e,u)
{
    $.post("Handlers/catchEvent.ashx",
    { 
        EventType:e,
        EventUrl:u
      },
      function(data){
      }
    );

}


function InjectStock()
{

    if(!IsDontShowStockRel)
    {
        
        $('a[rel|=stock]').each(function() {  
        var a = $(this);
        var s = $(this).attr('href'); 
        
        $(this).attr('href','http://finance.sponser.co.il/finance/table/table.php?s='+s);
        $(this).attr('target','_blank');
        $(this).addClass('stockRel');
        $(this).css({fontWeight:"bold"});

        if (s != undefined && s != "") { 
            
             $.post("Handlers/StockData.ashx",
                { 
                    symbol:s
                  },
                  function(data){
                    if(data != "ERROR")
                    {
                       var sdd = data.split("|");
                       if(sdd[1]=="1")
                       {
                            arr="&uarr;";
                            imm="arrow_red.gif";
                            sg="";
                            cls= "stockU";
                       }
                       else
                       {
                            imm="arrow_green.gif";
                            arr="&darr;";
                            cls= "stockD";
                            sg="&#8722;";
                       }
                       
                       if(!jQuery.browser.msie)
                        a.after("&nbsp;<span  class='stock'>("+sdd[2]+ "<span class='arr'>"+arr+"</span><span class='"+cls+"'>"+ sdd[0] +"%"+sg+"</span>)</span>&nbsp;");
                        else
                        a.after("&nbsp;<span  class='stock'>("+sdd[2]+ "<span class='arr'>"+arr+"</span><span class='"+cls+"'>"+ sg+ sdd[0] +"%</span>)</span>&nbsp;");          
                               //a.after("&nbsp;<span class='stock'><table cellspacing='0' border='0' style='font-size: 86%; font-weight: bold; display: inline; ' celladding='0' dir='rtl'><tbody><tr><td>(</td><td dir='ltr' style='color: black;'>"+sdd[2]+"</td><td><img border='0' src='/images/"+imm+"'></td><td style='color: rgb(34, 145, 0);' dir='ltr'>"+sdd[0]+"%</td><td>)</td></tr></tbody></table></span>&nbsp;");
                    }
                    else
                    {
                       
                    }
                  }
                );
         } 
         }); 
     }
     else
     {

        $('a[rel|=stock]').each(function() {  
            $(this).removeAttr('href'); 
        });
     }
    
}


function ChkAddBlogPost()
{
    var  x = $("*[id$='txtTitle']").val();
    x=jQuery.trim(x);
    if(x=="")
    {    
        alert("נא למלא כותרת");
        return false;
    }
    
    x = $("*[id$='txtSubTitle']").val();
    x=jQuery.trim(x);
    if(x=="")
    {    
        alert("נא למלא כותרת משנה");
        return false;
    }
    
    return true;
    
}



function formatText (tag) 
{ 
    var selectedText = document.selection.createRange().text; 
     
    if (selectedText != "") { 
        var newText = "<" + tag + ">" + selectedText + "</" + tag + ">"; 
        document.selection.createRange().text = newText; 
    } 
} 

 
function ahrefThis() {
strSelection = document.selection.createRange().text
if (strSelection == "") document.text.text.focus()
strHref = prompt("Enter the URL of the site you to link:","http://")
if (strHref == null) return;
document.selection.createRange().text = "<a href=\"" + strHref + "\" target=\"_blank\" >" + strSelection + "</a>"
return;
}
 
function ahrefThis2() {
strSelection = document.selection.createRange().text
if (strSelection == "") document.text.text.focus()
strHref = prompt("Enter the URL of the site you to link:","http://")
if (strHref == null) return;
document.selection.createRange().text = "<a style='text-decoration:none;' href=\"" + strHref + "\" target=\"_blank\" class=\"text\">" + strSelection + "</a>"
return;
}




function ChkFrmAsk2Join()
{
     var e = $("#txtEmail").val();
     e=jQuery.trim(e);
     
     if(e=="" || !ValidateEmail(e))
     {
        alert("אימייל לא תקין");
        return false;
     }
     var n = $("#txtFullName").val();
     n=jQuery.trim(n);
     
     if(n=="")
     {
        alert("יש למלא שם שולח");
        return false;
     } 
     
     var t = $("#txtText").val();
     
   
    n=ChangeUtf(n);
    t=ChangeUtf(t);
   
   
   alert("http://www.sponser.co.il/Handlers/SendEmailAsk2Join.ashx");
    $.post("http://www.sponser.co.il/Handlers/SendEmailAsk2Join.ashx",
    { 
        txtEmail:e,
        txtName:n,
        txtText:t
      },
      function(data){
        if(data != "ERROR")
        {
            jQuery(document).trigger('close.facebox');
        }
        else
        {
            alert("המערכת לא הצליחה לבצע את השליחה.");
            jQuery(document).trigger('close.facebox');
        }
      }
    );
}



function querySt(ji) {
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i=0;i<gy.length;i++) {
ft = gy[i].split("=");
if (ft[0] == ji) {
return ft[1];
}
}
}
