function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeText(elementname, newtext)
{
    if(document.getElementById(elementname)!=null)
	document.getElementById(elementname).innerHTML = newtext;
}	
								
function changeImages()	{
	if (document.images	) {
		for	(var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src	= changeImages.arguments[i+1];
		}
	}
	
}
function ChangeImages(elementid, src)	{
if(document.getElementById(elementid)!=null)
    document.getElementById(elementid).src = src;
   // alert("hello");
	
}
function ChangeBG(elementid, src)	{
if(document.getElementById(elementid)!=null)
    document.getElementById(elementid).background = src;	
}
function changeLinks(elementid, href)
{
if(document.getElementById(elementid)!=null)
	document.getElementById(elementid).href = href;
}	

function popup(wndName, url, width, height) {
  var left=(window.screen.availWidth-width)/2 , top=(window.screen.availHeight-height)/2;
  var thewnd = window.open(url,'time_wnd','width=' + width + ',height=' + height + ',left='+ left +',top=' + top + ',resizable=no');
  thewnd.focus();
}
function popupOnCenter(url, width, height, winName) {
    if (!winName) winName = '';
    var left = (window.screen.availWidth - width) / 2, top = (window.screen.availHeight - height) / 2;
    var thewnd = window.open(url, winName, 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',resizable=no');
    thewnd.focus();
}

function display(id)
{  
    var control = document.getElementById(id);
    if(control != null)
    {
        control.style.display = "block";
    }
}
function hide(id)
{
    var control = document.getElementById(id);
    if(control != null)
    {
        control.style.display = "none";
    }
}

function changeGetPriceAndBuy(buyLinkId, url) {  
  var objBuyLink = MM_findObj(buyLinkId);
  if(objBuyLink) objBuyLink.href = url;
  
  var viframe = document.getElementById("StoreLocatorIframe");
  if (viframe) {
    var div1 = document.getElementById('StoreLocatorTab');	
    var div2 = document.getElementById('StoreLocatorPic');	
    var getPricesLinkRow = document.getElementById("GetPricesLinkRow");

 	if (objBuyLink.href.lastIndexOf("target_popup.html")>0) {
		div1.style.display='none'; 	
		div2.style.display='block';
		getPricesLinkRow.style.display = 'none';	
	}
	else {
		var str = getSKUfromHref(objBuyLink.href);
		viframe.src="StoreLocatorForm.aspx?sSKU="+str;				
		div1.style.display='block'; 	
		div2.style.display='none';
		getPricesLinkRow.style.display = 'block';
	}
  }	
}

function changeBuyLink(colorselect, buyLinkId) {  
  var objColorSelect = MM_findObj(colorselect);
  changeGetPriceAndBuy(buyLinkId, objColorSelect.options[objColorSelect.selectedIndex].value);
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
// hack for MNP: automatic length of left navigator
function autoNavigatorLength() {
    $("#mnpMenuTop").css({ "width": "180px", "border-right-width": "0" }).next().css({ "width": "180px", "border-right-width": "0" }).parent().css({ "border-right": "1px solid #999", "background-color": "#f1f1f1" });
    $("#msviFooter").prev().css({ "display": "none" });
}
