﻿
function ValidateLength(oSrc, args)
{
    
    args.IsValid = (oSrc.text.length >= 10);
    
}
function Nav(url)
{
	window.location = url;
}

function GotoRank(Sender,Url)
{	//window.open(Url);
    window.location = Url;    
    return false;
}

function CalcHeight(iframeId)
{
    var the_height = document.getElementById(iframeId).contentWindow.document.body.clientHeight;
    document.getElementById(iframeId).height = the_height+20;
}

function GotoDetailesEx(Sender,Url,SenderId,RepeaterId,ifWidth, ifHeight)
{

    //get the sender id 
    var senderId = Sender.id ;            
    
    //get the row nunber
    //var strart = senderId.indexOf("ctl");
    //var end = senderId.indexOf(SenderId);            
   // var rowNumber = senderId.substring(strart + 3,end - 1);          
   var rowNumber = 1;
    
    //create the panel object id  
    //var panelId = RepeaterId + "_ctl" + rowNumber + "_pnl" ;
    
    var panelId = SenderId;
    
    
    var innerText = document.getElementById(panelId).innerHTML.toUpperCase();
    
   // for (var k = 0 ; k<innerText.length ; k++){
  //  }
   // alert(innerText.indexOf("           "));
  //  innerText.replace(" ", "k");
   // alert (innerText);
   // innerText.replace(/^\s+|\s+$/g,"");
  //  alert(innerText.charCodeAt(3));
  //  alert(innerText.length);
    
    //alert(innerText.indexOf("IFRAME"));
    
  //  if(innerText == "<INPUT TYPE=\"HIDDEN\">" || innerText == "")
    if (!(innerText.indexOf("IFRAME")>0))
    {
       
       //alert("dsadsads");
        //create the iframe control
        var contentIframe = '<iframe frameborder="0" id="IFR_' + panelId + '" onLoad="CalcHeight(this.id)" class="inner_iframe" src="' + Url + Sender.alt  +'" width="' + ifWidth +  '" frameborder="0px"></iframe>';//+'" width="' + ifWidth + '" height="' + ifHeight
        var closeButton =   '<div class="close_button_div"><IMG class="repeater_action_button" id="' + senderId + '" onclick="GotoDetailesEx(document.getElementById(\'' + panelId + '\'),\'' + Url + '\',\'' + SenderId  + '\',\'' + RepeaterId + '\',\'' + ifWidth + '\',\'' + ifHeight + '\');" src="../Images/buttons/btn_close.gif" alt="'+ rowNumber +'" style="border-width:0px;" title="סגור" /></div>' ;        
        document.getElementById(panelId).innerHTML = contentIframe  + closeButton;         
       
    }
    else
    {  
        //alert("else"); 
        //remove the iframe control             
        document.getElementById(panelId).innerHTML = "<input type='hidden'/>";        
    }
    
}

function GotoDetailes(Sender,Url,SenderId,RepeaterId)
{    
    
    //get the sender id 
    var senderId = Sender.id ;            
    
    //get the row nunber
    var strart = senderId.indexOf("ctl");
    var end = senderId.indexOf(SenderId);            
    var rowNumber = senderId.substring(strart + 3,end - 1);          
   //var rowNumber = 1;
    
    //create the panel object id  
    var panelId = RepeaterId + "_ctl" + rowNumber + "_pnl" ;

    GotoDetailesEx(Sender,Url,panelId,RepeaterId,'770px','700px');                        
}

function GotoURL(Sender,Url,SenderId)
{       
    window.parent.location = Url + Sender.alt;
}

function OpenPrintWindow(ControlToPrintId)
{        //debugger;                            
    var newWindow = window.open("../General/PrintPage.htm");    
    newWindow.document.write("<html>")
    newWindow.document.write("<head>")
    newWindow.document.write("<link href='http://www.kamaze.co.il/App_Themes/Default/Common.css' rel='stylesheet' type='text/css' />");
    newWindow.document.write("<link href='http://www.kamaze.co.il/App_Themes/Default/PageLayout.css' rel='stylesheet' type='text/css' />");
    newWindow.document.write("<link href='http://www.kamaze.co.il/App_Themes/Default/Input.css' rel='stylesheet' type='text/css' />");
    newWindow.document.write("<link href='http://www.kamaze.co.il/App_Themes/Default/Controls.css' rel='stylesheet' type='text/css' />");
    newWindow.document.write("</head>");
    newWindow.document.write("<body dir='rtl'>");
    newWindow.document.write("<center>");
    newWindow.document.write("<br/><script>function doPrint() { window.location.reload(); window.print();} </script>");
    newWindow.document.write("<a href='javascript:doPrint();' text='שלח להדפסה' ><img src='../Images/Buttons/btn_print.gif' border='0' alt='הדפס'/></a>");    
    newWindow.document.write("<table>");
    newWindow.document.write(document.getElementById(ControlToPrintId).innerHTML);
    newWindow.document.write("</table>");
    newWindow.document.write("</center>");
    newWindow.document.write("</body>");
    newWindow.document.write("</html>");
    newWindow.focus();
    return false;
}

function SetIframeHref(controlId,Url)
{
    var ifarmeControl = document.getElementById(controlId);
    ifarmeControl.src = Url;                                            
}

function SetDivContent(controlId,Content)
{
    var div = document.getElementById(controlId);
    div.innerHTML = Content;
}

function SetPageContent(frameId,frameUrl,TitleId,Title)
{
    SetDivContent(TitleId,Title);
    SetIframeHref(frameId,frameUrl);    
    return false;
}

function OpenEditWindow(file)
{
    var newWindow = window.open("emaeditor.aspx?FILE_TO_EDIT=" + file ,"Editor");
    return false;
}
function OpenSendPassword()
{
    window.open('../../שכחתי-סיסמא.aspx',null,'height=130,width=400,status=yes,toolbar=no,menubar=no,location=no');
}

function OpenLead(url)
{
    window.open(url,"_blank","height=600,width=550,status=no,menubar=no,location=yes");
    return false;
}

function OpenMailToFriend(height, width)
{
    window.open('../../שלח-לחבר.aspx',"_blank","height="+ height + ",width="+ width + ",status=no,menubar=no,location=no");
    return false;
}

function bookmarksite(title,url){
    if (window.sidebar) // firefox
	    window.sidebar.addPanel(title, url, "");
    else if(window.opera && window.print){ // opera
	    var elem = document.createElement('a');
	    elem.setAttribute('href',url);
	    elem.setAttribute('title',title);
	    elem.setAttribute('rel','sidebar');
	    elem.click();
    } 
    else if(document.all)// ie
	    window.external.AddFavorite(url, title);
}

function starpopup()
   {
      window.open('http://www.kamaze.co.il/Bezeq/table.html','windname','width=592,height=650,scrollbars,noresizable,nononotop=0,location,top=150,left=500');
   }
   
   
function pnyxeApiCallback(apiName, callId, apiResult)
{
    var span = document.getElementById(callId);
    var spanTitle = document.getElementById('Title'+callId);
    if (apiResult == '0')
    {
        spanTitle.innerHTML = 'ספרו כמה אתם משלמים';
        span.innerHTML = 'הוסיפו תגובה...';
    }
    else if (apiResult == '1')
    {
        spanTitle.innerHTML = 'כמה אחרים משלמים?';
        span.innerHTML = 'קראו תגובה אחת...';
    }
    else
    {
        spanTitle.innerHTML = 'כמה אחרים משלמים?';
        span.innerHTML = 'קראו '+ apiResult+ ' תגובות...';
    }
}


function CheckUrl(sender, args)
  {
    if (args.Value.indexOf("'")>=0 ||
        args.Value.indexOf("?")>=0 ||
        args.Value.indexOf("&")>=0 ||
        args.Value.indexOf("\"")>=0 ||
        args.Value.indexOf("%")>=0  )
    {
         args.IsValid = false;
         document.getElementById("txtVirtualUrl").focus();
         return;
    }
     args.IsValid = true;
  }