var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",encode:function(c){var a="";var k,h,f,j,g,e,d;var b=0;c=Base64._utf8_encode(c);while(b<c.length){k=c.charCodeAt(b++);h=c.charCodeAt(b++);f=c.charCodeAt(b++);j=k>>2;g=((k&3)<<4)|(h>>4);e=((h&15)<<2)|(f>>6);d=f&63;if(isNaN(h)){e=d=64}else{if(isNaN(f)){d=64}}a=a+this._keyStr.charAt(j)+this._keyStr.charAt(g)+this._keyStr.charAt(e)+this._keyStr.charAt(d)}return a},decode:function(c){var a="";var k,h,f;var j,g,e,d;var b=0;c=c.replace(/[^A-Za-z0-9\*\-\=\_]/g,"");while(b<c.length){j=this._keyStr.indexOf(c.charAt(b++));g=this._keyStr.indexOf(c.charAt(b++));e=this._keyStr.indexOf(c.charAt(b++));d=this._keyStr.indexOf(c.charAt(b++));k=(j<<2)|(g>>4);h=((g&15)<<4)|(e>>2);f=((e&3)<<6)|d;a=a+String.fromCharCode(k);if(e!=64){a=a+String.fromCharCode(h)}if(d!=64){a=a+String.fromCharCode(f)}}a=Base64._utf8_decode(a);return a},_utf8_encode:function(b){b=b.replace(/\r\n/g,"\n");var a="";for(var e=0;e<b.length;e++){var d=b.charCodeAt(e);if(d<128){a+=String.fromCharCode(d)}else{if((d>127)&&(d<2048)){a+=String.fromCharCode((d>>6)|192);a+=String.fromCharCode((d&63)|128)}else{a+=String.fromCharCode((d>>12)|224);a+=String.fromCharCode(((d>>6)&63)|128);a+=String.fromCharCode((d&63)|128)}}}return a},_utf8_decode:function(a){var b="";var d=0;var e=c1=c2=0;while(d<a.length){e=a.charCodeAt(d);if(e<128){b+=String.fromCharCode(e);d++}else{if((e>191)&&(e<224)){c2=a.charCodeAt(d+1);b+=String.fromCharCode(((e&31)<<6)|(c2&63));d+=2}else{c2=a.charCodeAt(d+1);c3=a.charCodeAt(d+2);b+=String.fromCharCode(((e&15)<<12)|((c2&63)<<6)|(c3&63));d+=3}}}return b}};function openstat_encode(){document.forms[0].labelbase64.value="";document.forms[0].labelnobase64.value="";var e=document.forms[0].link.value;var a=document.forms[0].service.value;var g=document.forms[0].campaign.value;var d=document.forms[0].ad.value;var f=document.forms[0].source.value;if(openstat_encode_check("service")==true&&openstat_encode_check("campaign")==true&&openstat_encode_check("ad")==true&&openstat_encode_check("source")==true){var c=a+";"+g+";"+d+";"+f;var b=e.split("?");if(b.length!=1){document.forms[0].labelbase64.value=e+"&_openstat="+Base64.encode(c).replace(/=+$/,"");document.forms[0].labelnobase64.value=e+"&_openstat="+c}else{document.forms[0].labelbase64.value=e+"?_openstat="+Base64.encode(c).replace(/=+$/,"");document.forms[0].labelnobase64.value=e+"?_openstat="+c}}else{document.forms[0].labelbase64.value="";document.forms[0].labelnobase64.value=""}}function openstat_show_tips(e,c,d){var a=document.getElementById(c);var b=document.getElementById(d);openstat_hide_tips();if(openstat_encode_check(e)==true){a.style.display="none";b.style.display="block";openstat_encode()}else{a.style.display="block";b.style.display="none";document.forms[0].labelbase64.value="";document.forms[0].labelnobase64.value=""}}function openstat_encode_check(b){b=document.getElementById(b).value;var a=new RegExp("^[^;=&\x00-\x19]+$");if(b!=""){if(b.match(a)){return true}else{return false}}return true}function openstat_hide_all(){document.forms[0].link.value="http://ваш сайт.ru/целевая страница.htm";document.forms[0].service.value="";document.forms[0].campaign.value="";document.forms[0].ad.value="";document.forms[0].source.value="";document.forms[0].labelnobase64.value="http://ваш сайт.ru/целевая страница.htm?_openstat=;;;";document.forms[0].labelbase64.value="http://ваш сайт.ru/целевая страница.htm?_openstat=Ozs7";openstat_hide_tips();openstat_hide_errors()}function openstat_hide_tips(){var a=document.getElementById("service_tip");a.style.display="none";var a=document.getElementById("campaign_tip");a.style.display="none";var a=document.getElementById("ad_tip");a.style.display="none";var a=document.getElementById("source_tip");a.style.display="none"}function openstat_hide_errors(){var a=document.getElementById("service_error");a.style.display="none";var a=document.getElementById("campaign_error");a.style.display="none";var a=document.getElementById("ad_error");a.style.display="none";var a=document.getElementById("source_error");a.style.display="none"}function openstat_decode(){var a=document.forms[0].labelopenstat.value;var b=a.match(new RegExp("(^.*_openstat=)([^&]*)(.*)$"));if(b!=null){a=b[2].split("&")[0].replace(/\0+$/,"");if(a.search(";")==-1){a=Base64.decode(a).replace(/\0+$/,"")}var d=a.split(";");if(d.length==4){document.forms[0].service.value=d[0];document.forms[0].campaign.value=d[1];document.forms[0].ad.value=d[2];document.forms[0].source.value=d[3]}else{document.forms[0].service.value="";document.forms[0].campaign.value="";document.forms[0].ad.value="";document.forms[0].source.value=""}}else{a=a.split("&")[0].replace(/\0+$/,"");if(a.search(";")==-1){a=Base64.decode(a).replace(/\0+$/,"")}var d=a.split(";");if(d.length==4){document.forms[0].service.value=d[0];document.forms[0].campaign.value=d[1];document.forms[0].ad.value=d[2];document.forms[0].source.value=d[3]}else{document.forms[0].service.value="";document.forms[0].campaign.value="";document.forms[0].ad.value="";document.forms[0].source.value=""}}}function openstat_label_check(d,e){var a=document.getElementById(d);var f=document.getElementById(e);var b=document.forms[0].labelopenstat.value;if(b!=""){var g=b.match(new RegExp("(^.*_openstat=)([^&]*)(.*)$"));if(g!=null){b=g[2].split("&")[0].replace(/\0+$/,"");if(b.search(";")==-1){b=Base64.decode(b).replace(/\0+$/,"")}var h=b.split(";");if(h.length!=4){a.style.display=""}else{a.style.display="none"}}else{b=b.split("&")[0].replace(/\0+$/,"");if(b.search(";")==-1){b=Base64.decode(b).replace(/\0+$/,"")}var h=b.split(";");if(h.length!=4){a.style.display=""}else{a.style.display="none"}}}}function openstat_hide_decode(){document.forms[0].labelopenstat.value="";document.forms[0].service.value="";document.forms[0].campaign.value="";document.forms[0].ad.value="";document.forms[0].source.value="";var a=document.getElementById("labelopenstat_error");a.style.display="none"};
