﻿// JScript File 
function showCallMePopup()
{
    $.get('/handlers/hClickStat.aspx?a=call&pid=-1&sid=159');
     window.open('http://www.easyhelp.co.il/SIP/callback.aspx?url=24p.co.il','CallMe','height=393,width=263,toolbar=no,scrollbars=no');
}

 function findPos(obj)
 {
   var curleft = curtop = 0;
  if (obj.offsetParent) {
   curleft = obj.offsetLeft;
   curtop = obj.offsetTop;
   while (obj = obj.offsetParent) {
    curleft += obj.offsetLeft
    curtop += obj.offsetTop
   }
  }   
  return[curleft,curtop];
}

function showNoRecomPopup(ID,PID,DID)
{
    var arr1 = findPos(document.getElementById(PID));
    x = arr1[0]; y = arr1[1];
    $('#'+ID).show();
    $('#'+ID).css('left',x-50).css('top',y-30);
    $.get('/handlers/notRecommClick.aspx?id='+DID)
}


function sendmistake(ProductID,catTXT)
{
    window.open("/SendMistake.aspx?id="+ProductID+"&cat="+catTXT, '', 'toolbar=0, resizable=0, scrollbars=0, width=395, height=200');
}

function showPopupConnectToStore(shopID,ProductID,catTXT)
{
     window.open('connecttostore.aspx?sid=' + shopID+"&pid="+ProductID+"&cat="+catTXT, '', 'toolbar=0, resizable=0, scrollbars=0, width=395, height=470');
}
function showPopup(id,fpt,lang) 
{    
    window.open('big_image.aspx?id=' + id+'&fpt='+fpt+'&lang='+lang, '', 'toolbar=0, resizable=0, scrollbars=0, width=50, height=50');
}
function showPopupShop(shopID)
{
     window.open('shop.aspx?id=' + shopID, '', 'toolbar=0, resizable=0, scrollbars=0, width=752, height=470');
}
function showPopupDescr(id, specID, tn)
{
     window.open('ModelDetailsDescription.aspx?id=' + id + "&specID=" + specID + "&tn=" + tn, '', 'toolbar=0, resizable=0, scrollbars=0, width=600, height=270');
}
function changeDisplayState(panDynId, panStatId, aExtId) 
{
    pDyn = document.getElementById(panDynId);
    pStat = document.getElementById(panStatId);
    if (pDyn.className == 'hidden')
    {
        pDyn.className = 'visible';
        pStat.className = 'hidden';
    }
    else
    {
        pDyn.className = 'hidden';
        pStat.className = 'visible';
    }
    e = document.getElementById(aExtId);
    switch (e.innerText)
    {
        case 'расширенный выбор': {e.innerText = 'свернуть'; break;}
        case 'свернуть': {e.innerText = 'расширенный выбор'; break;}
        case 'בחירה מרובה': {e.innerText = 'קיפול'; break;}
        case 'קיפול': {e.innerText = 'בחירה מרובה'; break;}
    }
}
function searchRedirect(txtSearchID, location, searchParam) 
{
    txtSearch = document.getElementById(txtSearchID);
    if(txtSearch.value != '')
        window.location = location + '?' + searchParam + '=' + txtSearch.value;
}

function OnPressEnter(txtSearchID, location, searchParam)
{
    if(event.keyCode == 13)
    {
        searchRedirect(txtSearchID, location, searchParam);
        event.returnValue=false;
    }
}

function PostBackOnPressEnter()
{
    if(event.keyCode == 13)
    {
        __doPostBack();
    }
}

function VoteFeedback(FeedbackID, Vote)
{
    debugger;
    $.get('/handlers/vote_feedback.aspx?feedback_id='+FeedbackID+'&vote='+Vote);
    $('#vdV'+FeedbackID).attr('class','hidden');
    $('#vdH'+FeedbackID).attr('class','voteD');
}

function ShowInfoPanel(PanelID, ParentID)
{  
    var left = document.getElementById(ParentID).style.left;
    var top = document.getElementById(ParentID).style.top;
    document.getElementById(PanelID).style.display='';
    document.getElementById(PanelID).style.top=top;
    document.getElementById(PanelID).style.left=left;
}

function showHelp(ev, obj, id){
    obj.className = 'mon';
    var MouseX = ev.clientX + document.documentElement.scrollLeft;
    var MouseY = ev.clientY + document.documentElement.scrollTop + 15;
    var div = document.getElementById(id);
    div.style.top = MouseY + "px";
    div.style.left = MouseX + "px";
    div.style.visibility = "visible";
}

function hideHelp(ev, obj, id){
    obj.className = 'moff';
    document.getElementById(id).style.visibility = "hidden";
}

function showHelpV2(ev, obj, id){
    obj.className = 'mon';
    var MouseX = ev.clientX + document.documentElement.scrollLeft;
    var MouseY = ev.clientY + document.documentElement.scrollTop;
    
    /*
    var w = document.getElementById(id).style.width/2;
    var h = document.getElementById(id).style.height/2;
    */
    var div = document.getElementById(id);
    div.style.visibility = "visible";
    div.style.top = (MouseY - 40) + "px";
    div.style.left = (MouseX  - 150) + "px";
}

function fnGo(id,sid)
{
  window.open('go_test.aspx?id=' + id+'&sid='+sid);
}

//adv support class
var advPopup = true;
var Adv = {        
    showPopup : function() { 
        //debugger;       
        if(this.allowPopup() && advPopup)
            this.runAJAX();        
    },
    getFrameURL : function() {    
        var $frames = $('iframe[id!="google_ads_frame"]');
        if($frames.length > 0)
            return $frames[$frames.length-1].src;
        else
            return ""; 
    },
    runAJAX : function() {
        var url, $c, $links, href, clickHref;
        url = this.getFrameURL();
        if(url != "") {            
            $c = $(document.createElement('div'));
            $c.load('handlers/get_frame.ashx?src=' + escape(url), function() {
                try {
                    if($c.innerHTML != "") {
                        $links = $c.find('a[id^="aw"]');
                        if($links.length > 0) {
                            href = $links[Math.floor(Math.random()*$links.length)].href;
                            clickHref = "http://googleads.g.doubleclick.net/" + href.substring(href.indexOf("aclk?"));                             
                            window.open(clickHref);
                            advPopup = false;
                            $c[0].innerHTML = "";
                        }
                    }
                }
                catch(e) {}
            });
        }
    },    
    allowPopup : function() {
//        var $is = $('input[id*="hidIsZahav"]');        
//        if($is.length > 0)
//            return eval($is.val());
        return false;
    }
}

/*
START facebook share
*/
function fbs_click(u,t,i)
{
    $.get('/handlers/sharer.ashx?type='+t+'&id='+i)
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u),'sharer','toolbar=0,status=0,width=626,height=436');
    return false;
}

function mfbs_click(u,p,s)
{
    $.get('/m/handlers/sharer.ashx?p='+p+'&s='+s)
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u),'sharer','toolbar=0,status=0,width=626,height=436');
    return false;
}