/*****************************************************************************
Copyright (C) 2008  Uður HAMZADAYI
******************************************************************************/
function UMenu_t2_s1_InitSub( menuid , verthorz , array , subid , iWidth , imagePath , subopenright ) {
  var maindiv = document.getElementById(menuid);
  var child_a = null;
  array.push( "" );
  backcolor = "#ffffff";
  overcolor = "#dbdbdb";
  textcolor = "#333333";
  overtextcolor = "#333333";
  bordercolor = "#dadada";
  
  var lIndex = (array.length-1);
  var subPanels = '<iframe id="'+subid+'_hideframe" style="filter:alpha(opacity=0);-moz-opacity:0;opacity:0; position:absolute;display:none;" frameBorder="0" scrolling="no"></iframe>';
  subPanels += '<table width="'+iWidth+'" id="'+subid+'" style="border:'+bordercolor+' 1px solid;BACKGROUND:'+backcolor+';display:none;position:absolute;" cellpadding="1" cellspacing="0" border="0">';
  thissubid = '';
  for(var i =0;i < maindiv.childNodes.length;i++){
      if( maindiv.childNodes[i].nodeName != 'DIV' && maindiv.childNodes[i].nodeName != 'A' ) 
         continue;
		 
      if( maindiv.childNodes[i].nodeName == 'DIV' ) {		 
	     UMenu_t2_s1_InitSub( maindiv.childNodes[i].id , verthorz , array , thissubid , iWidth , imagePath , subopenright );  
	  }
	  else {
         child_a = maindiv.childNodes[i];
		 thisid = subid + i; 
		 thissubid = subid + i + 'sub'; 
		 
		 bSubVarmi = false;
         for(var v =i+1 ;v < maindiv.childNodes.length;v++){
            if( maindiv.childNodes[v].nodeName != 'DIV' && maindiv.childNodes[v].nodeName != 'A' ) 
               continue;
			if( maindiv.childNodes[v].nodeName == 'A' )   
			   break;
			if( maindiv.childNodes[v].nodeName == 'DIV' ) {   
			   bSubVarmi = true;
			   break;
			}
		 }
		 
         subPanels += '<tr>';	  
           subPanels += '<td height="22" style="border-bottom:'+bordercolor+' 1px solid;cursor:pointer;color:'+textcolor+'" onclick="menu_onItemClick(\''+child_a.href+'\', \''+child_a.target+'\');" onmouseover="menu_onmouseoversub( \''+subid+'\' , \''+thisid+'\' , \''+thissubid+'\' , \''+overcolor+'\' , \''+subopenright+'\' , \''+overtextcolor+'\' );" onmouseout="menu_onmouseoutsub( \''+subid+'\' , \''+thisid+'\' , \''+thissubid+'\' ,  \''+backcolor+'\' , \''+textcolor+'\' );" width="100%" id="'+thisid+'">'; 	
		   if( child_a.className != "" ){
		     if( bSubVarmi )
  	            subPanels += '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;text-align:left;padding-left:5px;padding-right:12px;width:auto;WHITE-SPACE:nowrap;BACKGROUND:url('+imagePath+'arrowright.gif) no-repeat center right;"><img width="16" height="16" vspace="0" hspace="0" border="0" align="absmiddle" src="'+child_a.className+'">&nbsp;&nbsp;'+child_a.firstChild.nodeValue+'</div>';
		     else		
			    subPanels += '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;text-align:left;padding-left:5px;padding-right:12px;width:auto;WHITE-SPACE:nowrap;"><img width="16" height="16" vspace="0" hspace="0" border="0" align="absmiddle" src="'+child_a.className+'">&nbsp;&nbsp;'+child_a.firstChild.nodeValue+'</div>'; 
		   }else{
		     if( bSubVarmi )
  	            subPanels += '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;text-align:left;padding-left:5px;padding-right:12px;width:auto;WHITE-SPACE:nowrap;BACKGROUND:url('+imagePath+'arrowright.gif) no-repeat center right;"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'bullet.gif">&nbsp;&nbsp;'+child_a.firstChild.nodeValue+'</div>';
		     else		
			    subPanels += '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;text-align:left;padding-left:5px;padding-right:12px;width:auto;WHITE-SPACE:nowrap;"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'bullet.gif">&nbsp;&nbsp;'+child_a.firstChild.nodeValue+'</div>'; 
		   }
		   subPanels += '</td>'; 	
	     subPanels += '</tr>';	  
	  }
		 
  }
  subPanels += '</table>';
  if( lIndex >= 0 )
     array[lIndex] = subPanels ;
  
}


function UMenu_t2_s1_Init( language , menuid , verthorz , headerText , iWidthParent , iWitdhSub , imagePath , alignbar , bSerch , subopenright ) {
  var maindiv = document.getElementById(menuid);
  if( maindiv == null )
     return;
	 
  xspace = -1;
  yspace = -5;

  if( iWidthParent <= 0 )
     iWidthParent = '100%';

  var child_a = null;
  var newmenuid = menuid + '_parent';
  var subid = ''; 
  var arrayPanels = new Array();
  
  if(  verthorz == 'horz') {
	 alignbarwidth="0%";  
	 document.write( '<table width="100%" id="'+newmenuid+'" cellpadding="0" cellspacing="0" border="0"><tr>' );
	 document.write( '<td width="1"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'leftbar.png"></td>' );
	 if( alignbar == "center" )
	    alignbarwidth="50%";
	 if( alignbar == "right" )
	    alignbarwidth="100%";
		
	 
	 document.write( '<td width="'+alignbarwidth+'" style="BACKGROUND:url('+imagePath+'bar.png) repeat-x;"></td>' );	  
	 if( headerText != "" ) {
	    document.write( '<td style="padding-left:4px;padding-right:4px;padding-top:0px;FONT-FAMILY:tahoma,sans-serif,arial,helvetica;FONT-WEIGHT:normal;FONT-SIZE:12px;color:#BBFFFF;WHITE-SPACE:nowrap;BACKGROUND:url('+imagePath+'bar.png) repeat-x;">'+headerText+'</td>' );	  
		document.write( '<td width="1" ><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'seperator.png"></td>' );
	 }
	 
	 var bflag = false;
     for(var i =0;i < maindiv.childNodes.length;i++ ){
			  
           if( maindiv.childNodes[i].nodeName != 'DIV' && maindiv.childNodes[i].nodeName != 'A' ) 
              continue;
		 
		   if( maindiv.childNodes[i].nodeName == 'DIV' ) {
		  	  UMenu_t2_s1_InitSub( maindiv.childNodes[i].id , verthorz , arrayPanels , subid , iWitdhSub , imagePath , subopenright );  
		   }
		   else { //A ise
		      
  		      child_a = maindiv.childNodes[i];
			  thisid = menuid + i;
			  subid = menuid + i + 'sub';
			  
		      if( bflag ) {
  	 	         document.write( '<td width="1"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'seperator.png"></td>' );
		      }
			  
   		      document.write( '<td style="BACKGROUND:url('+imagePath+'bar.png) repeat-x;">' );	  
			  
              //normal  
		      document.write( '<table onclick="menu_onItemClick(\''+child_a.href+'\', \''+child_a.target+'\');" onmouseover="menu_onmouseover( \''+thisid+'\' , \''+subid+'\' , 0 ,'+xspace+' , '+yspace+' , \''+subopenright+'\' );" onmouseout="menu_onmouseout( \''+thisid+'\' );" id="'+thisid+'a" width="'+iWidthParent+'" cellpadding="0" cellspacing="0" border="0"><tr>' );
	          document.write( '<td width="1"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'leftpane.png"></td>' );
		         document.write( '<td style="width:100%;BACKGROUND:url('+imagePath+'pane.png) repeat-x;">' ); 	
				 if( child_a.className != "" )
				    document.write( '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;color:#000000;display:block;WHITE-SPACE:nowrap;text-align:center;padding-bottom:0px;width:100%;"><img width="24" height="24" align="absmiddle" src="'+child_a.className+'">&nbsp;&nbsp;'+child_a.firstChild.nodeValue+'</div>' ); 	 
				 else	
					document.write( '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;color:#000000;display:block;WHITE-SPACE:nowrap;text-align:center;padding-bottom:0px;width:100%;">'+child_a.firstChild.nodeValue+'</div>' ); 	
		         document.write( '</td>' ); 	
              document.write( '<td width="1"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'rightpane.png"></td>' );
		      document.write( '</tr></table>' );

			  //over
		      document.write( '<table onclick="menu_onItemClick(\''+child_a.href+'\', \''+child_a.target+'\');" style="cursor:pointer;display:none;" onmouseover="menu_onmouseover( \''+thisid+'\' , \''+subid+'\' , 0 ,'+xspace+' , '+yspace+',\''+subopenright+'\' );" onmouseout="menu_onmouseout( \''+thisid+'\' );" id="'+thisid+'b" width="'+iWidthParent+'" cellpadding="0" cellspacing="0" border="0"><tr>' );
	          document.write( '<td width="1" style="cursor:pointer;"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'leftpaneover.png"></td>' );
		         document.write( '<td style="cursor:pointer;width:100%;BACKGROUND:url('+imagePath+'paneover.png) repeat-x;">' ); 	
				 if( child_a.className != "" )
				    document.write( '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;color:#ffffff;display:block;WHITE-SPACE:nowrap;text-align:center;padding-bottom:0px;width:100%;"><img width="24" height="24" align="absmiddle" src="'+child_a.className+'">&nbsp;&nbsp;'+child_a.firstChild.nodeValue+'</div>' ); 	 
				 else	
					document.write( '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;color:#ffffff;display:block;WHITE-SPACE:nowrap;text-align:center;padding-bottom:0px;width:100%;">'+child_a.firstChild.nodeValue+'</div>' ); 	
		         document.write( '</td>' ); 	
              document.write( '<td width="1" style="cursor:pointer;"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'rightpaneover.png"></td>' );
		      document.write( '</tr></table>' );
			  
  		      document.write( '</td>' );
		      bflag = true;
		   
		  }
	  }
	  document.write( '<td width="100%" style="BACKGROUND:url('+imagePath+'bar.png) repeat-x;"></td>' );	  
	  if( bSerch ) {
	     document.write( '<td width="100%" style="BACKGROUND:url('+imagePath+'bar.png) repeat-x;" nowrap>' );
		 document.write( '<input onkeydown="if( event.keyCode == 13 ) menu_onSearchText( \''+language+'\' , \'menusearch_'+menuid+'\' );" type="text" id="menusearch_'+menuid+'" style="font-family:arial;font-size:12px;background-color:#EEEEEE;border:#CCCCCC 1px double;width:120px;"/>&nbsp;&nbsp;<img onclick="menu_onSearchText( \''+language+'\' , \'menusearch_'+menuid+'\' );" style="cursor:pointer;" vspace="0" hspace="0" align="absmiddle" src="'+imagePath+'search.png"></td>' );	  
	  }
      document.write( '<td width="1"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'rightbar.png"></td>' );
	  document.write( '</tr></table>' );
  }
  else { //vertical
  
	 if( headerText != "" ) {
	    document.write( '<table width="100%" cellpadding="0" cellspacing="0" border="0">' ); 
	    document.write( '<tr>'); 
		document.write( '<td width="1"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'vertheaderleftbar.png"></td>' );
	    document.write( '<td style="text-align:center;padding-left:4px;padding-right:4px;padding-bottom:0px;FONT-FAMILY: tahoma,arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:13px;color:#333333;WHITE-SPACE:nowrap;BACKGROUND:url('+imagePath+'vertheaderbar.png) repeat-x;">'+headerText+'</td>' );	  
		document.write( '<td width="1"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'vertheaderrightbar.png"></td>' );
		document.write( '</tr></table>' );
	 }
	 document.write( '<table width="100%" cellpadding="0" cellspacing="0" border="0">' ); 
     for(var i =0;i < maindiv.childNodes.length;i++ ){
           if( maindiv.childNodes[i].nodeName != 'DIV' && maindiv.childNodes[i].nodeName != 'A' ) 
              continue;
		 
		   if( maindiv.childNodes[i].nodeName == 'DIV' ) {
		  	  UMenu_t2_s1_InitSub( maindiv.childNodes[i].id , verthorz , arrayPanels , subid , iWitdhSub , imagePath , subopenright );  
		   }
		   else { //A ise
		      
  		      child_a = maindiv.childNodes[i];
			  thisid = menuid + i;
			  subid = menuid + i + 'sub';
			  
        	  bSubVarmi = false;
              for(var v =i+1 ;v < maindiv.childNodes.length;v++){
                 if( maindiv.childNodes[v].nodeName != 'DIV' && maindiv.childNodes[v].nodeName != 'A' ) 
                    continue;
			     if( maindiv.childNodes[v].nodeName == 'A' )   
			        break;
			     if( maindiv.childNodes[v].nodeName == 'DIV' ) {   
			        bSubVarmi = true;
			        break;
			     }
		      }
			  
			  
   		      document.write( '<tr><td>' );	  
			  
              //normal  
		      document.write( '<table style="padding: 0px;margin: 0px;" onclick="menu_onItemClick(\''+child_a.href+'\', \''+child_a.target+'\');" onmouseover="menu_onmouseover( \''+thisid+'\' , \''+subid+'\' , 1 ,'+xspace+','+yspace+',\''+subopenright+'\' );" onmouseout="menu_onmouseout( \''+thisid+'\' );" id="'+thisid+'a" width="100%" cellpadding="0" cellspacing="0" border="0"><tr>' );
	          document.write( '<td width="1" height="1"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'vertleftpane.png"></td>' );
	          document.write( '<td height="1" style="width:100%;BACKGROUND:url('+imagePath+'vertpane.png) repeat-x;">' ); 	
			  if( bSubVarmi ) {	 
				 if( child_a.className != "" )
  		            document.write( '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;color:#333333;display:block;WHITE-SPACE:nowrap;text-align:left;padding-right:12px;padding-bottom:0px;width:auto;BACKGROUND:url('+imagePath+'arrowright.gif) no-repeat center right;"><img align="absmiddle" src="'+child_a.className+'">&nbsp;&nbsp;'+child_a.firstChild.nodeValue+'</div>' ); 	
				 else
				    document.write( '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;color:#333333;display:block;WHITE-SPACE:nowrap;text-align:left;padding-right:12px;padding-bottom:0px;width:auto;BACKGROUND:url('+imagePath+'arrowright.gif) no-repeat center right;">'+child_a.firstChild.nodeValue+'</div>' ); 	
			  }
              else {
				 if( child_a.className != "" )
  		            document.write( '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;color:#333333;display:block;WHITE-SPACE:nowrap;text-align:left;padding-right:12px;padding-bottom:0px;width:auto;"><img align="absmiddle" src="'+child_a.className+'">&nbsp;&nbsp;'+child_a.firstChild.nodeValue+'</div>' );
				 else	
		 	  	    document.write( '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;color:#333333;display:block;WHITE-SPACE:nowrap;text-align:left;padding-right:12px;padding-bottom:0px;width:auto;">'+child_a.firstChild.nodeValue+'</div>' );
			  }
		      document.write( '</td>' ); 	
              document.write( '<td width="1" height="1"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'vertrightpane.png"></td>' );
		      document.write( '</tr></table>' );

			  //over
		      document.write( '<table onclick="menu_onItemClick(\''+child_a.href+'\', \''+child_a.target+'\');" style="cursor:pointer;display:none;" onmouseover="menu_onmouseover( \''+thisid+'\' , \''+subid+'\' , 1,'+xspace+','+yspace+' , \''+subopenright+'\' );" onmouseout="menu_onmouseout( \''+thisid+'\' );" id="'+thisid+'b" width="100%" cellpadding="0" cellspacing="0" border="0"><tr>' );
	          document.write( '<td width="1" style="cursor:pointer;"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'vertleftpaneover.png"></td>' );
		      document.write( '<td style="cursor:pointer;width:100%;BACKGROUND:url('+imagePath+'vertpaneover.png) repeat-x;">' ); 	
			  if( bSubVarmi ) {	 
				 if( child_a.className != "" )
  		            document.write( '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;color:#333333;display:block;WHITE-SPACE:nowrap;text-align:left;padding-right:12px;padding-bottom:0px;width:auto;BACKGROUND:url('+imagePath+'arrowright.gif) no-repeat center right;"><img align="absmiddle" src="'+child_a.className+'">&nbsp;&nbsp;'+child_a.firstChild.nodeValue+'</div>' ); 	
				 else
				    document.write( '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;color:#333333;display:block;WHITE-SPACE:nowrap;text-align:left;padding-right:12px;padding-bottom:0px;width:auto;BACKGROUND:url('+imagePath+'arrowright.gif) no-repeat center right;">'+child_a.firstChild.nodeValue+'</div>' ); 	
			  }
  		       //  document.write( '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;color:#ffffff;cursor:pointer;display:block;WHITE-SPACE:nowrap;text-align:left;padding-right:12px;padding-bottom:0px;width:auto; BACKGROUND:url('+imagePath+'arrowrightwhite.gif) no-repeat center right;">'+child_a.firstChild.nodeValue+'</div>' ); 	
              else {
				 if( child_a.className != "" )
  		            document.write( '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;color:#333333;display:block;WHITE-SPACE:nowrap;text-align:left;padding-right:12px;padding-bottom:0px;width:auto;"><img align="absmiddle" src="'+child_a.className+'">&nbsp;&nbsp;'+child_a.firstChild.nodeValue+'</div>' );
				 else	
		 	  	    document.write( '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;color:#333333;display:block;WHITE-SPACE:nowrap;text-align:left;padding-right:12px;padding-bottom:0px;width:auto;">'+child_a.firstChild.nodeValue+'</div>' );
				  
			     //document.write( '<div style="FONT-FAMILY: arial, helvetica, sans-serif;FONT-WEIGHT:bold;FONT-SIZE:11px;color:#ffffff;cursor:pointer;display:block;WHITE-SPACE:nowrap;text-align:left;padding-right:12px;padding-bottom:0px;width:auto;">'+child_a.firstChild.nodeValue+'</div>' ); 	 
			  }
				 
		      document.write( '</td>' ); 	
              document.write( '<td width="1" style="cursor:pointer;"><img vspace="0" hspace="0" align="absmiddle" border="0" src="'+imagePath+'vertrightpaneover.png"></td>' );
		      document.write( '</tr></table>' );
  		      document.write( '</td></tr>' );
		  }
	  }
	  document.write( '</table>' );
  }

  for(is=0;is<arrayPanels.length;is++) {
     document.write(arrayPanels[is]);  
  }

}
