var d = document;
var xmlHttp = null;
var xmlHttp2 = null;
var serverAdress = thisServerAdress; //from config.php

function showThisMenu(ele)
{

	if( d.getElementById(ele).style.display == "none" )
	{
		d.getElementById(ele).style.display = "";
	}
	else
	{
		d.getElementById(ele).style.display = "none";
	}
}

function rTrim(sString)
{
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
	sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function lTrim(sString)
{
	while (sString.substring(0,1) == ' ')
	{
	sString = sString.substring(1, sString.length);
	}
	return sString;
}

function Trim( sString )
{
	return lTrim( rTrim(sString) );
}

function isEmpty( ele )
{
	if( Trim(ele) == "" || ele == undefined || ele == null )
		return true;	
	return false;
}

function InitXMLHttpRequest()
{
	try
  	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
  	}
  	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
  	}
}

function InitXMLHttpRequest2()
{
	try
  	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp2 = new XMLHttpRequest();
  	}
  	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp2 = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
  	}
}

function sendRequest( id, opp )
{
	xmlHttp.onreadystatechange=function()
    {
		if( xmlHttp.readyState==4 )
        {
			document.getElementById("body").innerHTML = xmlHttp.responseText;
        }
     }
	
	//document.getElementById("url").value = thisServerAdress + "/index.php?action=investment&id=" + id + "&oppage=" + opp + "&optyp=mm";
	
    xmlHttp.open( "GET", "includes/investment.php?&id=" + id + "&oppage=" + opp + "&optyp=mm&http=link&req=" + Math.random(), true );
    xmlHttp.send(null);
}


function sendBusinessRequest( url )
{
	xmlHttp.onreadystatechange=function()
    {
		if( xmlHttp.readyState==4 )
        {
			document.getElementById("body").innerHTML = xmlHttp.responseText;
        }
     }

	//document.getElementById("url").value = thisServerAdress + "/index.php?action=" + url.replace(".php?", "&");
	
    xmlHttp.open( "GET", "includes/"+url + "&http=link&req=" + Math.random(), true );
    xmlHttp.send(null);
}

function loadHttppage( url )
{
	xmlHttp.onreadystatechange=function()
    {
		if( xmlHttp.readyState==4 )
        {
			document.getElementById("body").innerHTML = xmlHttp.responseText;
        }
     }

    xmlHttp.open( "GET", "includes/"+url + ".php?http=link&req=" + Math.random(), true );
    xmlHttp.send(null);
}

var xmlHttp ="";
function loadHttpAbout( name )
{
	xmlHttp.onreadystatechange=function()
    {
		if( xmlHttp.readyState==4 )
        {
			document.getElementById("body").innerHTML = xmlHttp.responseText;
        }
     }
	 
	//document.getElementById("url").value = thisServerAdress + "/index.php?action=content&id="+name;

    xmlHttp.open( "GET", "includes/content.php?id="+name + "&http=link&req=" + Math.random(), true );
    xmlHttp.send(null);
}

function loadsStoryMenu( id )
{
	xmlHttp2.onreadystatechange=function()
    {
		if( xmlHttp2.readyState==4 )
        {
			document.getElementById("sStory").innerHTML = xmlHttp2.responseText;
        }
     }

    xmlHttp2.open( "GET", "includes/sstorymenu.php?id=" +id + "&req=" + Math.random(), true );
    xmlHttp2.send(null);
}


function getUrlValue( name, url )
{
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var tmpURL = url;
  var results = regex.exec( tmpURL );
  if( results == null )
	return "";
  else
	return results[1];
}
