/*** 
This is the menu creation code - place it right after you body tag
Feel free to add this to a stand-alone js file and link it to your page.
**/

//Menu object creation
oCMenu=new makeCM("oCMenu") //Making the menu object. Argument: menuname

//Menu properties   
oCMenu.pxBetween=10
oCMenu.fromLeft=0
oCMenu.fromTop=57   
oCMenu.rows=1 
//var avail="0+((cmpage.x2-0)/2)";
//var avail="( cmpage.x2 - (cmpage.x2*0.18) - 140 )";
var avail="( cmpage.x2 - (cmpage.x2*0.18) - 550 )";
//oCMenu.menuPlacement=new Array(avail+"-80", avail, avail+"+80", avail+"+160")
oCMenu.menuPlacement="right"

                                                             
oCMenu.onlineRoot="" 
oCMenu.resizeCheck=1 
oCMenu.wait=200 

oCMenu.zIndex=0

//Background bar properties
oCMenu.useBar=0
oCMenu.barWidth="100%"
oCMenu.barHeight="menu" 
oCMenu.barClass="clBar"
oCMenu.barX=500 
oCMenu.barY=00
oCMenu.barBorderX=0
oCMenu.barBorderY=0
oCMenu.barBorderClass=""

//Level properties - ALL properties have to be specified in level 0
oCMenu.level[0]=new cm_makeLevel() //Add this for each new level
oCMenu.level[0].width=120
oCMenu.level[0].height=16 
oCMenu.level[0].regClass="clLevel0"
oCMenu.level[0].overClass="clLevel0over"
oCMenu.level[0].borderX=7
oCMenu.level[0].borderY=1
oCMenu.level[0].borderClass="clLevel0border"
oCMenu.level[0].offsetX=-1
oCMenu.level[0].offsetY=0
oCMenu.level[0].rows=0
oCMenu.level[0].arrow=0
oCMenu.level[0].arrowWidth=0
oCMenu.level[0].arrowHeight=0
oCMenu.level[0].align="bottom"


//EXAMPLE SUB LEVEL[1] PROPERTIES - You have to specify the properties you want different from LEVEL[0] - If you want all items to look the same just remove this
oCMenu.level[1]=new cm_makeLevel() //Add this for each new level (adding one to the number)
//oCMenu.level[1].width=oCMenu.level[0].width-2
oCMenu.level[1].width=130//104
oCMenu.level[1].height=25
oCMenu.level[1].regClass="clLevel1"
oCMenu.level[1].overClass="clLevel1over"
oCMenu.level[1].borderX=1
oCMenu.level[1].borderY=1
oCMenu.level[1].align="left" 
//oCMenu.level[1].offsetX=-(oCMenu.level[0].width-2)/2+20
oCMenu.level[1].offsetX=+1
oCMenu.level[1].offsetY=0
oCMenu.level[1].borderClass="clLevel1border"


//EXAMPLE SUB LEVEL[2] PROPERTIES - You have to spesify the properties you want different from LEVEL[1] OR LEVEL[0] - If you want all items to look the same just remove this
oCMenu.level[2]=new cm_makeLevel() //Add this for each new level (adding one to the number)
oCMenu.level[2].width=130
oCMenu.level[2].height=25
oCMenu.level[2].offsetX=1
oCMenu.level[2].offsetY=0
oCMenu.level[2].regClass="clLevel2"
oCMenu.level[2].align="right" 
oCMenu.level[2].overClass="clLevel2over"
oCMenu.level[2].borderClass="clLevel2border"


/******************************************
Menu item creation:
myCoolMenu.makeMenu(name, parent_name, text, link, target, width, height, regImage, overImage, regClass, overClass , align, rows, nolink, onclick, onmouseover, onmouseout) 
*************************************/
oCMenu.makeMenu('top0','','Products','/products','')

  oCMenu.makeMenu('sub00','top0','RapidSpell Desktop .NET','/products/rapidspell/dotNet')
  oCMenu.makeMenu('sub01','top0','RapidSpell Web .NET','/products/rapidspell/dotNetWeb')
  oCMenu.makeMenu('sub02','top0','Thesaurus Desktop .NET','/products/thesaurus/dotNet')
  oCMenu.makeMenu('sub021','top0','Thesaurus for ASP.NET','/products/thesaurus/dotNetWeb')
  oCMenu.makeMenu('sub022','top0','Search for ASP.NET','/products/search/dotNetWeb/index.html')
  oCMenu.makeMenu('sub03','top0','RapidSpell Desktop Java','/products/rapidspell')
  oCMenu.makeMenu('sub04','top0','RapidSpell Web Java','/products/rapidspell/javaWeb')
  oCMenu.makeMenu('sub05','top0','Dictionaries','')
	  oCMenu.makeMenu('s0501','sub05','.NET Dictionaries','/products/rapidspell/dotNet/dictionaries/index.html')
	  oCMenu.makeMenu('s0502','sub05','Java Dictionaries','/products/rapidspell/dictionaries/index.html')

/******************************************	  
	  oCMenu.makeMenu('s0501','sub05','.NET Medical','/products/rapidspell/dotNet/dictionaries/medical-en')
	  oCMenu.makeMenu('s0502','sub05','.NET Danish','/products/rapidspell/dotNet/dictionaries/danish-da')
	  oCMenu.makeMenu('s0503','sub05','.NET Dutch','/products/rapidspell/dotNet/dictionaries/dutch-nl')
	  oCMenu.makeMenu('s0504','sub05','.NET French','/products/rapidspell/dotNet/dictionaries/french-fr')
	  oCMenu.makeMenu('s0505','sub05','.NET German','/products/rapidspell/dotNet/dictionaries/german-de')
	  oCMenu.makeMenu('s0506','sub05','.NET Greek','/products/rapidspell/dotNet/dictionaries/greek-gr')
	  oCMenu.makeMenu('s0507','sub05','.NET Italian','/products/rapidspell/dotNet/dictionaries/italian-it')
	  oCMenu.makeMenu('s0508','sub05','.NET Norwegian','/products/rapidspell/dotNet/dictionaries/norwegian-no')
	  oCMenu.makeMenu('s0509','sub05','.NET Portuguese','/products/rapidspell/dotNet/dictionaries/Portuguese-pt')
	  oCMenu.makeMenu('s0510','sub05','.NET Port. BR','/products/rapidspell/dotNet/dictionaries/Portuguese-br')
	  oCMenu.makeMenu('s0511','sub05','.NET Spanish','/products/rapidspell/dotNet/dictionaries/spanish-es')
	  oCMenu.makeMenu('s0512','sub05','.NET Swiss German','/products/rapidspell/dotNet/dictionaries/swiss-ch')
	  oCMenu.makeMenu('s0513','sub05','Java Medical','/products/rapidspell/dictionaries/medical-en')
	  oCMenu.makeMenu('s0514','sub05','Java Danish','/products/rapidspell/dictionaries/danish-da')
	  oCMenu.makeMenu('s0515','sub05','Java Dutch','/products/rapidspell/dictionaries/dutch-nl')
	  oCMenu.makeMenu('s0516','sub05','Java French','/products/rapidspell/dictionaries/french-fr')
	  oCMenu.makeMenu('s0517','sub05','Java German','/products/rapidspell/dictionaries/german-de')
	  oCMenu.makeMenu('s0518','sub05','Java Greek','/products/rapidspell/dictionaries/greek-gr')
	  oCMenu.makeMenu('s0519','sub05','Java Italian','/products/rapidspell/dictionaries/italian-it')
	  oCMenu.makeMenu('s0520','sub05','Java Norwegian','/products/rapidspell/dictionaries/norwegian-no')
	  oCMenu.makeMenu('s0521','sub05','Java Portuguese','/products/rapidspell/dictionaries/Portuguese-pt')
	  oCMenu.makeMenu('s0522','sub05','Java Port. BR','/products/rapidspell/dictionaries/Portuguese-br')
	  oCMenu.makeMenu('s0523','sub05','Java Spanish','/products/rapidspell/dictionaries/spanish-es')
	  oCMenu.makeMenu('s0524','sub05','Java Swiss German','/products/rapidspell/dictionaries/swiss-ch')
*************************************/
  oCMenu.makeMenu('sub06','top0','StudioSpell','/products/studiospell')
  oCMenu.makeMenu('sub07','top0','Wish list','/wishlist.html')

oCMenu.makeMenu('top1','','Customer Care','/care')
	oCMenu.makeMenu('sub10','top1','Existing Customers','/care/existingcustomers.html')
	oCMenu.makeMenu('sub11','top1','Support','/care/support')
	oCMenu.makeMenu('sub12','top1','Support Forum','/support')
	oCMenu.makeMenu('sub13','top1','Knowledge Base','/kb')
	


oCMenu.makeMenu('top3','','Company','/index.html')
	oCMenu.makeMenu('sub30','top3','Home','/index.html')
	oCMenu.makeMenu('sub31','top3','About','/about.html')
	oCMenu.makeMenu('sub32','top3','Contact','/contact.html')
	oCMenu.makeMenu('sub33','top3','Resellers','/resellers.html')
	oCMenu.makeMenu('sub34','top3','Refunds Policy','/refund-policy.html')
	oCMenu.makeMenu('sub35','top3','Support Policy','/support-policy.html')
	oCMenu.makeMenu('sub36','top3','Privacy Policy','/privacypolicy.html')

	oCMenu.makeMenu('top4', '', '', 'javascript:showSearch(cm_lastMenuItemClicked);', '', 20, 16, '/searchicon.gif')

oCMenu.construct();

var searchIconDiv = document.getElementById('oCMenu_top4_0');
if(searchIconDiv!=null){
searchIconDiv.style.left = (searchIconDiv.style.left.substring(0, searchIconDiv.style.left.length-2)-20)+"px";
}


var searchVis = false;
       var km_scripts;
       
       function	importScripts(){
			if (typeof(km_scripts) == 'undefined')
				 km_scripts = new Object();
			
			importScript('/Keyoti_SearchEngine_Web_Common/Core.js');
			
			loadAutoComplete();
			
			importCSS("/Keyoti_SearchEngine_Web_Common/AutoComplete.css");
			importScript('/scriptsloaded.js');
			
		
		}

		function loadAutoComplete(){
			if(typeof(sew_coreJSLoaded)!='undefined' &&  sew_coreJSLoaded){
				importScript('/Keyoti_SearchEngine_Web_Common/AutoComplete.js');
			} else {
				setTimeout("loadAutoComplete()", 50);
			}
		}

		function importScript(jsFile) {
			if (km_scripts[jsFile] != null)	return;
			var	scriptElt =	document.createElement('script');
			scriptElt.type = 'text/javascript';
			scriptElt.src =	jsFile;
			document.getElementsByTagName('head')[0].appendChild(scriptElt);
			km_scripts[jsFile] = jsFile;
		}

		function importCSS(jsFile) {
			if (km_scripts[jsFile] != null)	return;
			var	scriptElt =	document.createElement('link');
			scriptElt.type = 'text/css';
			scriptElt.href =	jsFile;
			scriptElt.rel="STYLESHEET";
			document.getElementsByTagName('head')[0].appendChild(scriptElt);
			km_scripts[jsFile] = jsFile;
		}

	   
		var sew_configs = new Array();
		var sew_failSilent = true;
		sew_configs[sew_configs.length] = {sew_queryTextBoxID : "searchtb",
			sew_searchButtonID : "se_bt",
			sew_indexDirectory : "~/IndexDirectory", //path to index dir
			sew_numberOfSuggestions : "4",
			sew_runSearchOnSelect : true,
			sew_showNumberOfResults : false,
			sew_searchPostback: "document.getElementById('se_bt').click();",
			sew_appPath : "/Search2010/"
			};


       function showSearch(icon) {
       
			
       var searchBoxWidth = 240, searchBoxHeight=50;
           var img = document.getElementById("img" + cm_lastMenuItemClicked);
	         var div = document.getElementById("searchBox");
           var searchBoxWidth = 240, searchBoxHeight=50;
           
           if (div == null) {
               var divElement = document.createElement("div");
               document.getElementsByTagName('body')[0].appendChild(divElement);
               divElement.id = "searchBox";

               div = document.getElementById(divElement.id);
               div.innerHTML = "<span style='color:#006699;'>Search</span><form name='search' action='http://dev.keyoti.com/SearchResult.aspx' style='padding:0px;margin:0px;text-align:center'><input type='text' autocomplete='off' name='QueryExpr' size='20' style='font-size:12pt;margin-right:5px;' id='searchtb' /><button id='se_bt' type='submit'>Go</button></form>";

           }
           
           div.style.position = "absolute";
           div.style.padding = "5px";
           div.style.margin = "0px";
           div.style.border = "2px solid #006699";
           div.style.backgroundColor = "#CCD7EC";
           div.style.backgroundImage = "url(/search-grad.png)";
           div.style.backgroundRepeat = "repeat-y";
           
           div.style.width = searchBoxWidth + "px";
           div.style.height = searchBoxHeight + "px";
           div.style.left = (rsw_findPosX(img)-searchBoxWidth+10)+"px";
           div.style.top = (rsw_findPosY(img) + 19) + "px";
           searchVis= !searchVis;
           div.style.display = searchVis?"block":"none";
           //alert(rsw_findPosX(img) +" "+ rsw_findPosY(img));

          
           
           importScripts();
           
       }
       
       
       
       function initAC(){
			sew_menuShiftX = 2;
			sew_menuShiftY = 2;
			for(var i=0; i<sew_configs.length; i++){


			KSQ("#"+sew_configs[i].sew_queryTextBoxID).autocomplete(
			sew_configs[i].sew_appPath+"Keyoti.SearchEngine.Web.CallBackHandler.ashx",

			{
			delay:50,
			minChars:1,
			matchSubset:0,
			matchContains:1,
			cacheLength:1,
			formatItem:sew_formatItem,
			autoFill:false,
			onItemSelect:sew_item_selected,
				//##NOCRUNCH
			extraParams:{"cl":"SBAC", "id":sew_configs[i].sew_indexDirectory, "tl": sew_configs[i].sew_showNumberOfResults, "n":sew_configs[i].sew_numberOfSuggestions},
				//##ENDNOCRUNCH
			sew_searchButtonID:sew_configs[i].sew_searchButtonID,
			sew_runSearchOnSelect:sew_configs[i].sew_runSearchOnSelect,
			sew_searchPostback:sew_configs[i].sew_searchPostback
			}
			);
			sew_queryTB = KSQ("#"+sew_configs[i].sew_queryTextBoxID)[0];
			if(sew_queryTB!=null)sew_copyComputedStyle(KSQ.style('.sew_suggestion'), sew_queryTB);
			if(sew_queryTB!=null)sew_copyComputedStyle(KSQ.style('.sew_results'), sew_queryTB, "nocolor");
		}
		           
		                      try{
           if(searchVis) document.getElementById("searchtb").focus();
           }catch(e){}
       }
       
       

       function rsw_findPosX(obj) {
           var curleft = 0;

           if (typeof (obj.offsetParent) != 'undefined' && obj.offsetParent)//this if is probably not redundent because if also detects if member exists
           {
               while (obj.offsetParent) {
                   curleft += obj.offsetLeft;

                   obj = obj.offsetParent;
               }
               curleft += obj.offsetLeft;
           }
           else if (obj.x)
               curleft += obj.x;




           return curleft;

       }

       function rsw_findPosY(obj) {
           var curtop = 0;

           if (typeof (obj.offsetParent) != 'undefined' && obj.offsetParent) {
               while (obj.offsetParent) {
                   curtop += obj.offsetTop;
                   obj = obj.offsetParent;
               }
               curtop += obj.offsetTop;

           }
           else if (obj.y)
               curtop += obj.y;


           return curtop;

       }


