var lastMnObj;
var lastSnObj;

var http_request = false; // HTTP Request


         var b64s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
             b64 = [];f64 =[];
             for (var i=0; i<b64s.length ;i++) 
             {
                 b64[i] = b64s.charAt(i);
                 f64[b64s.charAt(i)] = i;
             }

//****************************************************************************************************************
// NAVIGATION SET MAIN
//****************************************************************************************************************
function navigation_set_main(MnObj,SnObj) 
	{
	if(lastMnObj && lastMnObj.className) 
		{
		lastMnObj.className = '';
		}
		MnObj.className = (MnObj.className != 'clicked') ? 'clicked' : '';
		lastMnObj = MnObj;
		
	if(lastSnObj && lastSnObj.style) 
		{
		lastSnObj.style.visibility = 'hidden';
		}		
		document.getElementById('ulNavigationLevel2'+SnObj).style.visibility = 'visible';
		lastSnObj = document.getElementById('ulNavigationLevel2'+SnObj);
	}

//****************************************************************************************************************
// NAVIGATION GET SUB
//****************************************************************************************************************

function navigation_get_sub(SnObj,sPage)
{
	loadContent(SnObj,sPage,'leftContentDiv');
}

//****************************************************************************************************************
// NAVIGATION GET TOP
//****************************************************************************************************************

function navigation_get_top(SnObj,sPage)
{
	loadContent(SnObj,sPage,'leftContentDiv');
}


//****************************************************************************************************************
// LOAD CONTENT
//****************************************************************************************************************

function loadContent(SnObj,sPage,sDiv)
{
	create_request("http://localhost:8080/conceptx_new/"+sPage+"?ID_TYP="+SnObj,sDiv);
}

function onLoadIndex(SnObj,sPage,sDiv)
{	
	loadContent(SnObj,sPage,sDiv);
}



//****************************************************************************************************************
// CREATE REQUEST
//****************************************************************************************************************

function create_request(url,sDiv) {

        http_request = false;

		try
		 {
		 // Firefox, Opera 8.0+, Safari
		 http_request=new XMLHttpRequest();
		 }
		catch (e)
		 {
		 // Internet Explorer
		 try
		  {
		  http_request=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		 catch (e)
		  {
		  http_request=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		 }

        if (!http_request) {
            alert('Fehler 01 : Bei dem Request ist ein Problem aufgetreten.');
            return false;
        }
        
        http_request.onreadystatechange = function() 
        			        {

					         if (http_request.readyState == 4) 
					         {
					            if (http_request.status == 200) {
					            	document.getElementById(sDiv).innerHTML = http_request.responseText;
					            } else {
					           	alert(http_request.responseText);
							    alert('Fehler 02 : Bei dem Request ist ein Problem aufgetreten.');
					            }
					         }

					    	}

		http_request.open('GET', url, true);
      	http_request.send(null);
    }
    
//****************************************************************************************************************
// OPEN CLOSE PRODUCT DETAILS
//****************************************************************************************************************

function open_close_product_details(DivIdClose,DivIdOpen)
{
	document.getElementById(DivIdClose).style.display='none';
	document.getElementById(DivIdOpen).style.display='block';
	
	var bgColor = '#CCCCFF';
		
	 if (!document.getElementById(DivIdOpen).parentNode.style.backgroundColor) 
		{
		document.getElementById(DivIdOpen).parentNode.style.backgroundColor = bgColor;
		} else {
		document.getElementById(DivIdOpen).parentNode.style.backgroundColor='';	
		} 
}

//****************************************************************************************************************
// CHANGE TO IMG
//****************************************************************************************************************

function change_to_Img(ImgDiv,ImgSrc, ImgWidth)
{
	
	NewImage = new Image();
	NewImage.src = ImgSrc;
	document.images[''+ImgDiv+''].width = ImgWidth;
	document.images[''+ImgDiv+''].src  = NewImage.src;
	
}

//****************************************************************************************************************
// PRINT DIV
//****************************************************************************************************************

function printDiv(sPage,WinName)
{
	var PrintWin  = window.open('',WinName,"location=0,status=0,scrollbars=0,width=450,height=600");
	PrintWin.document.writeln("<html><head><link rel='stylesheet' type='text/css' href='style/conceptxsports.css'></head><body><div id='printDiv' class='printClass'>")
		create_request(sPage+"?ID_TYP=0",'printClass');
		//PrintWin.document.getElementById('printDiv').innerHTML = 'agb.php';
	PrintWin.document.writeln("</div></body></html>");
	
	PrintWin.print();
}

//****************************************************************************************************************
// PRINT DIV
//****************************************************************************************************************

function sendContactMail()
{
surname = document.getElementsByName("surname")[0].value;
name = document.getElementsByName("name")[0].value;
from = document.getElementsByName("from")[0].value;
message = document.getElementsByName("message")[0].value;
bsent = document.getElementsByName("bsent")[0].value;
strUebergabe = 'contact.inc.php?surname='+surname+'&name='+name+'&from='+from+'&message='+message+'&bsent='+bsent
alert(strUebergabe);
strUebergabe = encode_base64(strUebergabe);
alert(strUebergabe);
//window.location.href='http://localhost:8080/conceptx_new/index.php?key='+strUebergabe+'|0';
// create_request('http://localhost:8080/conceptx_new/contact.inc.php?surname='+surname+'&name='+name+'&from='+from+'&message='+message+'&bsent='+bsent,'leftContentDiv')
}



       function encode_base64(d) {
             var r=[]; var i=0; var dl=d.length;
            // Padding vorbereiten
             if ((dl%3) == 1) {
                 d[d.length] = 0; d[d.length] = 0;}
             if ((dl%3) == 2)
                 d[d.length] = 0;
             // Konvertieren
             while (i<d.length)
                 {
                 r[r.length] = b64[d[i]>>2];
                 r[r.length] = b64[((d[i]&3)<<4) | (d[i+1]>>4)];
                 r[r.length] = b64[((d[i+1]&15)<<2) | (d[i+2]>>6)];
                 r[r.length] = b64[d[i+2]&63];
                 if ((i%57)==54)
                     r[r.length] = "\n";
                 i+=3;
                 }
             // padding abschlie�en
             if ((dl%3) == 1)
                 r[r.length-1] = r[r.length-2] = "=";
             if ((dl%3) == 2)
                 r[r.length-1] = "=";
             // Array in text zusammenf�hren
             var t=r.join("");
             return t;
             }

