var xmlHttp = createXmlHttpRequestObject();
var urlpath="http://www.sneakersgalore.com/";

function createXmlHttpRequestObject()
	{
	var xmlHttp;
	
	try
			{
			xmlHttp = new XMLHttpRequest();
			}
	
	catch(e)
			{
			var XmlHttpVersions = new Array ('MSXML2.XMLHTTP.6.0',
											 'MSXML2.XMLHTTP.5.0',
											 'MSXML2.XMLHTTP.4.0',
											 'MSXML2.XMLHTTP.3.0',
											 'MSXML2.XMLHTTP',
											 'Microsoft.XMLHTTP');
			
				for(var i=0;i<XmlHttpVersions.length && !xmlHttp;i++)
					{
						try
							{
							xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
							}
					
				catch(e) {};	
					}
			}
		 
	 if(!xmlHttp)
	 	{
		alert("Error creating the XMLHTTPRequest object.");
		}
	  else
	   return xmlHttp;
	 }

function sC(url)
 	{
    	i = new Image();
	i.src = url;
  	}

function dC(url,delay)
	{
	uri=url
	setTimeout("sC(uri)",delay*1000);
	}
function randomToN(maxVal,floatVal)
	{
   	var randVal = Math.random()*maxVal;
    	return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
	}
    	
function jump(obj)
 	{ 
        if(obj.selectedIndex != 0)
        	{ 
        	window.location=obj.options[obj.selectedIndex].value;
        	}
    	} 

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function writeCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function ampCh(strng)
	{
	strng=strng.replace(/amp23/g, '&amp;');
	return strng;
	}
	
function html_entity_decode(str) 
	{
   	var ta = document.createElement("textarea");
 	ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
	toReturn = ta.value;
        ta = null;
        return toReturn
        }

function implodeAd(query)
	
	{
	var pureAd = query;
	 impAd= encodeURI(pureAd);
	 return impAd;
	}

function encodeUTF8(string) 
	{
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++)
        	{

		    var c = string.charCodeAt(n);

		    if (c < 128) 
			{
			utftext += String.fromCharCode(c);
			}
		    else if((c > 127) && (c < 2048)) 
			{
			utftext += String.fromCharCode((c >> 6) | 192);
			utftext += String.fromCharCode((c & 63) | 128);
			}
		    else 
			{
			utftext += String.fromCharCode((c >> 12) | 224);
			utftext += String.fromCharCode(((c >> 6) & 63) | 128);
			utftext += String.fromCharCode((c & 63) | 128);
			}

        	}

        return utftext;
        }

function checkIfInArray(string, arr,redirectUrl)
	{
	isEx=arr.indexOf(string);
	if(isEx==-1)
		{
		alert('Bitte wählen Sie eine gültige Marke aus dem Ausklappmenü aus.');	
		}
	else
		{
		getRedirection(string, redirectUrl)
		}
	}

function getFeaturePreview(id)
	{	
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
			{                       
        	        //query=query.replace(/&/g, 'amper23');    
                        //own=encodeURI(own);
			//alert(id);
			var param="id="+id;
			var doma=urlpath+"func/getFeaturePreview.php"
			xmlHttp.open("POST",doma, true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlHttp.onreadystatechange = insertFeaturePreview;
			xmlHttp.send(param);
			}
		else
			{
			setTimeout('getFeaturePreview(id)',100);
			}	
	}

function getRedirection(id, redirect)
	{	
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
			{                       
        	        //query=query.replace(/&/g, 'amper23');    
                        //own=encodeURI(own);
			id=id.replace(/&/g, 'amper23');
			var param="id="+encodeURI(id);				
			xmlHttp.open("POST",redirect, true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlHttp.onreadystatechange = redirectUrl;
			xmlHttp.send(param);
			}
		else
			{
			setTimeout('getRedirection(id, redirect)',100);
			}	
	}

function redirectUrl()
	{
	if(xmlHttp.readyState == 4)
		{
			if(xmlHttp.status == 200)
				{
				xmlResponse = xmlHttp.responseXML;
				xmlStatus=xmlResponse.getElementsByTagName("status");
				xmlKid=xmlResponse.getElementsByTagName("html");

				state = new Array;
					for (var loop = 0; loop < xmlStatus.length; loop++) 
						{
						xmlFirst=xmlStatus[loop];
						state[loop]=xmlFirst.firstChild.nodeValue;
						}
				kid = new Array;
					for (var loop = 0; loop < xmlKid.length; loop++) 
						{
						xmlFirst=xmlKid[loop];
						kid[loop]=xmlFirst.firstChild.nodeValue;
						} 		
				//document.getElementById("chart").innerHTML = '<img src="mod/ajax/'+mother[0]+'" />'; //
				if(state[0]==0)
					{
					alert('Bitte wählen Sie eine gültige Option aus');	
					}
                                if(state[0]==1)
					{
					//alert(kid[0]);
					window.location = kid[0];	
					}        
				}
			else
				{
				alert("Problem accessing Server: " + xmlHttp.statusText);
				}
		}
	}
	
function insertFeaturePreview()
	{
	if(xmlHttp.readyState == 4)
		{
			if(xmlHttp.status == 200)
				{
				xmlResponse = xmlHttp.responseXML;
				xmlStatus=xmlResponse.getElementsByTagName("status");
				xmlKid=xmlResponse.getElementsByTagName("html");

				state = new Array;
					for (var loop = 0; loop < xmlStatus.length; loop++) 
						{
						xmlFirst=xmlStatus[loop];
						state[loop]=xmlFirst.firstChild.nodeValue;
						}
				kid = new Array;
					for (var loop = 0; loop < xmlKid.length; loop++) 
						{
						xmlFirst=xmlKid[loop];
						kid[loop]=xmlFirst.firstChild.nodeValue;
						} 		
				//document.getElementById("chart").innerHTML = '<img src="mod/ajax/'+mother[0]+'" />'; //
				if(state[0]==0)
					{
					//alert('Bitte wählen Sie eine gültige Option aus');	
					}
                                if(state[0]==1)
					{
					//alert(kid[0]);
					$('examplePic').innerHTML = kid[0];	
					}        
				}
			else
				{
				alert("Problem accessing Server: " + xmlHttp.statusText);
				}
		}
	}

function roT(delay)
	{
	//alert(document.getElementById('rotLauncher').innerHTML);
	setTimeout('Effect.toggle(\'restOfText\',\'BLIND\', { duration: 0.7 });',delay);
	changeRotStatus();
	//setTimeout('alert(1);',delay);
	}
function changeRotStatus()
	{
	if($('rotLauncher').innerHTML!='einklappen')
		$('rotLauncher').innerHTML='einklappen';
	else
		$('rotLauncher').innerHTML='...restlichen Text lesen';
	}

function decodeUTF8(utftext) 
	{
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) 
        	{

		    c = utftext.charCodeAt(i);

		    if (c < 128) 
		    {
			string += String.fromCharCode(c);
			i++;
		    }
		    
		    else if((c > 191) && (c < 224)) 
		    {
			c2 = utftext.charCodeAt(i+1);
			string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
			i += 2;
		    }
		    
		    else 
		    {
			c2 = utftext.charCodeAt(i+1);
			c3 = utftext.charCodeAt(i+2);
			string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
			i += 3;
		    }

		}

        return string;
    	}    
//dropdowmenu ie    	
    	
function startList()
	{
	if (document.all&&document.getElementById)
			{
			navRoot = document.getElementById("nav");
				for (i=0; i<navRoot.childNodes.length; i++)
					{
					node = navRoot.childNodes[i];
						if (node.nodeName=="LI")
							{
							node.onmouseover=function()
								{
								this.className+=" over";
								}
							node.onmouseout=function()
								{
								this.className=this.className.replace(" over", "");
								}
							}
					}
			}
	}	
	

//brandmap dropdown menue	
function selVal()
	{
	gettingBrandsCategory($F('kategorien'));
    	}

function checkNlForm()

{error='';valid=1;if(document.getElementById('nlForename').value=='')

{error='Bitte geben Sie Ihren Vornamen an.<br />';valid=0;}

if(document.getElementById('nlName').value=='')

{error+='Bitte geben Sie Ihren Nachnamen an.<br />';valid=0;}

if(document.getElementById('nlMail').value=='')

{error+='Bitte geben Sie Ihren eMail-Adresse an.<br />';valid=0;}

else

{if(!isValidEmail(document.getElementById('nlMail').value))

{error+='Bitte geben Sie eine korrekte eMail-Adresse an.<br />';valid=0;}}

error+='<br />';if(valid==0)

{document.getElementById("nlError").innerHTML=error;}

if(valid==1)

{insertNlData();}}

function isValidEmail(str)

{return(str.indexOf(".")>2)&&(str.indexOf("@")>0);}

function switchVis(objectId)

{vis=document.getElementById(objectId).style.visibility;if(vis=='visible')

{document.getElementById(objectId).style.visibility='hidden';}

else

{document.getElementById(objectId).style.visibility='visible';}}


function insertNlData()

{vorname=document.getElementById('nlForename').value;nachname=document.getElementById('nlName').value;email=document.getElementById('nlMail').value;sex=$F('nlSex');document.getElementById('nlForm').innerHTML='<img src="imgz/ajax-loader.gif">...loading';par='v='+vorname+'&n='+nachname+'&e='+email+'&s='+sex;if(xmlHttp.readyState==4||xmlHttp.readyState==0)

{xmlHttp.open("POST","func/newsletterSuscription.php",true);xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlHttp.onreadystatechange=handleSuscriptionanswer;xmlHttp.send(par);}

else

{setTimeout('insertNlData()',100);}}

function handleSuscriptionanswer()

{if(xmlHttp.readyState==4)

{if(xmlHttp.status==200)

{xmlResponse=xmlHttp.responseXML;xmlStatus=xmlResponse.getElementsByTagName("status");xmlHtml=xmlResponse.getElementsByTagName("html");state=new Array;for(var loop=0;loop<xmlStatus.length;loop++)

{xmlFirst=xmlStatus[loop];state[loop]=xmlFirst.firstChild.nodeValue;}

html=new Array;for(var loop=0;loop<xmlHtml.length;loop++)

{xmlFirst=xmlHtml[loop];html[loop]=xmlFirst.firstChild.nodeValue;}

if(state[0]=='1')

{document.getElementById("nlForm").innerHTML=html[0];}}

else

{alert("Problem accessing Server: "+xmlHttp.statusText);}}}

function permRemove(id,action,cat)
	{	
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
			{                       
        	        //query=query.replace(/&/g, 'amper23');    
                        //own=encodeURI(own);

  			var pathurl=urlpath+'func/permanentRemove.php';
			var param="id="+id+"&a="+action+"&cat="+cat;
					
			xmlHttp.open("POST",pathurl, true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlHttp.onreadystatechange = alert('Item removed.');
			xmlHttp.send(param);
			}
		else
			{
			setTimeout('permRemove(action,id,cat)',100);
			}	
	}


function editorsChoice(id)
	{	
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
			{                       
        	        //query=query.replace(/&/g, 'amper23');    
                        //own=encodeURI(own);

  			var pathurl=urlpath+'admin/addPick.php';
			var param="id="+id;
					
			xmlHttp.open("POST",pathurl, true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlHttp.onreadystatechange = alert('Item '+id+' added.');
			xmlHttp.send(param);
			}
		else
			{
			setTimeout('editorsChoice(id)',100);
			}	
	}


