function httpRequest(target,url,method,postdata) {
    var xmlHttp;
    
    if( window.ActiveXObject ) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }else if( window.XMLHttpRequest ) {
        xmlHttp = new XMLHttpRequest();
        xmlHttp.overrideMimeType('text/xml');
    }

    xmlHttp.onreadystatechange = function () {
	var field = document.getElementById(target);
	if( xmlHttp.readyState == 4 ) {
    	    if( xmlHttp.status == 200 ) {
		field.innerHTML = xmlHttp.responseText;
	    }else{
    	        field.innerHTML = 'Damn it, some problems. Report it to admin@spx.pl :  HTTP status ' + xmlHttp.status + ' = ' + xmlHttp.statusText;
    	    }
	}else{
	    field.innerHTML = '';
	}
    }
    try {
	xmlHttp.open(method, url, true );
    	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    	xmlHttp.setRequestHeader('X-Powered-By','slap.pl');
    	xmlHttp.send(postdata);
    }catch(e){
	alert( "Please report this msg to admin@spx.pl\nxmlHttp.open() Error: " + e.toString() );
    }
}

function getCheckbox() {
    var x=0;
    var i=0;
    var returnarray=Array();
    for( x=0; x < document.myform.checkboxes.length; x++ ) {
	if(document.myform.checkboxes[x].checked) {
	    returnarray[i]=document.myform.checkboxes[x].value;
	    i=i+1;
	}
    }
    return returnarray;
}

function showdiv(id) {
    if(document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'block';
    }else{
        if(document.layers) { // Netscape 4
            document.id.display = 'block';
        }else{ // IE 4
            document.all.id.style.display = 'block';
        }
    }
}

function hidediv(id) {
    if(document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'none';
    }else{
        if(document.layers) { // Netscape 4
            document.id.display = 'none';
        }else{ // IE 4
            document.all.id.style.display = 'none';
        }
    }
}

function selectfield(field) {
    field.focus();
    field.select();
}

function checklogin() {
    httpRequest('checklogin','signup.php','POST','checklogin='+document.signup.newlogin.value);
}

function bookmark() {
    title = "Slap.pl - Podziel siê pornusami";
    url = "http://www.slap.pl/";
    if (window.sidebar) {
	window.sidebar.addPanel(title, url,"");
    }else if( window.external ) { // IE Favorite
	window.external.AddFavorite( url, title); 
    }else if(window.opera && window.print) {
	return true;
    }
}

function ajax_addcomment() {
    httpRequest('addcomment','/comment.php?c='+document.ajax_comment.content_id.value+'&nickname='+document.ajax_comment.nickname.value+'&comment='+document.ajax_comment.comment.value,'GET','');
    alert('komentarz dodany:)');
}

function openwindow(url, title, width, height) {
    window.open(url,title,'left=20,top=20,width='+width+',height='+height+',toolbar=0,resizable=0');
}

function blogapi_getblogs() {
    httpRequest('temp','/blogapi.php','POST','login='+document.info.login.value+'&password='+document.info.password.value+'&remember='+document.info.remember.value+'&api='+document.info.api.value);
}

function blogapi_selectblog() {
    httpRequest('temp','/blogapi.php','POST','login='+document.info.login.value+'&password='+document.info.password.value+'&blogid='+document.info.blogid.value);
}

function switchcontent(pn, h, ct, c) {
    if (ct == 1) {
	location.href='/watch?v='+h+'&p='+pn;
    }else{
	document.getElementById('image').src=c+'.jpg';
	document.getElementById('c'+pn).style.borderColor='#000000';
	document.getElementById('imagescroll').scrollLeft=(129*(pn-1));
	location.href='#'+pn
    }
}

function _onloadWatch() {
    if( location.hash ){
	n = location.hash.replace(/#/,'');
	if( _CONTENT[n] == false ) {
	    n=0
	}else{
	    document.getElementById('imagescroll').scrollLeft = 129*(n-1);
	}
    }else{
	n=1;
    }
    myObj = eval('(' + _CONTENT[n] + ')');
    document.getElementById('c'+n).style.borderColor = '#000000';
    document.getElementById('image').src = myObj.content+'.jpg';
}