/*******************************************************************
***   Deklaration der benötigeten Variablen   		               ***
*******************************************************************/
	var arrCrossArrays	= new Array();		//Array für die CrossArtikel aus der JS zu der ausgewählten Farbe
	var blnCrossClicked = false;
	var _GET						= new Object();
	var _GET_VARS				= new Array();
	var intZaehler 			= 0;
	var intCompleted 		= 0;
	var CrossArticle 		= new Array();


/*******************************************************************
***    Prüfen, ob CrossClicked oder nicht                        ***
***    ----------------------------------                        ***
***    wenn ja, dann Parameter in Array/Object _GET speichern    ***
*******************************************************************/
	if(parent.location.search.substring(1).indexOf('MasterStyle') >= 0){
		arrTemp = parent.location.search.substring(1).split('&');
		for(intI in arrTemp){
			arrTemp2 = arrTemp[intI].split('=');
			_GET[arrTemp2[0]] = arrTemp2[1];
			try{
				_GET_VARS.push(arrTemp2[0]); 			
			}catch(e){_GET_VARS[_GET_VARS.length] = arrTemp2[0];}
		}
		blnCrossClicked = true;
	}
			

/*******************************************************************
***    Prüfen, ob CrossClicked oder nicht                        ***
*******************************************************************/
	SelectedColor	=(blnCrossClicked)	? _GET['SelectedColor'] : parent.ColorNumber;
	MasterStyle		=(blnCrossClicked)  ? _GET['MasterStyle'] 	: parent.StyleNumber;
	MasterID			=(blnCrossClicked)  ? _GET['MasterID'] 			: parent.ID;
	arrCrossArrays.length = 0;
			

/*******************************************************************
***    Wenn nicht CrossClicked               										 ***
***    -----------------------               										 ***
***    CrossJS laden                         										 ***
*******************************************************************/
	if(!blnCrossClicked) {
		blnCrossJSLoaded = false;
		document.write('<script src="../CrossJS/'+MasterStyle.toLowerCase()+'.html" type="text/javascript"><\/script>');
	}else{
		blnCrossJSLoaded = false;
		document.write('<script src="../CrossJS/'+MasterStyle.toLowerCase()+'.html" type="text/javascript"><\/script>');
	}
			
			


	function buildCrossStyleArray(intAktAufruf, intMaxAufruf, intCurrentPos, strShow){
		if(intMaxAufruf > intAktAufruf){

			if(blnCrossJSLoaded){

				if(arrCrossArrays.length < 1){
					for(intI = 1; intI<=6; intI++){
						try{
							if(typeof eval('Cross'+intI+'Arr_'+SelectedColor) == 'object' && eval('Cross'+intI+'Arr_'+SelectedColor)[1] != ''){
								arrCrossArrays[arrCrossArrays.length] = eval('Cross'+intI+'Arr_'+SelectedColor);
							}
						}catch(e){}
					}
				}
						
				if(arrCrossArrays.length > 0){
					for(intJ=intCurrentPos; intJ < arrCrossArrays.length; intJ++){
						strCurrentID = arrCrossArrays[intJ][1];
						
						for(intK = arrCrossArrays[intJ][1].length; intK < 8; intK++) strCurrentID = '0'+strCurrentID;
						arrCrossArrays[intJ][1] = strCurrentID;
						arrCrossArrays[intJ][4] = arrCrossArrays[intJ][4].toUpperCase();
						arrCrossArrays[intJ][5] = arrCrossArrays[intJ][5].toUpperCase();
						var objItem = document.createElement('script');
						
						try {
							objItem.setAttribute('src', '../HtmlJS/'+parent.strLng+'/'+strCurrentID+'.html');
							objItem.setAttribute('type', 'text/javascript');
							document.getElementsByTagName('head')[0].appendChild(objItem);
				  	}catch(e){}
					  
					  if(strCurrentID != '00000000'){
					  	setTimeout("\
								if(typeof blnHtmlJSOk != 'undefined' && blnHtmlJSOk == true){\
									if(arrCrossArrays[intJ].length != 10){\
										arrCrossArrays[intJ][arrCrossArrays[intJ].length] = StyleName;\
										arrCrossArrays[intJ][arrCrossArrays[intJ].length] = PriceNewArr[0][0];\
										arrCrossArrays[intJ][arrCrossArrays[intJ].length] = strCurrentID;\
										arrCrossArrays[intJ][arrCrossArrays[intJ].length] = '_'+ProductTemplate;\
										blnHtmlJSOk = false;\
										++intCompleted;\
									}\
								}", 150);
		  			}
						if(strCurrentID == '00000000'){
 							blnHtmlJSOk = false;
  						++intCompleted;
	  				}
						if(intCompleted == arrCrossArrays.length) {
							buildCrossStyleTable(arrCrossArrays, strShow);
							return;
						}
						setTimeout('buildCrossStyleArray('+(++intAktAufruf)+', 50, '+intCompleted+', "'+strShow+'")',150);
						break;
					}
				}
			} 
		}
	}

	function CrossStyle(Template, ID, StyleNumber, Color, StyleName, Price, FarbeVorhanden){
		this.Template 	 		 = Template;
		this.ID 				 		 = ID;
		this.Color 			 		 = Color;
		this.StyleNumber 		 = StyleNumber;
		this.StyleName 	 		 = StyleName;
		this.Price 			 		 = Price;
		this.FarbeVorhanden  = FarbeVorhanden;
	}


	function buildCrossStyleTable(arrCrossArray, strShow){

			for(intV = 0; intV < arrCrossArray.length; intV++){
						
			CrossArticle[intV] = new CrossStyle(arrCrossArray[intV][9], arrCrossArray[intV][8], arrCrossArray[intV][4], arrCrossArray[intV][5], arrCrossArray[intV][6], arrCrossArray[intV][7], ((arrCrossArray[intV][0]) == '-1' ? false : true));
		
		}

		strPictureLine = '';
		strTXTLine  = '';

		maxToCrossStyles = 3;
		if(maxToCrossStyles > (arrCrossArray.length)) maxToCrossStyles = (arrCrossArray.length);
		//if(maxToCrossStyles > (arrCrossArray.length - 1)) maxToCrossStyles = (arrCrossArray.length - 1);
		switch(strShow){
			
			// Klein horizontal
			case 'h_pd':
				strOut = '<center>\
										<table cellpadding="0" cellspacing="0" border="0">\
											<tr>\
						 		 ';
									 

    		for(intG=0; intG < maxToCrossStyles; intG++){
					if(CrossArticle[intG].FarbeVorhanden){
      			strPictureLine 	+= '<td align="left" valign="bottom"><a href="../HtmlProduct/'+parent.strLng+'/HtmlProduct'+CrossArticle[intG].Template+'.html?id='+CrossArticle[intG].ID+'&defcolor='+CrossArticle[intG].Color+'&language='+parent.strLng+((MasterID != CrossArticle[intG].ID) ? ('&MasterStyle='+MasterStyle+'&SelectedColor='+SelectedColor+'&MasterID='+MasterID) : '')+'&CSType=1" target="_parent"><img src="http://www.espritshop.com/Shop/PicDestStyleSuitingsSmall/'+CrossArticle[intG].StyleNumber+'_'+CrossArticle[intG].Color+'.gif" width="86" height="93" onmouseover="parent.vergroessern(\'http://www.espritshop.com/Shop/PicSrcCrossSellingFlat/'+CrossArticle[intG].StyleNumber+'_'+CrossArticle[intG].Color+'.jpg\', \''+CrossArticle[intG].StyleName+'\', \''+CrossArticle[intG].Price+'\')" onmouseout="parent.verkleinern()" /></a></td>';
      		}else{
      			try{
  	    			if(CrossArticle[(intG + 3)].FarbeVorhanden){
 	      				strPictureLine 	+= '<td align="left" valign="bottom"><a href="../HtmlProduct/'+parent.strLng+'/HtmlProduct'+CrossArticle[(intG + 3)].Template+'.html?id='+CrossArticle[(intG + 3)].ID+'&defcolor='+CrossArticle[(intG + 3)].Color+'&language='+parent.strLng+((MasterID != CrossArticle[(intG + 3)].ID) ? ('&MasterStyle='+MasterStyle+'&SelectedColor='+SelectedColor+'&MasterID='+MasterID) : '')+'&CSType=1" target="_parent"><img src="http://www.espritshop.com/Shop/PicDestStyleSuitingsSmall/'+CrossArticle[(intG + 3)].StyleNumber+'_'+CrossArticle[(intG + 3)].Color+'.gif" width="86" height="93" onmouseover="parent.vergroessern(\'http://www.espritshop.com/Shop/PicSrcCrossSellingFlat/'+CrossArticle[(intG + 3)].StyleNumber+'_'+CrossArticle[(intG + 3)].Color+'.jpg\', \''+CrossArticle[(intG + 3)].StyleName+'\', \''+CrossArticle[(intG + 3)].Price+'\')" onmouseout="parent.verkleinern()" /></a></td>';
        			}
       			}catch(e){}
      		}
    		}
				strOut += strPictureLine + '</tr>\
																	</table>\
																</center>';
				break;

			//horizontal BasketLayer
			case 'h_bl':
				strOut = '<center>\
										<table cellpadding="0" cellspacing="0" border="0">\
											<tr>\
						 		 ';
    		for(intG=0; intG < maxToCrossStyles; intG++){						 		 
					if(CrossArticle[intG].FarbeVorhanden){
        		strPictureLine 	+= '<td align="left"><a href="../HtmlProduct/'+parent.strLng+'/HtmlProduct'+CrossArticle[intG].Template+'.html?id='+CrossArticle[intG].ID+'&defcolor='+CrossArticle[intG].Color+'&language='+parent.strLng+((MasterID != CrossArticle[intG].ID) ? ('&MasterStyle='+MasterStyle+'&SelectedColor='+SelectedColor+'&MasterID='+MasterID) : '')+'&CSType=2" target="_parent"><img src="http://www.espritshop.com/Shop/PicSrcCrossSellingFlat/'+CrossArticle[intG].StyleNumber+'_'+CrossArticle[intG].Color+'.jpg" /></a></td>';
        		strTXTLine 			+= '<td style="color:#5F5F5F; background-color:#F3F0EC;" align="center">\
        													<table>\
        														<tr>\
        															<td valign="top"><img src="../Img/Product/'+parent.strLng+'/cross_iframe_pfeil.gif"></td>\
        															<td valign="top"><b><a href"#"><font color="#989A97">'+CrossArticle[intG].StyleName+'</font></a></b><br>\
        															<b><span style="font-size:10px;color:#989A97">$&nbsp;'+CrossArticle[intG].Price+'</span></b></td>\
        														</tr>\
        													</table>\
        												</td>\
        											 ';
        	}else{
     				try{
 	    				if(CrossArticle[(intG + 3)].FarbeVorhanden){
	        			strPictureLine 	+= '<td align="left"><a href="../HtmlProduct/'+parent.strLng+'/HtmlProduct'+CrossArticle[(intG + 3)].Template+'.html?id='+CrossArticle[(intG + 3)].ID+'&defcolor='+CrossArticle[(intG + 3)].Color+'&language='+parent.strLng+((MasterID != CrossArticle[(intG + 3)].ID) ? ('&MasterStyle='+MasterStyle+'&SelectedColor='+SelectedColor+'&MasterID='+MasterID) : '')+'&CSType=2" target="_parent"><img src="http://www.espritshop.com/Shop/PicSrcCrossSellingFlat/'+CrossArticle[(intG + 3)].StyleNumber+'_'+CrossArticle[(intG + 3)].Color+'.jpg" /></a></td>';
  	      			strTXTLine 			+= '<td style="color:#5F5F5F; background-color:#F3F0EC;" align="center">\
    	    														<table>\
      	  															<tr>\
        																	<td valign="top"><img src="../Img/Product/'+parent.strLng+'/cross_iframe_pfeil.gif"></td>\
        																	<td valign="top"><b><a href"#"><font color="#989A97">'+CrossArticle[(intG + 3)].StyleName+'</font></a></b><br>\
        																	<b><span style="font-size:10px;color:#989A97">$&nbsp;'+CrossArticle[(intG + 3)].Price+'</span></b></td>\
        																</tr>\
	    	    													</table>\
  	    	  												</td>\
    	    												 ';
        			}
	       		}catch(e){}
  	    	}
    		}
    	    											 
				strOut += strPictureLine;
				strOut += '  </tr><tr>';
				strOut += strTXTLine;
				strOut += '  </tr>\
									 </table></center>\
									';
				break;
			case 'v_pd':
				strOut = '<table cellpadding="0" cellspacing="0" border="0">';
				// bei Uhren nur 2 CS-Artikel anzeigen
				if(parent.ProductTemplate == '_Uhren') maxToCrossStyles = 2;
				
    		for(intG=0; intG < maxToCrossStyles; intG++){						 		 
					if(CrossArticle[intG].FarbeVorhanden){						 		 
					  strPictureLine 	+= '<tr><td align="center" width="150"><a href="../HtmlProduct/'+parent.strLng+'/HtmlProduct'+CrossArticle[intG].Template+'.html?id='+CrossArticle[intG].ID+'&defcolor='+CrossArticle[intG].Color+'&language='+parent.strLng+((MasterID != CrossArticle[intG].ID) ? ('&MasterStyle='+MasterStyle+'&SelectedColor='+SelectedColor+'&MasterID='+MasterID) : '')+'&CSType=1" target="_parent"><img src="http://www.espritshop.com/Shop/PicDestStyleSuitings/'+CrossArticle[intG].StyleNumber+'_'+CrossArticle[intG].Color+'.jpg" width="118" height="105" onmouseover="parent.vergroessern(\'http://www.espritshop.com/Shop/PicSrcCrossSellingFlat/'+CrossArticle[intG].StyleNumber+'_'+CrossArticle[intG].Color+'.jpg\', \''+CrossArticle[intG].StyleName+'\', \''+CrossArticle[intG].Price+'\')" onmouseout="parent.verkleinern()"/></a></td>';
    	    	if(CrossArticle[intG].Template != '_Bodywear' && parent.ProductTemplate != '_Bodywear')
      	  		strPictureLine 			+= '<tr><td style="color:#5F5F5F; background-color:#F3F0EC;" align="center">\
	      	  													<table width="150">\
  	      															<tr>\
    	    																<td valign="top"><b><a href"#"><font color="#989A97">'+CrossArticle[intG].StyleName+'</font></a></b><br>\
      	  																<b><span style="font-size:10px;color:#989A97">$&nbsp;'+CrossArticle[intG].Price+'</span></b></td>\
        																</tr>\
        															</table>\
        														</td>\
        													 ';
        	}else{
   					try{
							if(CrossArticle[(intG + 3)].FarbeVorhanden){						 		 
				  			strPictureLine 	+= '<tr><td align="center" width="150"><a href="../HtmlProduct/'+parent.strLng+'/HtmlProduct'+CrossArticle[(intG + 3)].Template+'.html?id='+CrossArticle[(intG + 3)].ID+'&defcolor='+CrossArticle[(intG + 3)].Color+'&language='+parent.strLng+((MasterID != CrossArticle[(intG + 3)].ID) ? ('&MasterStyle='+MasterStyle+'&SelectedColor='+SelectedColor+'&MasterID='+MasterID) : '')+'&CSType=1" target="_parent"><img src="http://www.espritshop.com/Shop/PicDestStyleSuitings/'+CrossArticle[(intG + 3)].StyleNumber+'_'+CrossArticle[(intG + 3)].Color+'.jpg" width="118" height="105" onmouseover="parent.vergroessern(\'http://www.espritshop.com/Shop/PicSrcCrossSellingFlat/'+CrossArticle[(intG + 3)].StyleNumber+'_'+CrossArticle[(intG + 3)].Color+'.jpg\', \''+CrossArticle[(intG + 3)].StyleName+'\', \''+CrossArticle[(intG + 3)].Price+'\')" onmouseout="parent.verkleinern()"/></a></td>';
	        			if(CrossArticle[(intG + 3)].Template != '_Bodywear' && parent.ProductTemplate != '_Bodywear')
  	      				strPictureLine 			+= '<tr><td style="color:#5F5F5F; background-color:#F3F0EC;" align="center">\
	  	      																<table width="150">\
  	  	    																	<tr>\
    	  	  																		<td valign="top"><b><a href"#"><font color="#989A97">'+CrossArticle[(intG + 3)].StyleName+'</font></a></b><br>\
      	  																			<b><span style="font-size:10px;color:#989A97">$&nbsp;'+CrossArticle[(intG + 3)].Price+'</span></b></td>\
        																			</tr>\
			        															</table>\
      			  														</td>\
        																 ';
        			}
        		}catch(e){}
					}
				}
				strOut += strPictureLine;
			  strOut += '  <tr>';
				strOut += strTXTLine;
			  strOut += '  </tr>\
									 </table>\
									';
				break;
		}
		document.getElementById('out').innerHTML = strOut;
	}	
