
function goToURL(adresa) {

window.location = adresa;

location.reload(true);

return false;

}

function changeDivs(div1,div2) {
	document.getElementById(div1).style.display = 'none';
	document.getElementById(div2).style.display = 'block';
}

function isAlphabetic(val)
{
if (val.match(/^[a-zA-Z ]+$/))
{
return true;
}
else
{
return false;
} 
}

function isAlphaNumeric(val)
{
if (val.match(/^[a-z.A-Z0-9_ ]+$/))
{
return true;
}
else
{
return false;
} 
}

function isNumeric(value) {
  if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
  return true;
}

function isValidEmail(email){
 	var RegExp = /^((([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+(\.([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+)*)@((((([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.))*([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.)[\w]{2,4}|(((([0-9]){1,3}\.){3}([0-9]){1,3}))|(\[((([0-9]){1,3}\.){3}([0-9]){1,3})\])))$/
  if (RegExp.test(email)) 
  {
  	return true;
  }else{
 	return false;
  }
}

var reload
var graph = '';
var twitter_username = '';
var word_id = '';
function loadFeed(graph2,twitter_username2,word_id2)
{		
		if (graph == "") {
        	graph = graph2;
        }
        if (twitter_username == "") {
        	twitter_username = twitter_username2;
        }
        if (word_id == "") {
        	word_id = word_id2;
        }
        
		var pars = '?graph='+graph;
        pars += '&twitter_username='+twitter_username;
        pars += '&word_id='+word_id;
        
        var url = 'http://www.twitelect.com/ajax/loadFeed.php';
        var myAjax = new Ajax.Request(
    
            url, 
            {
                method: 'get', 
                parameters: pars, 
                onComplete: theResponse
            });
	    
    function theResponse(originalRequest)
    {
    	var response = originalRequest.responseText;
    	document.getElementById('liveFeed').innerHTML = response;
	}
    reload = setTimeout("loadFeed()",60000);
}

function toggleGraphBars(which_graph,type) {

	var total = parseInt(document.getElementById('total'+which_graph).value);
    var start = parseInt(document.getElementById('start'+which_graph).value);
    
    if (type == 'next') {
    	start++;
        if (start+4 < total) {
	    for (i=1; i<=total; i++) {
    		if (i<start || i-5>start) {
        		document.getElementById('bar'+which_graph+i).style.display = 'none';
	        }
    	    else {
        		document.getElementById('bar'+which_graph+i).style.display = 'block';
	        }
    	}
        document.getElementById('start'+which_graph).value = start;
        }
    }
    else if (type == 'prev') {
    	start--;
        if (start > 0) {
	    for (i=1; i<=total; i++) {
    		if (i<start || i-5>start) {
        		document.getElementById('bar'+which_graph+i).style.display = 'none';
	        }
    	    else {
        		document.getElementById('bar'+which_graph+i).style.display = 'block';
	        }
    	}
        document.getElementById('start'+which_graph).value = start;
        }
    }
    
}