
var sFavDomain = "http://www.shamrad.co.il/";
var sFavName = "Shamrad";
var current = "SMCategories.aspx?";

function Menu_OnClick(oTree)
{
	var oSNode = oTree.getTreeNode(oTree.selectedNodeIndex);
	var sMenuIndex = oTree.clickedNodeIndex;
	var oIndex = document.getElementById("SMMenu1_MenuSelectedIndex");
	oSNode = oTree.getTreeNode(sMenuIndex);
	if(oIndex != null){
		oIndex.value = sMenuIndex;
	}
	if(oSNode != null){
		SetServerAction("MenuIndex",sMenuIndex);
		var sCmd = oSNode.getAttribute("NodeData");
		//alert(sCmd)
		var sId = oSNode.getAttribute("ID");
		var sTxt = oSNode.getAttribute("Text");
		//if(sId.indexOf("MainNode")==0){
		if(sCmd.indexOf("Gotosub")>=0)
			eval(sCmd)
		else
		{
			sId = sId.replace("MainNode","");
			GotoMenu(sId);
			}
		/*}else{
			sId = sId.replace("TreeNode","");
			GotoCategory(sId);
		}*/
		
		var oCaption = document.getElementById("PageCaption");
		if(oCaption != null){
			oCaption.innerHTML = sTxt;			
		}
	}	
}

function GotoPage(sIndex)
{
	__doPostBack("LoadPage","");
}
function GotoMenu(sIndex,sArgs)
{
	var oFrm = document.getElementById("MainFrame");
	var sUrl = "";
	sIndex = "" + sIndex + ""
	switch(sIndex)
	{
		case "-12": sUrl = (current!="SMCategories.aspx?")?current+"Parent=1&Type=12":current+"area=-12&Parent=1&Type=12"; break;
		case "-13": sUrl = (current!="SMCategories.aspx?")?current+"Parent=1&Type=13":current+"area=-13&Parent=1&Type=13"; break;
		case "-14": sUrl = (current!="SMCategories.aspx?")?current+"Parent=1&Type=14":current+"area=-14&Parent=1&Type=14"; break;
		case "-15": sUrl = (current!="SMCategories.aspx?")?current+"Parent=1&Type=15":current+"area=-15&Parent=1&Type=15"; break;
		case "-16": sUrl = (current!="SMCategories.aspx?")?current+"Parent=1&Type=16":current+"area=-16&Parent=1&Type=16"; break;
		case "-7": sUrl = current; break;
		case "2": sUrl = "SMAbout.aspx?Parent=1&Type=1"; break;
		case "2.1": sUrl = "SMAbout.aspx?Parent=1&Type=3"; break;
		case "2.2": sUrl = "SMAbout.aspx?Parent=1&Type=18"; break;
		case "2.3": sUrl = "SMAbout.aspx?Parent=1&Type=9"; break;
		case "2.4": sUrl = "SMAbout.aspx?Parent=1&Type=4"; break;
		case "7": sUrl = "SMContacteng.aspx"; break;
		case "3.1": sUrl = "SMAbout.aspx?Parent=1&Type=7"; break;
		case "3" : sUrl = "SMAbout.aspx?Parent=1&Type=8"; break;
		case "5" : sUrl = "SMAbout.aspx?Parent=1&Type=10"; break;
		case "6": sUrl = "SMCust.aspx"; break;
		case "4": sUrl = "SMCategories.aspx"; break;
		case "8": sUrl = "SMNews.aspx"; break;
		case "9": sUrl = "SMProject.aspx"; break;
		case "10": sUrl = "SMProducts.aspx"; break;
	}
	//alert(sUrl)
	
	if(sArgs != null){
		sUrl = sUrl+"?"+sArgs;
	}
	if(oFrm == null){
		oFrm = parent.document.getElementById("MainFrame");
	}
	if(oFrm != null && sUrl != ""){
		oFrm.src = sUrl;
		SetServerAction("LoadPage",sUrl);
	}else{
		__doPostBack("LoadPage",sUrl);
	}
}
function GotoCategory(sIndex)
{
	current = "";
	var oFrm = document.getElementById("MainFrame");
	var sUrl = "";
	if(location.href.indexOf('Type=10')>0||location.href.indexOf('SMProject.aspx')>0)
	current = "SMProject.aspx?";
	else if(location.href.indexOf('Type=10')<0&&location.href.indexOf('Type=8')<0){
	switch(sIndex)
	{
		case 1: current = "SMCategories.aspx?area=-12&"; break;
		case 2: current = "SMCategories.aspx?area=-13&"; break;
		case 3: current = "SMCategories.aspx?area=-14&"; break;
		case 4: current = "SMCategories.aspx?area=-15&"; break;
		case 5: current = "SMCategories.aspx?area=-16&"; break;		
	}	
	}
	else if(location.href.indexOf('Type=8')>0)
	current = "SMProducts.aspx?";
	
	switch(sIndex)
	{
		case 1: sUrl = current+="area=-12&";GotoMenu('-12'); break;
		case 2: sUrl = current+="area=-13&";GotoMenu('-13'); break;
		case 3: sUrl = current+="area=-14&";GotoMenu('-14'); break;
		case 4: sUrl = current+="area=-15&";GotoMenu('-15'); break;
		case 5: sUrl = current+="area=-16&";GotoMenu('-16'); break;		
	}			
}

function Gotosub(Index,topic)
{

switch(topic)
{
case 3:
current = "SMProducts.aspx?";
if (Index<0)
{
current+="area="+Index+"&";
GotoMenu(Index);
}
else
{
current = "SMProducts.aspx?area="+Index +"&Parent=1&Type="+Index+"0";
GotoMenu('-7');
current = "SMProducts.aspx?";
}
break;
case 4:
if (Index>0)
{
	current = "SMCategories.aspx?area="+Index +"&Parent=1&Type="+Index+"0";
	GotoMenu('-7');
	current = "SMCategories.aspx?";
	}
else
{
current = "SMCategories.aspx?";
GotoMenu(Index);
}
	break;
	
case 5:
current = "SMProject.aspx?";
if (Index<0)
{
current+="area="+Index+"&";
GotoMenu(Index);
}
else
{
current = "SMProject.aspx?area="+Index +"&Parent=1&Type="+Index+"0";
GotoMenu('-7');
current = "SMProject.aspx?";
}
break;
}
}
	

function GotoLang(Index)
{
	switch(Index)
	{
	case 1:
	location.href='Default.aspx';
	break;
	case 2:
	location.href='English.aspx';
	break;
	}
}

function GotoProd(Id)
{
	GotoMenu('10','ID='+Id);
} 

function GotoProj(Id)
{
	GotoMenu('9','ID='+Id);
}
function GotoNews(Id)
{
	GotoMenu('8','ID='+Id);
}
function GotoNewsList(Id)
{
	GotoMenu('8','newsID='+Id);
}
function GotoCust(Id)
{
	GotoMenu('6','ID='+Id);
}

function search()
{
var sUrl = "SMSearch.aspx?txtSearch=" + document.forms[0].txtSearch.value;
var frm = document.getElementById("MainFrame");
if(frm == null){
		frm = parent.document.getElementById("MainFrame");
	}
	if(frm != null && sUrl != ""){
		frm.src = sUrl;
		SetServerAction("LoadPage",sUrl);
	}else{
		__doPostBack("LoadPage",sUrl);
	}
}

function SetServerAction(sAction,sActionArg)
{
	var oFrm = document.getElementById("ActionFrame");
	if(oFrm != null){
		if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
			oFrm = oFrm.Document.getElementById("Form1");
		}
		else {
			oFrm = oFrm.contentDocument.forms["Form1"];
		}
		
		if(oFrm != null){
			oFrm.__EVENTTARGET.value = sAction;
			oFrm.__EVENTARGUMENT.value = sActionArg;
			oFrm.submit();
		}
	}
}
function calcIframeHeight(iframeName)
{
	//find the height of the internal page
	var the_frm = document.getElementById(iframeName);
	if(the_frm != null)
	{
	the_frm.height= 1;
		var the_height=
			the_frm.contentWindow.document.body.scrollHeight;
	
		//change the height of the iframe
		if(the_height < 300)
			the_height = 350;
		the_frm.height = the_height+50;
		//alert(the_height);
	}	
}
function goToMenuIndex(Index,Action)
{
	//alert(Index);
	var sUrl = "";
	switch(Index)
	{
		case 0:
			if(window.location == parent.window.location){
				window.navigate("Default.aspx"); 
			}else{
				parent.window.navigate("Default.aspx");
			}
			break;
		case 1: sUrl = "?.aspx"; break;
	}
}

function DocumentWrite(sHtml)
{
	document.writeln(sHtml);
}

function WriteFlashObj(sSrc,sWidth,sHeight,bTrans,sBgColor)
{
	var sObj = "";
	var sWMode = "";
	var sObjID = sSrc.replace(".swf","");
	var oLang = document.getElementById('ItemLang');
	var sLang = "Lang=";
	if(oLang != null){
		sLang = sLang+oLang.value;
		if(sSrc.indexOf("?")>0)
			sLang = "&"+sLang;
		else
			sLang = "?"+sLang;
		sSrc = sSrc+sLang;
	}
	if(sBgColor == null) sBgColor = "#ffffff";
	sObj = sObj+"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+sWidth+"' height='"+sHeight+"' id='"+sObjID+"' align='middle' VIEWASTEXT>";
	sObj = sObj+"<param name='allowScriptAccess' value='sameDomain' />";
	sObj = sObj+"<param name='movie' value='"+sSrc+"' />";
	sObj = sObj+"<param name='quality' value='high' />";
	sObj = sObj+"<param name='bgcolor' value='"+sBgColor+"' />";
	if(bTrans == true){
		sObj = sObj+"<PARAM NAME='WMode' VALUE='Transparent'>";
		sWMode = "wmode='transparent'";
	}
	sObj = sObj+"<embed src='"+sSrc+"' quality='high' bgcolor='"+sBgColor+"' "+sWMode+" width='"+sWidth+"' height='"+sHeight+"' ID='"+sObjID+"' NAME='bg' align='middle' allowScriptAccess='sameDomain' swLiveConnect=true ID='bg' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	sObj = sObj+"</object>";
	
	DocumentWrite(sObj);
}
if(window.addEventListener)
	window.addEventListener("load", checkLoc, false);
else if(window.attachEvent)
	window.attachEvent("onload", checkLoc);
else
	window.onload=checkLoc;
function checkLoc()
{
	var lnks=document.links;
for(var i=0;i<lnks.length;i++)
{
	if( lnks[i].href.indexOf('http://www.')>-1 && window.location.href.indexOf('http://www.')<0)
		lnks[i].href=lnks[i].href.replace('http://www.','http://');
	else if( lnks[i].href.indexOf('http://')>-1&&lnks[i].href.indexOf('http://www.')<0 && window.location.href.indexOf('http://www.')>-1)
	{
		//alert(lnks[i].href)
	lnks[i].href=lnks[i].href.replace('http://','http://www.');
	}
}
if(parent.frames.length<1)
{
var str=location.pathname
if(str[str.length-1]=='/')str=str.substring(0,str.length-1);
str=str.substring(str.lastIndexOf('/')+1,str.length);
alert(("SMMaineng.aspx"+location.search+"&amp;page="+str));
if (location.search.indexOf("Type=28&lang=2")>=0)
location.replace("SMMaineng.aspx"+location.search+"&amp;page="+str)
else
location.replace("SMMain.aspx"+location.search+"&amp;page="+str)
}
}

