function createSilverlight()
{
	var scene = new ServerLaunch.Page();
	Silverlight.createObject(
        "Page.xaml",
        document.getElementById("silverlight_elem"),
        "SilverlightControl",
        {
            width: "1000",
            height: "800",
            inplaceInstallPrompt: true,
            background: "#eaf6ff",
            isWindowless: "true",
            framerate: "24",
            version: "1.0"
        },
        {
            onError: null,
            onLoad: Silverlight.createDelegate(scene, scene.handleLoad)
        },
        null,                              
        null
	);
}

if (!window.Silverlight) 
	window.Silverlight = {};

Silverlight.createDelegate = function(instance, method) {
	return function() {
		return method.apply(instance, arguments);
	}
}

function AreaResize(){
	var iWidth = (document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight )) ? document.documentElement.clientWidth : parseInt(document.body.offsetWidth);
	var iHeight = (document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight )) ? document.documentElement.clientHeight : parseInt(document.body.offsetHeight);
	
	var oSlArea = document.getElementById("silverlight_elem");
	var oSlPlugin = document.getElementById("SilverlightControl");
	
	if(!oSlPlugin)
		return;
	
	var oPage = oSlPlugin.content.findName("Page");
	var oLeftBodyBg = oPage.findName("left_body_bg");
	var oPageContainer = oPage.findName("page_container");
	
	//header elems
	var oHeader = oPage.findName("Header");
	var oDoneBy = oPage.findName("done_by");
	var oLogo = oPage.findName("logo");
	var oLaunchDate = oPage.findName("launch_date");
	var oLaunchNotice = oPage.findName("launch_notice");
	//content elems
	var oLaunchNotice = oPage.findName("launch_notice");
	var oSuggestion = oPage.findName("suggestion");
	var oLeftSugg = oPage.findName("left_suggestion");
	var oMiddleSugg = oPage.findName("middle_suggestion");
	var oMiddleSuggBunner = oPage.findName("middle_sugg_bunner");
	var oMiddleSuggText = oPage.findName("middle_sugg_text");
	var oRightSugg = oPage.findName("right_suggestion");
	var oRightSuggBunner = oPage.findName("right_sugg_bunner");
	var oRightSuggText = oPage.findName("right_sugg_text");
	var oMainContent = oPage.findName("main_content");
	var oLabs = oPage.findName("labs");
	var oImgLogo = oPage.findName("img_logo");
	var oAdditional = oPage.findName("additional");
	//footer elems
	var oFooter = oPage.findName("footer");
	var oFooterLogo = oPage.findName("ms_footer_logo");
	/**/	
	if(iWidth > 1000){
		if(iWidth < 1500){
			oSlArea.style.width = iWidth + "px";
			oSlPlugin.style.width = iWidth + "px";
			oPage.Width = iWidth;
			oLeftBodyBg.Width = iWidth;
			oPageContainer.Width = iWidth;
			oHeader.Width = iWidth;
			//oDoneBy["Canvas.Left"] = (iWidth - 188);
			oDoneBy["Canvas.Left"] = (iWidth - 164);
			oLaunchNotice.Width = iWidth - 575;
			oSuggestion.Width = iWidth - 295;
			iSuggWidth = (iWidth - 295) / 3;
			oLeftSugg.Width = iSuggWidth;
			oMiddleSugg.Width = iSuggWidth;
			oRightSugg.Width = iSuggWidth;
			oMiddleSugg["Canvas.Left"] = iSuggWidth;
			oMiddleSuggBunner["Canvas.Left"] = ((iSuggWidth - 209) / 2) - 15;
			oMiddleSuggText["Canvas.Left"] = ((iSuggWidth - 209) / 2) + 15;
			oRightSugg["Canvas.Left"] = iSuggWidth * 2;
			oRightSuggBunner["Canvas.Left"] = iSuggWidth - 239;
			oRightSuggText["Canvas.Left"] = iSuggWidth - 209;
			oMainContent.Width = iWidth - 295;
			//oLabs.Width = iWidth - 560;
			oLabs.Width = ((iWidth - 295) / 100) * 62;
			oAdditional["Canvas.Left"] = (iWidth - 530);
			oFooter.Width = iWidth - 60;
			oFooterLogo["Canvas.Left"] = iWidth - 163;
		}
		else{
			oSlArea.style.width = 1500 + "px";
			oSlPlugin.style.width = 1500 + "px";
			oPage.Width = 1500;
			oLeftBodyBg.Width = 1500;
			oPageContainer.Width = 1500;
			oHeader.Width = 1500;
			//oDoneBy["Canvas.Left"] = (1500 - 188);
			oDoneBy["Canvas.Left"] = (1500 - 164);
			oLaunchNotice.Width = 1500 - 575;
			oSuggestion.Width = 1500 - 295;
			iSuggWidth = (1500 - 295) / 3;
			oLeftSugg.Width = iSuggWidth;
			oMiddleSugg.Width = iSuggWidth;
			oRightSugg.Width = iSuggWidth;
			oMiddleSugg["Canvas.Left"] = iSuggWidth;
			oRightSugg["Canvas.Left"] = iSuggWidth * 2;
			oMainContent.Width = 1500 - 295;
			//oLabs.Width = 1500 - 560;
			oLabs.Width = (1500 - 295) / 100 * 62;
			oAdditional["Canvas.Left"] = (1500 - 530);
			oFooter.Width = 1500 - 60;
			oFooterLogo["Canvas.Left"] = 1500 - 163;
		}
	}
	else{
		oSlArea.style.width = 1000 + "px";
		oSlPlugin.style.width = 1000 + "px";
		oPage.Width = 1000;
		oLeftBodyBg.Width = 1000;
		oPageContainer.Width = 1000;
		oHeader.Width = 1000;
		//oDoneBy["Canvas.Left"] = (1000 - 188);
		oDoneBy["Canvas.Left"] = (1000 - 164);
		oLaunchNotice.Width = 1000 - 575;
		oSuggestion.Width = 1000 - 295;
		iSuggWidth = (1000 - 295) / 3;
		oLeftSugg.Width = iSuggWidth;
		oMiddleSugg.Width = iSuggWidth;
		oRightSugg.Width = iSuggWidth;
		oMiddleSugg["Canvas.Left"] = iSuggWidth;
		oRightSugg["Canvas.Left"] = iSuggWidth * 2;
		oMainContent.Width = 1000 - 295;
		//oLabs.Width = 1000 - 560;
		oLabs.Width = (1000 - 295) / 100 * 62;
		oAdditional["Canvas.Left"] = (1000 - 530);
		oFooter.Width = 1000 - 60;
		oFooterLogo["Canvas.Left"] = 1000 - 163;
	}
	
	// Построение высоты и ширины подгружаемого контента
	var oPageContent = (oPage.findName("PageContent")) ? oPage.findName("PageContent") : 0;
	var iContentHeight = 0;
	var iElemMargBottom = 0;
	var iPrevElemHeight = 0;
	var iPrevTop = 0;
	var sPrevElemStyle = "";
	if(oPageContent) {
		for(i = 0; i < oPageContent.Children.Count; i++) {
		//###################################################//
			j = i - 1;
			oPageContent.Width = oLabs.Width;
			oCurrItem = oPageContent.Children.GetItem(i);
			var sStyleType = (oCurrItem.Tag.indexOf(";")) ? oCurrItem.Tag.split(";")[0] : oCurrItem.Tag ;
			if(sStyleType != "blank"){
				var sUrl = (oCurrItem.Tag.indexOf(";")) ? oCurrItem.Tag.split(";")[1] : 0;
				var iBottomMarginPrev = iElemMargBottom;
				
				if(oCurrItem.toString() == "TextBlock" && sStyleType.toString() != "hiddenText" && sStyleType.toString() != "hiddenBlock"){
					oCurrItem.TextWrapping = "Wrap";
					oCurrItem.FontFamily = XAMLTextStyles[sStyleType]['fontFamily'];
					oCurrItem.FontSize = parseInt(XAMLTextStyles[sStyleType]['fontSize']);
					oCurrItem.FontWeight = XAMLTextStyles[sStyleType]['fontWeight'];
				}
				if(sStyleType.toString() != "img" && sStyleType.toString() != "hiddenText" && sStyleType.toString() != "hiddenBlock") {
					var iCurrElemWidth = Math.round(oPageContent.Width - 20 - parseInt(XAMLTextStyles[sStyleType]['marginLeft']) - parseInt(XAMLTextStyles[sStyleType]['marginRight']));
					oCurrItem.Width = iCurrElemWidth;
				}
				if(sUrl){
					if(oCurrItem.Cursor != "Hand"){
						oCurrItem.Cursor = "Hand";
						oCurrItem.AddEventListener("MouseLeftButtonDown", Link);
					}
				}
				if(sStyleType.toString() == "hiddenText" || sStyleType.toString() == "hiddenBlock"){
					oCurrItem.Opacity = parseInt(XAMLTextStyles[sStyleType]['opacity']);
					oCurrItem.Height = parseInt(XAMLTextStyles[sStyleType]['height']);
				}
				if(sStyleType.toString() == "pseudoLinkH4"){
					oCurrItem.Foreground = XAMLTextStyles[sStyleType]['color'];
					oCurrItem.TextDecorations  = XAMLTextStyles[sStyleType]['textDecorations'];
					oCurrItem.Cursor  = "Hand";
				}
				if(sStyleType.toString() == "paraWidthTopIndent"){
					oCurrItem.Opacity = "1.0";
				}
				if(sStyleType.toString() == "block"){
					oCurrItem.Opacity = "1.0";
					var iBlockHeight = 0;
					var iBlockElemMargBottom = 0;
					var iBlockContentHeight = 0;
					for(k = 0; k < oCurrItem.Children.Count; k++) {
						p = k - 1;
						oBlockElem = oCurrItem.Children.GetItem(k);
						oBlockElemStyle = oBlockElem.Tag;
						//alert(oBlockElemStyle);
						oBlockElem.Width = (oBlockElemStyle.toString() != "listBull") ? Math.round(oCurrItem.Width - parseInt(XAMLTextStyles[oBlockElemStyle]['marginLeft']) - parseInt(XAMLTextStyles[oBlockElemStyle]['marginRight'])) : 0;
						iBlockElemBottomMarginPrev = iBlockElemMargBottom;
						if(oBlockElem.toString() == "TextBlock" && oBlockElemStyle.toString() != "listBull"){
							oBlockElem.TextWrapping = "Wrap";
							oBlockElem.FontFamily = XAMLTextStyles[oBlockElemStyle]['fontFamily'];
							oBlockElem.FontSize = parseInt(XAMLTextStyles[oBlockElemStyle]['fontSize']);
							oBlockElem.FontWeight = XAMLTextStyles[oBlockElemStyle]['fontWeight'];
						}
						if(oBlockElemStyle.toString() == "listBull"){
							oBlockElem.FontWeight = "Bold";
						}
						oBlockElem["Canvas.Top"] = (oBlockElemStyle.toString() != "listBull") ? Math.round(iBlockContentHeight + parseInt(XAMLTextStyles[oBlockElemStyle]['marginTop']) + iBlockElemBottomMarginPrev) : (iBlockContentHeight + 5);
						oBlockElem["Canvas.Left"] = (oBlockElemStyle.toString() != "listBull") ? Math.round(XAMLTextStyles[oBlockElemStyle]['marginLeft']) : 5;
						if(oBlockElemStyle.toString() != "listBull"){
							iBlockElemHeight = (oBlockElem.toString() == "TextBlock") ? oBlockElem.ActualHeight : oBlockElem.Height;
						}
						else {
							iBlockElemHeight = 0;
						}
						
						iBlockContentHeight += (oBlockElemStyle.toString() != "listBull") ? (iBlockElemHeight + parseInt(XAMLTextStyles[oBlockElemStyle]['marginTop']) + parseInt(XAMLTextStyles[oBlockElemStyle]['marginBottom'])) : 0;
						iBlockElemMargBottom = (oBlockElemStyle.toString() != "listBull") ? XAMLTextStyles[oBlockElemStyle]['marginBottom']: 0;
						iPrevBlockElemHeight = iBlockElemHeight;
						iBlockHeight = 0;
					}
					oCurrItem.Height = iBlockContentHeight;
				}

				oCurrItem["Canvas.Top"] = (sStyleType.toString() != "hiddenText" && sStyleType.toString() != "hiddenBlock") ? Math.round(iContentHeight + parseInt(XAMLTextStyles[sStyleType]['marginTop']) + iBottomMarginPrev) : 0;
				oCurrItem["Canvas.Left"] = (sStyleType.toString() != "hiddenText" && sStyleType.toString() != "hiddenBlock") ? Math.round(XAMLTextStyles[sStyleType]['marginLeft']) : 0;

				if(sStyleType.toString() == "tdright"){ oCurrItem["Canvas.Top"] = iPrevTop; }

				iItemHeight = (oCurrItem.toString() == "TextBlock" && sStyleType.toString() != "hiddenText" && sStyleType.toString() != "hiddenBlock") ? oCurrItem.ActualHeight : oCurrItem.Height;
				iContentHeight += (sStyleType.toString() != "hiddenText") ? (iItemHeight + parseInt(XAMLTextStyles[sStyleType]['marginTop']) + parseInt(XAMLTextStyles[sStyleType]['marginBottom'])) : 0;
				if(sStyleType.toString() == "paraWithImg" || sStyleType.toString() == "paraWithImgLink"){
					if(sPrevElemStyle.toString() == "img"){
						if(iPrevElemHeight > iItemHeight) {
							iContentHeight -= iItemHeight;
						}
						else{
							iContentHeight -= iPrevElemHeight;
						}
					}
					//else{
					//	iContentHeight += iItemHeight;
					//}
					if(sPrevElemStyle.toString() == "paraWithImg"){
						oCurrItem["Canvas.Top"] = (iPrevTop + iPrevElemHeight + parseInt(XAMLTextStyles[sStyleType]['marginTop']));
					}
					else{
						oCurrItem["Canvas.Top"] = iPrevTop;
					}
				}
				iElemMargBottom = XAMLTextStyles[sStyleType]['marginBottom'];
				iPrevElemHeight = iItemHeight;
				iPrevTop = oCurrItem["Canvas.Top"];
				sPrevElemStyle = sStyleType;
			}
		//###################################################//
		}
		oPage.findName("PageContent").Height = (window.location.hash=="" || window.location.hash=="#p_1") ? (iContentHeight + 110) : iContentHeight;
		if(window.location.hash=="" || window.location.hash=="#p_1")
			oImgLogo["Canvas.Top"] = Math.round(iContentHeight + 40);
	}
	var bIndexPage = (window.location.hash=="" || window.location.hash=="#p_1") ? true : false ;
	var iDwnldHght = (oPage.findName("PageContent")) ? parseInt(oPage.findName("PageContent").Height) : 601;
	var iHgt = (bIndexPage) ? 300 : 600;
	var iSlAddHeight = (iDwnldHght > iHgt) ? iDwnldHght : iHgt ;
	var iSlHeight = (bIndexPage) ? (parseInt(37 + 150 + iSlAddHeight + 30 + 300)) : (parseInt(37 + 150 + iSlAddHeight + 30)) ;
	
	if(iSlHeight > iHeight){
		oSlArea.style.height = iSlHeight + "px";
		oSlPlugin.style.height = iSlHeight + "px";
		oPage.Height = iSlHeight;
		oLeftBodyBg.Height = iSlHeight;
		oPageContainer.Height = iSlHeight;
		oLabs.Height = iDwnldHght;
		oFooter["Canvas.Top"] = iSlHeight - 37;
	}
	else{
		oSlArea.style.height = iHeight + "px";
		oSlPlugin.style.height = iHeight + "px";
		oPage.Height = iHeight;
		oLeftBodyBg.Height = iHeight;
		oPageContainer.Height = iHeight;
		oLabs.Height = iDwnldHght;
		oFooter["Canvas.Top"] = (iHeight - 37);
	}
	
}

window.onresize = AreaResize;