
function getData(url,id) {
	if ($("#"+id).length==0 && $("#reqdata").length==0) {
		var d = $('<div id="reqdata"></div>');
		$("body").append(d);
	} else {
		d = ($("#"+id).length>0)? $("#"+id) : $("#reqdata");
	}

	elemBlur();


	$.ajax({
	type: "GET",
	url: url,
	success: function(html){
	        d.html("");
	        d.append(html);
		if ($("#blurDiv").length>0) $("#blurDiv").remove();
		}
	
	});


}


var scroll_top;
var scroll_left;
var docwidth;
var docheight;
function getviewpoint(){ //get window viewpoint numbers
	var ie=document.all && !window.opera;
	var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000; //Preliminary doc width in non IE browsers
	var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body; //create reference to common "body" across doctypes
	scroll_top=(ie)? standardbody.scrollTop : window.pageYOffset;
	scroll_left=(ie)? standardbody.scrollLeft : window.pageXOffset;
	docwidth=(ie)? standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16);
	docheight=(ie)? standardbody.clientHeight : window.innerHeight;
}




function elemBlur(elem) {
	var hgt = $("#content").height() + $("#footer").height() + 78 + 'px';
	var wdt = document.body.scrollWidth + 'px';
	if ($("#blurDiv").length>0) $("#blurDiv").remove();
	var bl = $('<div id="blurDiv"></div>').css({width:wdt,height:hgt});
	$("body").append(bl)
	var img = $('<img src="/img/aloader.gif" alt="load" id="loadindicator" />');
	bl.append(img);
	getviewpoint();
	var ptop = (66 >= docheight)? '0px' : (docheight/2 - 33)+'px';
	var pleft = (66 >= docwidth)? '0px' : (docwidth/2 - 33)+'px';
	img.css({width:"66px",height:"66px",position:"fixed",left:pleft,top:ptop});
}



// translator
function changeTrWay(el) {
	var transwayf = $('#transwayf');
	var otherwayf = $('#otherwayf');
	var altf = $('#'+$(el).attr('id')+'img').attr('alt');
	if (transwayf.attr('value') == '1') {
		$(el).css({backgroundPosition:'0 -25px'});
		transwayf.attr('value','2');
	} else {
		$(el).css({backgroundPosition:'0 0'});
		transwayf.attr('value','1');
	}
	$('#'+$(el).attr('id')+'img').attr('alt',otherwayf.attr('value'));
	otherwayf.attr('value',altf);
}
function translateThis(f) {

    if ($('form#smForm :input[name="message"]').attr('value').length > 400) 
    	$('form#smForm :input[name="message"]').attr('value').substring(0,400);
	var message = $('form#smForm :input[name="message"]').attr('value');
	var transway = $('form#smForm :input[name="transway"]').attr('value');
    var params = {
    	message : message,
    	transway : transway,
    	a : 'translate'
    };
    
    

	var d = $('#transresult');
	$.post("/trans/tr.php", params,
		function(html){
	        d.html("");
	        d.append(html);
		if ($("#blurDiv").length>0) $("#blurDiv").remove();
		}, "html");
	elemBlur();

    return false;
}




function addtoopml(url, id){
	url = url+"&js=1";

	$.ajax({
	type: "GET",
	url: url,
	success: function(html){
	        $('#'+id).html("");
	        $('#'+id).append(html);
		if ($("#blurDiv").length>0) $("#blurDiv").remove();
		}

	});

	elemBlur();

}


function sndRequest(vote,id_num,ip_num) {
	var d = $('#unit_long'+id_num);
	d.innerHTML = '<div style="height: 20px;"><em>Loading ...</em></div>';
	$.ajax({
	type: "GET",
	url: '/rating/rpc.php?j='+vote+'&q='+id_num+'&t='+ip_num,
	success: function(text){
	        if(text.indexOf('|') != -1) {
        	    update = text.split('|');
	            changeText(update[0], update[1]);
	        }
		}
	
	});
}
function changeText( div2show, text ) {
    // Detect Browser
    var IE = (document.all) ? 1 : 0;
    var DOM = 0; 
    if (parseInt(navigator.appVersion) >=5) {DOM=1};

    // Grab the content from the requested "div" and show it in the "container"

    if (DOM) {
        var viewer = document.getElementById(div2show)
        viewer.innerHTML=text
    }
    else if(IE) {
        document.all[div2show].innerHTML=text
    }
}



$(document).ready(function(){
	$('.sideblock .artinlist').each(function(){
		var p = $(this);
		var a = $(this).find('a');
		$(p).css({cursor: 'pointer'});
		$(p).click(function(){
			location = $(a).attr('href');
		});
		$(p).hover(function(){
			$(p).css({background:'#efefef'});
		},function(){
			$(p).css({background:'#fff'});
		});
	});

	$('.cse-branding-logo').css({cursor: 'pointer'});
	$('.cse-branding-logo').click(function(){
		$('#cse-search-box').submit();
	});
	$('.cse-branding-text').css({cursor: 'pointer'});
	$('.cse-branding-text').click(function(){
		$('#cse-search-box').submit();
	});


	$("a","#artfulltext").click(function(){
		var newwindow = window.open($(this).attr("href"), "liverextrnal");
		newwindow.focus();
		return false
	});

});


function searchSubmit() {
	if ($("input[name=q]").attr("value")!='') {
		return true;
	} else {
		return false;
	}
}

