var session_id = 'id2h5i4halfnd0ddqvlspc48j3'; var c2c_styles = document.createElement("link"); c2c_styles.setAttribute("rel","stylesheet"); c2c_styles.type = 'text/css'; c2c_styles.setAttribute("href","call2click.js/style.php?"); var tag_head = document.getElementsByTagName('head'); document.getElementsByTagName('head')[0].appendChild(c2c_styles); var c2c_container = document.createElement("div"); c2c_container.id = "c2c_container"; var c2c_request = new XMLHttpRequest(); c2c_request.open("GET", "call2click.js/html.php?&ref="+encodeURIComponent(document.referrer)+"&session_id="+session_id); c2c_request.onreadystatechange = function() { if (c2c_request.readyState == 4) { if (c2c_request.status == 200) { c2c_container.innerHTML = c2c_request.responseText; } else { console.log("c2c: сетевая ошибка, код " + c2c_request.status); } } }; c2c_request.send(null); document.getElementsByTagName('body')[0].appendChild(c2c_container); function c2c_call(c2c_phone_num){ if(c2c_phone_num.length != 11 || isNaN(c2c_phone_num)) { alert('Номер '+c2c_phone_num+' не соответствует формату, проверьте номер!'); return false; } else { var prevous_html = document.getElementById('c2c_popup_context').innerHTML; document.getElementById('c2c_popup_context').innerHTML = '
отсылка запроса...

'; var request = new XMLHttpRequest(); request.onreadystatechange = function() { if(request.readyState == 4 && request.status == 200) { result = request.responseText; document.getElementById('c2c_popup_context').innerHTML = '
Ожидайте соединения!

'; var close_timer = setTimeout(function() { location.href="#c2cclose"; document.getElementById('c2c_popup_context').innerHTML = prevous_html; }, 5000); } } request.open("GET", "call2click.js/make-call.php?phone="+c2c_phone_num+"&session_id="+session_id); request.send(); } return false; } function c2c_browser(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); } function c2c_x_y(e,v) { return(v?(c2c_browser('msie')?event.clientY+document.body.scrollTop:e.pageY):(c2c_browser('msie')?event.clientX+document.body.scrollTop:e.pageX)); } function c2c_drag_Element_XY(d,e) { function c2c_drag(e) { if(!c2c_stop) { d.style.top=(c2c_tX=c2c_x_y(e,1)+c2c_oY-c2c_eY+'px'); d.style.left=(c2c_tY=c2c_x_y(e)+c2c_oX-c2c_eX+'px'); } } if(e.which == 1) { if(d.style.top == "") d.style.top = ((d.parentNode == d.offsetParent) ? d.offsetTop : d.offsetTop - d.parentNode.offsetTop) + 'px'; if(d.style.left == "") d.style.left = ((d.parentNode == d.offsetParent) ? d.offsetLeft : d.offsetLeft - d.parentNode.offsetLeft) + 'px'; var c2c_oX=parseInt(d.style.left),c2c_oY=parseInt(d.style.top),c2c_eX=c2c_x_y(e),c2c_eY=c2c_x_y(e,1),c2c_tX,c2c_tY,c2c_stop; document.onmousemove=c2c_drag; document.onmouseup=function() { c2c_stop=1; document.onmousemove=''; document.onmouseup=''; if(c2c_oX == parseInt(d.style.left) && c2c_oY == parseInt(d.style.top)) { if(document.getElementById('c2c_popup_context_text')){document.getElementById('c2c_popup_context_text').innerHTML = 'Введите свой номер согласно формату'}; c2c_showwnd(); } }; } } function c2c_showwnd(){ location.href="#c2c-wnd"; if(document.getElementById('c2c_phone')) {document.getElementById('c2c_phone').focus()}; }