var xmlHttp
var sArea

var xmlHttp2
var sArea2

var xmlHttp3
var sArea3

var xmlHttp4
var sArea4

var xmlHttp5
var sArea5

var xmlHttpMail


function ShowDiv(sShowDiv)
{
    if (document.getElementById(sShowDiv) != null)
	{
        if(document.getElementById(sShowDiv).style.display == 'none' || document.getElementById(sShowDiv).style.display == null)
        {
            document.getElementById(sShowDiv).style.display = 'block';
        }
        else
        {
            document.getElementById(sShowDiv).style.display = 'none';
        }
        //alert('show:' + sShowDiv);
    }
    else
    {
        //alert('cannot show:' + sShowDiv);
    }
}

function HideDiv(sHideDiv)
{
    if (document.getElementById(sHideDiv) != null)
	{
        document.getElementById(sHideDiv).style.display = 'none';
        //alert('hide:' + sHideDiv);
    }
    else
    {
        //alert('cannot hide:' + sHideDiv);
    }
}

function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
		
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}

function stateMail() 
{ 
	if (xmlHttpMail.readyState==4 || xmlHttpMail.readyState=="complete")
	{ 
	    //alert('Readystat Ok');
	    //populate(xmlHttp.responseText);
	} 
} 

function mailRequest(sUrl)
{
    xmlHttpMail=GetXmlHttpObject();
    if (xmlHttpMail==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	sUrl= sUrl + "&sid="+Math.random();
	alert('before open' + sUrl);
	xmlHttpMail.open("GET",sUrl,true);
	xmlHttpMail.onreadystatechange=stateMail;
	//alert('Opened');
	xmlHttpMail.send(null);
	alert('Meddelande skickat till Digishop!');
}

function ajaxRequest(sUrl,sDiv,sValue,sDivOff,sDivOff2,sDivOff3)
{
	xmlHttp=GetXmlHttpObject();
	sArea = sDiv;
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	document.getElementById(sArea).style.display = 'block';
	if (document.getElementById(sDivOff) != null)
	{
	    document.getElementById(sDivOff).style.display = 'none';
	}
	if (document.getElementById(sDivOff2) != null)
	{
	    document.getElementById(sDivOff2).style.display = 'none';
	}
	if (document.getElementById(sDivOff3) != null)
	{
	    document.getElementById(sDivOff3).style.display = 'none';
	}
	
	sUrl= sUrl + sValue + "&sid="+Math.random();
	//alert('check');
	xmlHttp.onreadystatechange=stateChanged; 
	//alert('checkagain');
	xmlHttp.open("GET",sUrl,true);
	
	xmlHttp.send(null);
	
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	    populate(xmlHttp.responseText);
	} 
} 

//
function ajaxRequest2(sUrl,sDiv,sValue,sDivOff,sDivOff2,sDivOff3)
{
	xmlHttp2=GetXmlHttpObject();
	sArea2 = sDiv;
	//alert(sDiv);
	if (xmlHttp2==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	document.getElementById(sArea2).style.display = 'block';
	if (document.getElementById(sDivOff) != null)
	{
	    document.getElementById(sDivOff).style.display = 'none';
	}
	if (document.getElementById(sDivOff2) != null)
	{
	    document.getElementById(sDivOff2).style.display = 'none';
	}
	if (document.getElementById(sDivOff3) != null)
	{
	    document.getElementById(sDivOff3).style.display = 'none';
	}
	sUrl= sUrl + sValue + "&sid="+Math.random();
	
	xmlHttp2.onreadystatechange=stateChanged2; 
	
	xmlHttp2.open("GET",sUrl,true);
	
	xmlHttp2.send(null);
	
}

function stateChanged2() 
{ 
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
	{ 
	    populate2(xmlHttp2.responseText);
	} 
} 


function populate(response)
{
    var iStart;
    var iEnd;
    iStart = response.indexOf('<body>') + 6;
    iEnd = response.indexOf('</body>') - 1;
    document.getElementById(sArea).innerHTML= response.slice(iStart,iEnd);
}

function populate2(response)
{
    var iStart;
    var iEnd;
    iStart = response.indexOf('<body>') + 6;
    iEnd = response.indexOf('</body>') - 1;
    document.getElementById(sArea2).innerHTML= response.slice(iStart,iEnd);
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

//AJAX OBJECT
function AjaxObject(sUrl,sDiv,sValue,sDivOff)
{
    this.url = sUrl;
    this.div = sDiv;
    this.value = sValue;
    this.divoff = sDivOff;
    
    if (window.XMLHttpRequest)
	{
		this.objXML =new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		this.objXML =new ActiveXObject("Microsoft.XMLHTTP")
	}
}

function AjaxCreateInstance(sUrl,sDiv,sValue,sDivOff)
{
     var AjaxInstance = new AjaxObject(sUrl,sDiv,sValue,sDivOff);
}


//////////

function ajaxRequest3(sUrl,sDiv,sValue,sDivOff,sDivOff2,sDivOff3)
{
	xmlHttp3=GetXmlHttpObject();
	sArea3 = sDiv;
	//alert('ON' + sDiv);
	//alert('OFF' + sDivOff + sDivOff2 + sDivOff3) 
	if (xmlHttp3==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	document.getElementById(sArea3).style.display = 'block';
	if (document.getElementById(sDivOff) != null)
	{
	   
	    document.getElementById(sDivOff).style.display = 'none';
	}
	if (document.getElementById(sDivOff2) != null)
	{
	    document.getElementById(sDivOff2).style.display = 'none';
	}
	if (document.getElementById(sDivOff3) != null)
	{
	    document.getElementById(sDivOff3).style.display = 'none';
	}
	sUrl= sUrl + sValue + "&sid="+Math.random();
	
	xmlHttp3.onreadystatechange=stateChanged3; 
	
	xmlHttp3.open("GET",sUrl,true);
	
	xmlHttp3.send(null);
	
}

function stateChanged3() 
{ 
	if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")
	{ 
	    populate3(xmlHttp3.responseText);
	} 
} 



function populate3(response)
{
    var iStart;
    var iEnd;
    iStart = response.indexOf('<body>') + 6;
    iEnd = response.indexOf('</body>') - 1;
    document.getElementById(sArea3).innerHTML= response.slice(iStart,iEnd);
}

//////////

function ajaxRequest4(sUrl,sDiv,sValue,sDivOff,sDivOff2,sDivOff3,sDivOff4)
{
	xmlHttp4=GetXmlHttpObject();
	sArea4 = sDiv;
	
	if (xmlHttp4==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	if (document.getElementById(sArea4) != null)
	{
	    document.getElementById(sArea4).style.display = 'block';
	}
	if (document.getElementById(sDivOff) != null)
	{
	    document.getElementById(sDivOff).style.display = 'none';
	}
	if (document.getElementById(sDivOff2) != null)
	{
	    document.getElementById(sDivOff2).style.display = 'none';
	}
	if (document.getElementById(sDivOff3) != null)
	{
	    document.getElementById(sDivOff3).style.display = 'none';
	}
	if (document.getElementById(sDivOff4) != null)
	{
	    document.getElementById(sDivOff4).style.display = 'none';
	}
	sUrl= sUrl + sValue + "&sid="+Math.random();
	//alert(sUrl);
	xmlHttp4.onreadystatechange=stateChanged4; 
	
	xmlHttp4.open("GET",sUrl,true);
	
	xmlHttp4.send(null);
	
}

function stateChanged4() 
{ 
	if (xmlHttp4.readyState==4 || xmlHttp4.readyState=="complete")
	{ 
	    //alert(xmlHttp4.responseText);
	    populate4(xmlHttp4.responseText);
	} 
} 



function populate4(response)
{
    var iStart;
    var iEnd;
    iStart = response.indexOf('<body>') + 6;
    iEnd = response.indexOf('</body>') - 1;
    if (document.getElementById(sArea4) != null)
	{
        document.getElementById(sArea4).innerHTML = response.slice(iStart,iEnd);
        //document.getElementById('INFO').style.backgroundcolor='red';
        //alert(document.getElementById(sArea4).innerHTML);
        //alert(sArea4);
    }
    else
    {
        alert('no object:' + sArea4);
    }
}

//////////

function ajaxRequest5(sUrl,sDiv,sValue,sDivOff,sDivOff2,sDivOff3)
{
	xmlHttp5=GetXmlHttpObject();
	sArea5 = sDiv;
	//alert(sDiv);
	if (xmlHttp5==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	document.getElementById(sArea5).style.display = 'block';
	if (document.getElementById(sDivOff) != null)
	{
	    document.getElementById(sDivOff).style.display = 'none';
	}
	if (document.getElementById(sDivOff2) != null)
	{
	    document.getElementById(sDivOff2).style.display = 'none';
	}
	if (document.getElementById(sDivOff3) != null)
	{
	    document.getElementById(sDivOff3).style.display = 'none';
	}
	sUrl= sUrl + sValue + "&sid="+Math.random();
	
	xmlHttp5.onreadystatechange=stateChanged5; 
	
	xmlHttp5.open("GET",sUrl,true);
	
	xmlHttp5.send(null);
	
}

function stateChanged5() 
{ 
	if (xmlHttp5.readyState==4 || xmlHttp5.readyState=="complete")
	{ 
	    populate5(xmlHttp5.responseText);
	} 
} 



function populate5(response)
{
    var iStart;
    var iEnd;
    iStart = response.indexOf('<body>') + 6;
    iEnd = response.indexOf('</body>') - 1;
    document.getElementById(sArea5).innerHTML= response.slice(iStart,iEnd);
}






