function addJavascript(jsname) {
var th = document.getElementsByTagName('head')[0];
var s = document.createElement('script');
s.setAttribute('type','text/javascript');
s.setAttribute('src',jsname);
th.appendChild(s);
}
addJavascript('/fckeditor/fckeditor.js');



window.onload = function()
{
if (document.location.href.substring(0,document.location.href.lastIndexOf('editSubmission')) ) {
var oFCKeditor = new FCKeditor('body');
oFCKeditor.Width = '600px';
oFCKeditor.Height = '800px';
oFCKeditor.ToolbarSet = 'Avtoro';
oFCKeditor.ReplaceTextarea();
}
//nag_screen();
inittabs();
}

function hideads(ad,w,h) {

var url = location.href;
var words = new Array();
var i;
var b;

words[0] = 'gurd';
words[1] = 'sublech';
words[2] = 'sublich';
words[3] = 'gola';
words[4] = 'playboy';
words[5] = 'playmate';
words[6] = 'goli';
words[7] = 'porno';
words[8] = 'seks';

for (i in words)
{
  if (url.match(words[i])) {
     b = 1;
     break;
  }
}

if (b != 1) {
document.write('<iframe scrolling="no" style="width:'+w+'px;height:'+h+'px;" frameborder="0" src="'+ad+'" marginheight="0" marginwidth="0"></iframe>');
}

}

function gallery(gid) {
document.write('<iframe scrolling="no" style="width:470px;height:394px;" frameborder="0" src="http://g.avtora.com/ginc.php?galleries_id='+gid+'" marginheight="0" marginwidth="0"></iframe>');
}
// begin charts crap
var tabLinks = new Array();
var contentDivs = new Array();

function inittabs() {

var tabListItems = document.getElementById('tabs').childNodes;
for ( var i = 0; i < tabListItems.length; i++ ) {
if ( tabListItems[i].nodeName == "LI" ) {
var tabLink = getFirstChildWithTagName( tabListItems[i], 'A' );
var id = getHash( tabLink.getAttribute('href') );
tabLinks[id] = tabLink;
contentDivs[id] = document.getElementById( id );
}
}

var i = 0;
for ( var id in tabLinks ) {
tabLinks[id].onclick = showTab;
tabLinks[id].onfocus = function() { this.blur() };
if ( i == 0 ) tabLinks[id].className = 'selected';
i++;
}

var i = 0;
for ( var id in contentDivs ) {
if ( i != 0 ) contentDivs[id].className = 'tabContent hide';
i++;
}
}
function showTab() {
var selectedId = getHash( this.getAttribute('href') );

for ( var id in contentDivs ) {
if ( id == selectedId ) {
tabLinks[id].className = 'selected';
contentDivs[id].className = 'tabContent';
} else {
tabLinks[id].className = '';
contentDivs[id].className = 'tabContent hide';
}
}

return false;
}
function getFirstChildWithTagName( element, tagName ) {
for ( var i = 0; i < element.childNodes.length; i++ ) {
if ( element.childNodes[i].nodeName == tagName ) return element.childNodes[i];
}
}
function getHash( url ) {
var hashPos = url.lastIndexOf ( '#' );
return url.substring( hashPos + 1 );
}
// end charts crap

function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { 
      offset += search.length
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}
function nag_screen() {
    if (document.cookie.length > 0) {
        if (!(get_cookie("setInquiryCookie") == "hide")) {
            var domain = "http://" + window.location.hostname;
            HttpRequest(domain+"/anketa/index.php");
        }
    }
}

function HttpRequest(url){
    var pageRequest = false;
/*@cc_on
@if (@_jscript_version >= 5)
    try {
        pageRequest = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e){
        try {
            pageRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
    catch (e2){
        pageRequest = false;
    }
}
@end
@*/
    if (!pageRequest && typeof XMLHttpRequest != 'undefined')
    pageRequest = new XMLHttpRequest();
        if (pageRequest){
            pageRequest.open('GET', url, false);
            pageRequest.send(null);
            embedpage(pageRequest);
        }
}

function embedpage(request) {
    if (window.location.href.indexOf("http")==-1 || request.status==200) {
        document.write(request.responseText);
    }
}
