﻿String.prototype.trim = function () {  return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");};


/*Show and Hide methods for the popup*/
var iframeEmptySrc = "/_layouts/iFrameEmpty.htm";
var g_PopupIFrame;
var g_OverlayIFrame;
var overlayObj;
var popupContainer;
var currentPopupId = "";

/* Popup by object: */
function ShowPopup(obj)
{
    ShowPopupWithId(obj.id);
}

/* Popup by ID: */
function ShowPopupWithId(id)
{
	var popupPrefix = 'popup_';
	var idI = id;
	var popupID = idI.replace('i_', popupPrefix);
	
	DisplayPopupById(popupID);
}

/* Popup For Accessories by ID: */
function ShowPopupAcc(id)
{
	var idString = id + '';
	
	var category = "Accessories/";
	if(idString.indexOf(0, "promopack") != -1)
	    category = "PromoPack/"
	
	var popupID = idString.replace('acc_', 'popup_');
	
    var popupObj = document.getElementById(popupID);
    
    var accName = popupObj.children[2].children[3].children[0].innerHTML.replace(/ /g, '');
    
	DisplayPopupById(popupID);
	
	//  Analytics code
	if (!popupContainer) popupContainer = document.getElementById('divPopupContainer');
	
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    popupContainer.innerHTML += unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E");
    try {
        var pageTracker = _gat._getTracker(document.getElementById('googleAnalyticsTrackID').innerHTML);
        pageTracker._setDomainName(".belcompany");
        pageTracker._setAllowLinker(true);
        pageTracker._setAllowAnchor(true);
        pageTracker._setAllowHash(true);
        pageTracker._trackPageview("");
        //pageTracker._trackPageview(category + accName);
        
        //        var GA_tracker_aggregated = _gat._getTracker("UA-6373197-7"); // New GA account for aggregated profile
        //        GA_tracker_aggregated._setDomainName(".telefoonkopen"); // de setDomainName wijzigt voor ieder domein
        //        GA_tracker_aggregated._setAllowHash(false);
        //        GA_tracker_aggregated._trackPageview(category + accName);
    } catch(err) {}
}

/* displays a popup: */
function DisplayPopupById(popupID)
{
	if (!popupContainer) popupContainer = document.getElementById('divPopupContainer');
		
	if (!overlayObj) overlayObj = document.getElementById('overlay2');

	// hide if any opened popup:
	HidePopup();
	
	// popup object:
	var popupObj = document.getElementById(popupID);
	if (!popupObj) return;
	
	var ie = document.all ? true : false;
	var pageScrollTop = (ie) ? document.documentElement.scrollTop : window.pageYOffset

	// fill popup HTML to the popup container:
	if (popupObj && popupContainer) 
	{
		popupContainer.innerHTML = popupObj.innerHTML;
		popupContainer.className = popupObj.className;
		currentPopupId = popupID;
		popupObj.innerHTML = "";
	}

	var pageSize = GetPageDimensions();
	
	overlayObj.style.width = pageSize[0] + "px";
	overlayObj.style.height = pageSize[1] + "px";

	var topPositionSum = 20 + pageScrollTop;
	var topPosition = topPositionSum + "px";

	// show the popup and the overlay:
	overlayObj.style.display = 'block';
	popupContainer.style.display = 'block';
	
	// set position of the popup:
	var popupLeft = '185px'; // default
	if (popupContainer.offsetWidth && popupContainer.offsetWidth > 0)
	{
		var tmpPopupLeft = (pageSize[0] - popupContainer.offsetWidth) / 2;
		popupLeft = tmpPopupLeft + "px";
	}
		
	popupContainer.style.left = popupLeft;
	popupContainer.style.top = topPosition;

	// fix for IE:
	if (ie)
	{
		var iFrameId = "iFrame_" + popupID;
		var existingIFrame = document.getElementById(iFrameId);
		var iFrame = existingIFrame ? existingIFrame : document.createElement("IFRAME");
		iFrame.setAttribute("id", iFrameId);
	//	iFrame.setAttribute("src", iframeEmptySrc);
		iFrame.setAttribute("frameborder", "0");

		//Match IFrame position with divPopup
		iFrame.style.position = "absolute";
		iFrame.style.left = popupContainer.offsetLeft;
		iFrame.style.top = popupContainer.offsetTop;
		iFrame.style.display = "block";
		iFrame.style.width = popupContainer.offsetWidth + "px";
		iFrame.style.height = popupContainer.offsetHeight + "px";
		iFrame.style.filter = "alpha(opacity=0)";
		
		// add the iframe object to the DOM:
		if (!existingIFrame) popupContainer.parentNode.appendChild(iFrame);

		// Increase default zIndex of div by 1, so that DIV appears before IFrame
		popupContainer.style.zIndex = popupContainer.style.zIndex + 1;
	
		// Store iFrame in global variable, so it can get removed when divPopup is hidden 
		g_PopupIFrame = iFrame;
		
		g_OverlayIFrame = GetIFrame("overlayFrame", "0", "0", 
			overlayObj.style.width, 
			overlayObj.style.height, 
			overlayObj.parentNode);
	}
}

/* creates an invisible IFrame used for IE6 and earlier to hide dropdowns for overlays: */
function GetIFrame(iFrameId, left, top, width, height, appendAsChildTo)
{
	var existingIFrame = document.getElementById(iFrameId);
	var ovFrame = existingIFrame ? existingIFrame : document.createElement("IFRAME");
	ovFrame.setAttribute("id", iFrameId);
//	ovFrame.setAttribute("src", iframeEmptySrc);
	ovFrame.setAttribute("frameborder", "0");

	//Match IFrame position with divPopup
	ovFrame.style.position = "absolute";
	ovFrame.style.left = left;
	ovFrame.style.top = top;
	ovFrame.style.display = "block";
	ovFrame.style.width = width;
	ovFrame.style.height = height;
	ovFrame.style.filter = "alpha(opacity=0)";
	
	// add the iframe object to the DOM:
	if (!existingIFrame) appendAsChildTo.appendChild(ovFrame);
	
	return ovFrame;
}

/* hides a popup: */
function HidePopup()
{
	if (overlayObj) overlayObj.style.display = 'none';
	else document.getElementById('overlay2').style.display = 'none';
	
	if (g_OverlayIFrame) g_OverlayIFrame.style.display = "none";

	if (popupContainer)
	{
		if (currentPopupId != "")
		{
			var popupOrig = document.getElementById(currentPopupId)
			if (popupOrig)
			{
				popupOrig.innerHTML = popupContainer.innerHTML;
				currentPopupId = "";
			}
		}
		popupContainer.innerHTML = "";
		popupContainer.style.display = "none";
		
	}
	
	if (document.all)
	{
		// hide the popup iframe:
		if (g_PopupIFrame) g_PopupIFrame.style.display = "none";
	}
}

/* hides an accessory popup: */
function HidePopupAcc()
{
	HidePopup();
}

/* returns page dimentions: */
function GetPageDimensions()
{
	var yScroll = 0;
	var xScroll = 0;

	// firefox:
  	if (window.innerHeight && window.scrollMaxY)
  	{	
		yScroll = window.innerHeight + window.scrollMaxY + 4;
		xScroll = window.innerWidth + window.scrollMaxX - 16;
	}
	else if (document.body.scrollHeight >= document.body.offsetHeight)
	{ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
		xScroll = document.body.scrollWidth;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		xScroll = document.documentElement.clientWidth;
		yScroll = document.documentElement.clientHeight + 51;
	}
	else
	{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight - 12;
		xScroll = document.body.offsetWidth - 4;
	}
	
	return [xScroll, yScroll];
}

/*End of Show and Hide methods for the popup*/


/* END Popups */

/* Closes all dropdowns to avoid the opened ones content to be shown over a tooltip div: */
function ClosePageDropDowns()
{
	var dropdownLists = document.getElementsByTagName("SELECT");
	for (i = 0; i < dropdownLists.length; i++)
	{
		dropdownLists[i].blur();
	}
}


/* Show & Hide tooltip */

var g_ToolTipIFrame;

/* Show toolip */
function ShowTooltip(prodId) 
{        
	var tooltipId = "tooltip_" + prodId;
	var tooltip = $get(tooltipId);
	if (tooltip === null) 
	{
		return;
	}
	
	// close all dropdowns to avoid the opened ones content to be shown over the tooltip:
	ClosePageDropDowns();
	
	tooltip.style.display = "block";
	var toolTipLeftClassName = "tooltipLeft";
	if (Sys.UI.DomElement.getBounds(tooltip.parentNode).x < tooltip.offsetWidth || tooltip.parentNode.className == "phonemain") {
		tooltip.childNodes[2].className = "tooltipBotL";
		if (tooltip.parentNode.className == "phone top5") {
			tooltip.style.left = "55px";
		}
		else if (tooltip.parentNode.className == "phone newest") {
			tooltip.style.left = "35px";
        }
        else if (tooltip.parentNode.className == "phonemain") {
            tooltip.style.left = "105px";
        }
		else {
			tooltip.style.left = "30px";
		}
	}
	else {
		tooltip.childNodes[2].className = "tooltipBot";
		tooltip.style.left = "";
	}

	// set parent DIVs zIndex - only the active should have "8", all others are "1"
	document.getElementById("phoneCell_" + prodId).style.zIndex = "8"

	
	// fix for IE:
	if (document.all)
	{
		var iFrameId = "iFrame_" + tooltipId;
		var existingIFrame = document.getElementById(iFrameId);
		var iFrame = existingIFrame ? existingIFrame : document.createElement("IFRAME");
		iFrame.setAttribute("id", iFrameId);
	//	iFrame.setAttribute("src", iframeEmptySrc);
		iFrame.setAttribute("frameborder", "0");

		//Match IFrame position with divPopup
		iFrame.style.position = "absolute";
		iFrame.style.left = tooltip.offsetLeft;
		iFrame.style.top = tooltip.offsetTop;
		iFrame.style.display = "block";
		iFrame.style.width = tooltip.offsetWidth + "px";
		iFrame.style.height = tooltip.offsetHeight + "px";
		iFrame.style.filter = "alpha(opacity=0)";
		
		// add the iframe object to the DOM:
		if (!existingIFrame) tooltip.parentNode.appendChild(iFrame);
		
		// Increase default zIndex of div by 1, so that tooltip appears before IFrame:
		if (tooltip.style.zIndex != "" && tooltip.style.zIndex != "undefined")
		{
			tooltip.style.zIndex = parseInt(tooltip.style.zIndex) + 1;
		}
		
		// Store iFrame in global variable, so it can get removed when divPopup is hidden 
		g_ToolTipIFrame = iFrame;
	}
}

/* Hide toolip */
function HideTooltip(prodId)
{
	var tooltipId = "tooltip_" + prodId;
	var tooltip = $get(tooltipId);
	if (tooltip === null) 
	{
		return;
	}
	tooltip.style.display = 'none';
	
	// for IE:
	if (document.all)
	{
		// hide the popup iframe:
		if (g_ToolTipIFrame) g_ToolTipIFrame.style.display = "none";
	}
	
	// reset parent DIVs zIndex - to be "1"
	document.getElementById("phoneCell_" + prodId).style.zIndex = "1";
}

/* end Show & Hide tooltip */

/* tab strip funcionality */
function openTab(element, ul, tablePrefix)
{
	var a = element;
	var div = element.parentNode;
	var li = div.parentNode;

	var tabStrip = document.getElementById(ul);
	var listItems = tabStrip.getElementsByTagName("LI");
	
	// set all classes to the "unselect" class
	for (i = 0; i< listItems.length; i++)
	{
		listItem  = listItems[i];
		
		listItem.className = "";
		
		if (i < listItems.length - 1){
			listItem.childNodes[0].className = "right";
		} else {
			listItem.childNodes[0].className = "";
		}
		
		// set the accompanying table diplay to none
		table = document.getElementById(tablePrefix + i);
		if (table) table.style.display = "none";
		
		if(listItem == element.parentNode.parentNode){
			tableSel = document.getElementById(tablePrefix + i);
			if (tableSel) tableSel.style.display = "block";
		}

		if(li == listItems[listItems.length - 1]){
			div.className = "selectL";
		} else {
			div.className = "selectR";
		}

	}

	// set the source element classes at the selected
	li.className = "select";
}

/* tab strip funcionality for contract details: */
function OpenTabContractDetails(elementId, tablePrefix)
{
    // put the classes to the following DIVs only:
    // divIn - "SelectR"
    // divOut - "SelectL"
    var element = document.getElementById(elementId);
	var divIn = element.parentNode;
	var divOut = divIn.parentNode;
	var li = divOut.parentNode;
	var tabStrip = li.parentNode;
	tabStrip.className = "";
	
	var listItems = tabStrip.getElementsByTagName("LI");
	
	// set all classes to the "unselect" class
	for (i = 0; i< listItems.length; i++)
	{
		var listItem  = listItems.item(i);
		
		listItem.className = "";
		
		if (i < listItems.length - 1)
		{
			listItem.childNodes.item(0).className = "right";
			listItem.childNodes.item(0).childNodes.item(0).className = "";
		} 
		else 
		{
			listItem.childNodes.item(0).className = "";
			listItem.childNodes.item(0).childNodes.item(0).className = "";
		}
		
		// set the accompanying table diplay to none
		table = document.getElementById(tablePrefix + i);
		if (!table) continue;
		
		if (table) table.style.display = "none";
		
		if (listItem == li)
		{
			tableSel = document.getElementById(tablePrefix + i);
			if (tableSel) tableSel.style.display = "";
		}

		if(li == listItems[listItems.length - 1])
		{
			divOut.className = "selectL";
			divIn.className = "";
			tabStrip.className = "rSel";
		} 
		else if (li == listItems[0])
		{
			divOut.className = "";
			divIn.className = "selectR";
		}
		else
		{
			divOut.className = "selectL";
			divIn.className = "selectR";
		}

	}

	// set the source element classes at the selected
	li.className = "select";
}

/* tab strip funcionality for product details: */
function OpenTabProductDetails(element, ul, tablePrefix)
{
	var a = element;
	var divIn = element.parentNode;
	var divOut = divIn.parentNode;
	var li = divOut.parentNode;
	
	// put the classes to the following DIVs only:
	// divIn - "SelectR"
	// divOut - "SelectL"

	var tabStrip = document.getElementById(ul);
	tabStrip.className = "";
	
	var listItems = tabStrip.getElementsByTagName("LI");
	
	// set all classes to the "unselect" class
	for (i = 0; i< listItems.length; i++)
	{
		var listItem  = listItems.item(i);
		
		listItem.className = "";
		
		if (i < listItems.length - 1)
		{
			listItem.childNodes.item(0).className = "right";
			listItem.childNodes.item(0).childNodes.item(0).className = "";
		} 
		else 
		{
			listItem.childNodes.item(0).className = "";
			listItem.childNodes.item(0).childNodes.item(0).className = "";
		}
		
		// set the accompanying table diplay to none
		table = document.getElementById(tablePrefix + i);
		if (!table) continue;
		
		if (table) table.style.display = "none";
		
		if (listItem == li)
		{
			tableSel = document.getElementById(tablePrefix + i);
			if (tableSel) tableSel.style.display = "";
		}

		if(li == listItems[listItems.length - 1])
		{
			divOut.className = "selectL";
			divIn.className = "";
			tabStrip.className = "rSel short";
		} 
		else if (li == listItems[0])
		{
			divOut.className = "";
			divIn.className = "selectR";
		}
		else
		{
			divOut.className = "selectL";
			divIn.className = "selectR";
		}

	}

	// set the source element classes at the selected
	li.className = "select";
}

/* stores opened tab name to a field to be "remembered" after a postback */
function SetTabOpened(tabName, saverControlId)
{
	var saverControl = document.getElementById(saverControlId);
	
	if (saverControl)
	{
		saverControl.value = tabName;
	}
}


/* /tab strip funcionality */

//function for custom validator in RegisterSoonAvailable
function ValidateEmailAndPhone(source, arguments) 
{
//    alert(source);
//    alert(source.id);
    var prefix = source.id.replace('valCustom', '');
    
    arguments.IsValid = false;
    var emailStr = prefix + "txtEmail";
    var phoneStr = prefix + "txtMobileNumber";
    var email = document.getElementById(emailStr).value;
    var phone = document.getElementById(phoneStr).value;

    if((email != null && email != '') || (phone != null && phone != ''))
    {
        arguments.IsValid = true;
    }
    else
    {
        arguments.IsValid = false;
        var msgStr = prefix + "regMessage";
        document.getElementById(msgStr).innerText = 'Ongeldige waarde';
    }
}

/* Method for the right "ShowSearchBox" web part 
that handles client click of the search button: */
function SearchBoxBtn_OnClientClick(textBoxId, resultsUrl, defaultText)
{
	var searchTerm = new String(document.getElementById(textBoxId).value);
	
	// trim the search term from leading and trailing spaces
	searchTerm = searchTerm.trim();
	searchTerm = (searchTerm == defaultText) ? '' : searchTerm;
	
	return (searchTerm != defaultText 
		&& searchTerm.toLowerCase() != "undefined" 
		&& searchTerm != "");
}


/* Method for the right "ShowSearchBox" web part 
that handles pressing the "enter" key in the textbox and fires the proper submit button */
function ShowSearchBoxBtn_OnKeyDown(source, evt, targetUrl)
{
	var keyPressed = window.event ? evt.keyCode : evt.which;

	if (keyPressed == 13) {
	    // WIWA #338: ga rechtstreeks naar de zoekpagina, ipv op zoek naar input buttons om vervolgens die te submitten.
	    var locationString = window.location.protocol + '//' + window.location.host + targetUrl + escape(source.value);
	    window.location.href = locationString;
	    evt.returnValue = false;
	    evt.cancel = true;
		return false;
	}
}

/* Method for the right "FindStore" web part 
that handles pressing the "enter" key and fires the proper submit button */
function FindStoreBtn_OnKeyDown(source, evt) {
    var keyPressed = window.event ? evt.keyCode : evt.which;

    if (keyPressed == 13) {
        if (window.event) evt.cancel = true;
        else {
            if (evt.cancelable) evt.preventDefault();
        }

        try {
            source.nextSibling.nextSibling.focus();
            eval(source.nextSibling.nextSibling.href.substring(11));
        }
        catch (ex) {
        }

        return false;
    }
}



/* Method for the right "RegisterNewsletter" web part 
that handles pressing the "enter" key and fires the proper submit button */
function RegisterNewsLetterBtn_OnKeyDown(source, evt)
{
	var keyPressed = window.event ? evt.keyCode : evt.which;

	if (keyPressed == 13) 
	{
		if (window.event) evt.cancel = true;
		else
		{
			if (evt.cancelable) evt.preventDefault();
		}

		try
		{
			source.nextSibling.childNodes.item(0).click();
		}
		catch(ex) 
		{
			try 
			{ 
				source.nextSibling.childNodes.item(0).focus(); 
			} 
			catch (ex2) {  }
		}

		return false;
	}
}

/*Method used in ShowProductList to call compare products*/
/*
    cbArray - array of ids of compare check boxes on the page
    compareUrl - url to which the redirection will be made without any query string parameters
    prodIdPrefix - the prefix for the check boxes server side id
*/
function CompareProducts(cbArray, compareUrl, prodIdPrefix)
{
    if (cbArray!=null && cbArray.length > 0) 
    {
        var maxNumberOfCompareProducts = 3;
        var minNumberOfCompareProducts = 2;      
        var redirectUrl = compareUrl;
        var checkedCount = 0;
        var seperator = '?';
        
        for (i=0; i<cbArray.length; i++)
        {
            var cb = document.getElementById(cbArray[i]);
            if (cb != null && cb.checked) 
            {     
                var indexPref = cbArray[i].indexOf(prodIdPrefix);
                if (indexPref == -1) 
                {
                    continue;
                } 
                //retreives product id from check box id
                var prodId = cbArray[i].substring(indexPref).replace(prodIdPrefix,''); 
                
                checkedCount++;
                if (checkedCount > maxNumberOfCompareProducts) 
                {
                    break;
                }
               
                redirectUrl = redirectUrl + seperator+"pid"+checkedCount+"="+prodId;
                
                seperator = '&';
            }
        }
        
        if (checkedCount >= minNumberOfCompareProducts) 
        {
            //redirect
            window.location = redirectUrl;
        }
        else 
        {
           // alert('Compare Products only works for '+minNumberOfCompareProducts+ ' to '+maxNumberOfCompareProducts+' products!');
        }   
    }
}


/* Opens the passed URL into a new browser window. */
function OpenNewWindow(url)
{
	window.open(url);
}



/* redirects to a given page with a selected bundle ID as URL parameter */
function SelectBundle(ddlObj, urlToGo)
{
	if (ddlObj.options[ddlObj.selectedIndex].value != "")
	{
	     window.location = urlToGo + "&bid=" + ddlObj.options[ddlObj.selectedIndex].value;
	}
	else
	{
		var strId = new String(ddlObj.id);
		var strToRemove = strId.match("\\w*BDDL_");
		window.location = urlToGo + "&bgid=" + strId.replace(strToRemove, "");
	}

}

/* redirects to a given page with a selected product ID as URL parameter */
function SelectProduct(ddlObj, urlToGo)
{
	if (ddlObj.options[ddlObj.selectedIndex].value != "")
	{
		window.location = urlToGo + ddlObj.options[ddlObj.selectedIndex].value;
	}
}

/* Shows or hides an element */
function ShowHideSection(sectId)
{
	var obj = document.getElementById(sectId);
	
	if (obj.style.display == "none")
	{
		obj.style.display = "block";
	}
	else
	{
		obj.style.display = "none";
	}
}

/* Navigation */
function startList() {
if (document.all && document.getElementById) {
navRoot = document.getElementsByTagName('UL')[1];
for (i=0; i<navRoot.childNodes.length; i++) {
  node = navRoot.childNodes[i];
  if (node.nodeName=="LI") {
            node.onmouseover=function() { 
                        this.className +=" sfhover"; 
            }
            node.onmouseout=function() {
                        var t = this;
        setTimeout(function() {
            t.className=t.className.replace(new RegExp(" sfhover\\b"), "");
        }, 10);
            }
   }
  }
 }
}
/* end Navigation */


/* Print methods: */

/* Prints the content of a normal site page: */
function PrintPage()
{
	var contentDiv = document.getElementById("divContent");
	// fix visibility of the main content DIV:
	if (contentDiv) contentDiv.style.display = "block";
	
	window.print();
}

/* Prints the content of a site popup: */
function PrintPopup(popupId)
{
//	var popupPrintContainer = document.getElementById("divPopupContainer");
//	var popup = document.getElementById(popupId);
//	if (popupPrintContainer && popup)
//	{
//		popupPrintContainer.innerHTML = popup.innerHTML;

		window.print();
//	}
}

/* END OF - Print methods */


/* Top navigation - set iframe (invisible - for IE 6) dimensions */
function SetNavIframeDimensions(iframeId)
{
	var iframe = document.getElementById(iframeId);
	
	if (!iframe) return;
	
	if (document.all)
	{
		iframe.style.height = iframe.parentNode.offsetHeight + "px";
		iframe.style.width = iframe.parentNode.offsetWidth + "px";
	}
	else
	{
		iframe.style.display = "none";
	}
}

// returns how many pixels is the page scrolled vertically:
function GetPageScrollTop()
{
	var ie = document.all ? true : false;
	return (ie) ? document.documentElement.scrollTop : window.pageYOffset
}

// Override of the MSOLayout_GetRealOffset method (from IE55up.js):
function MSOLayout_GetRealOffset(StartingObject, OffsetType, EndParent)
{
    var realValue = 0;
    if (!EndParent) EndParent = document.body;
    for (var currentObject = StartingObject; currentObject && currentObject != EndParent && currentObject != document.body; currentObject = currentObject.offsetParent)
    {
        var offset = eval('currentObject.offset' + OffsetType);
        if (offset) realValue += offset;
    }

    return realValue;
}

// Override of the MSOLayout_MoveDragObject method (from IE55up.js) - original does not calculate scrolled pixels correctly:
function MSOLayout_MoveDragObject()
{
	if(MSOLayout_currentDragMode !='move') return;
	if(MSOLayout_moveObject.style.display=='none') MSOLayout_moveObject.style.display='';
	if(MSOLayout_moveObject.style.width=='')
	{
		MSOLayout_moveObject.realWidth=MSOLayout_moveObject.offsetWidth;
		MSOLayout_moveObject.realHeight=MSOLayout_moveObject.offsetHeight;
	}
	var newWidth=MSOLayout_moveObject.realWidth;
	var newHeight=MSOLayout_moveObject.realHeight;
	var newLeft=event.clientX+document.body.scrollLeft - (newWidth / 2);
	var newTop=event.clientY+GetPageScrollTop()+1;
	if(newLeft+newWidth > document.body.scrollWidth) newWidth -=(newLeft+newWidth - document.body.scrollWidth);
	if(newTop+newHeight > document.body.scrollHeight) newHeight -=(newTop+newHeight - document.body.scrollHeight);
	if(newHeight <=0 || newWidth <=0)
	{
		MSOLayout_moveObject.style.display='none';
		newWidth=newHeight=0;
	}
	else MSOLayout_moveObject.style.display='';
	MSOLayout_moveObject.style.width=newWidth;
	MSOLayout_moveObject.style.height=newHeight;
	MSOLayout_moveObject.style.pixelLeft=newLeft;
	MSOLayout_moveObject.style.pixelTop=newTop;
}
