

//			if (location.href.indexOf('?cn') != -1){old_alert('test')}

var BreadcrumbStep='';

function getCookie(c_name){
if (document.cookie.length>0){
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1){
	c_start=c_start + c_name.length+1;
	c_end=document.cookie.indexOf(";",c_start);
	if (c_end==-1) c_end=document.cookie.length;
	return unescape(document.cookie.substring(c_start,c_end));
  }}
  return "";
}

function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


    ChangeToggleFrom		= "Prisen er med moms - Vis uden moms";
    ChangeToggleTo			= "Prisen er uden moms - Vis med moms";
    
    
    function ToggleProdVat() {
        if (document.getElementById("ShopMainLayOutTable").innerHTML.indexOf('ToggleProdVat()') != -1){
            if (getCookie("ProdToggle") == ''){setCookie("ProdToggle",0,1);}
            SubStringIndikator = "custom=1&";
            window.location.href = location.href.substring(0,location.href.indexOf("?"+ SubStringIndikator)) +"?"+ SubStringIndikator +"togglevat=1&VariantIdSelected=0";
        }
    }

    function TipProdLink() {
        window.location.href = "/shop/tip.html?productid="+ ProductNumber +"&VariantIdSelected=0";
    }



// Denne funktion sørger for automatisk at tilpasse indholdet er en menu
function cn_init_menu(menu,level){
	// Hent indhold i menuen
	var list=menu.rows;
	var i=list.length; var j=i;

	// Gennemgå punkterne
	if(i>0)do{
		// Hent en reference til punktet
		var tmp=list[j-i].cells; tmp=tmp[tmp.length-1];

		// Tjek om det er en undermenu
		var x=tmp.getElementsByTagName('table')[0];
		if(x){
			cn_init_menu(x,level+1);
			continue;
		}

		// Tjek om det er et almindeligt punkt
		tmp=tmp.getElementsByTagName('a');
		var x=tmp[0];
		var y=tmp[1];
		
		if (tmp.length>2)
		{
			tilfoej = '';
			if (tmp[2].innerHTML.substring(0,3)=='<u>') tilfoej = 'specialniv'
			tmp[2].innerHTML='<div class="niv'+level+' '+tilfoej+'">'+tmp[2].innerHTML+'</div>';
		}
		if(y&&x&&y.parentNode==x.parentNode) 
		{
			if (tmp.length<3)
			{
				tilfoej = '';
				if (y.innerHTML.substring(0,3)=='<u>') tilfoej = 'specialniv'
				y.innerHTML='<div class="niv'+level+' '+tilfoej+'">'+y.innerHTML+'</div>';
			}
		}
		else if(x)
		{
			tilfoej = '';
			if (x.innerHTML.substring(0,3)=='<u>') tilfoej = 'specialniv'
			x.innerHTML='<div class="niv'+level+' '+tilfoej+'">'+x.innerHTML+'</div>';		
		}
	}while(--i);
}

domReady(function(){
	


/*
    PriceShipping  = $('#ShippingFee').eq(0).text().replace('DKK','').replace('.','').replace(',','.');
    PriceTotBasket = $('#TotalPriceSmallBasket').eq(0).text().replace('DKK','').replace('.','').replace(',','.');
    if (PriceShipping.length == 0){
        $('#TotalPriceSmallBasket, .ShippingTotPrice').text('0,00')
    }else{
        $('#TotalPriceSmallBasket, .ShippingTotPrice').text((parseFloat(PriceTotBasket)-parseFloat(PriceShipping)).toFixed(2).replace('.',','))
	}
*/
  
    
//    if (window.location.href.indexOf("?cn") != -1){
//    	old_alert(		)
//    }

    if (window.location.href.indexOf("shop/showbasket.html") != -1){

		// Insætter tal i kurv, hvis kurv er tom
	
		if ($('#ShippingFee').html()  != null){
			if	($('#ShippingFee').html() == ''){
					$('#TotalPriceSmallBasket').text('0,00')
					$('.Step1Table').after('<span class="TellMoreText">Du har ikke nogle varer i din kurv</span>');
					$('.Step1Table, .HideIfFalse').hide();
			}
		}


    	$('#Table13 tr').eq(0).remove();
    }




    if (window.location.href.indexOf("togglevat=1") != -1){if (getCookie("ProdToggle") == 0){setCookie("ProdToggle",0,1);}else{setCookie("ProdToggle",1,1);}}

    if (document.getElementById("ProdToggle") != null){

        if ((getCookie("ProdToggle") == 1 || getCookie("ProdToggle") == '')){
            document.getElementById("ProdToggle").innerHTML = ChangeToggleFrom;
        }else{
            document.getElementById("ProdToggle").innerHTML = ChangeToggleTo;
        }
    }






    if ($('#ShopMainLayOutTable .FrontPage_TD #Important .Message').text().length == 0){$('#ShopMainLayOutTable .FrontPage_TD #Important').remove();}
    
	//Loader productmenu
	cn_init_menu(document.getElementById('ProductMenu_Table'),1);

	//Fjerner stort mellemrun i menu
	$('.SubMenu_Productmenu_Table').parent().parent().remove();

	// Laver grå menupunkt i produktmenu
	$('.gray1').attr('class','').parent().parent().attr('class','gray1');
	
	//Sletter den sidste linie i vis kurv + laver nbsp i tomme felter
	_COuntProdLines = $('#ShopMainLayOutTable .ProdLine').length -1
	$('#ShopMainLayOutTable .ProdLine').eq(_COuntProdLines).css('border-bottom','none');
	

	// Lave en tilbageknap hvis den kommer fra popup
	if (location.href.indexOf('shop/showbasket.html#ref=popup') != -1){
    	$('.BasketBackBN').css('float','left');
    	$('.BasketBackBN').html('<img src="http://img.printerpatroner.dk/images/template/handle-videre-cart.png">');
    }
	

	if (location.href.indexOf('c1.html') != -1 || location.href.indexOf('c2.html') != -1 || location.href.indexOf('c3.html') != -1 || location.href.indexOf('p.html') != -1){

		// Indhold der flytter posison
		if ($('.SecondPart').html()  != null){
			if ($('#MoveTo').html()  == ''){
				$('#MoveTo').html($('.SecondPart').html())
				$('.SecondPart').remove();
			}
		}



























/*

				// Hvis rootcat er blækpatroner/toner/Kundeservice på disse sider: mellemsider, varelister
				if ($(RootCatagory).val()==2014481026 || $(RootCatagory).val()==2014481027 || $(RootCatagory).val()==2014482280 && $('#ProductList_TD').length!=0){
                    // Boks 1
                    CN_maerke_txt1 = $('#ShopMainLayOutTable #BREADCRUMB a').eq(1).text().replace('Blækpatroner til','').replace('Lasertoner til','');
                    CN_maerke_link = $('#ShopMainLayOutTable #BREADCRUMB a').eq(0).attr('href');
                    $('#maerke').html(CN_maerke_txt1 +'<br><a href="'+ CN_maerke_link +'" title="'+ CN_maerke_txt1 +'" class="change">Skift mærke</a>');

                    // Boks 2
                    CN_model_txt1 = $('#ShopMainLayOutTable #BREADCRUMB a').eq(2).text();
                    CN_model_link = $('#ShopMainLayOutTable #BREADCRUMB a').eq(1).attr('href');
                    $('#model').html(CN_model_txt1 +'<br><a href="'+ CN_model_link +'" title="'+ CN_model_txt1 +'" class="change">Skift mærke</a>');
                    
                    // Hvis blækpatroner er HP og Blækpatroner
                    if (CN_maerke_txt1.toLowerCase().indexOf('hp') != -1 && $(RootCatagory).val()==2014481026){

                        // Boks 2
                        CN_model_txt1 = $('#ShopMainLayOutTable #BREADCRUMB a').eq(3).text();
                        CN_model_link = $('#ShopMainLayOutTable #BREADCRUMB a').eq(1).attr('href');
                        $('#model').html(CN_model_txt1 +'<br><a href="'+ CN_model_link +'" title="'+ CN_model_txt1 +'" class="change">Skift mærke</a>');

                    }

                    // Hvis brugeren er på forsiden af blækpatroner eller toner
                    if (location.href.indexOf('3256s.html') != -1 || location.href.indexOf('3257s.html') != -1){
                        // Boks 1
                        CN_maerke_txt1 = $('#ShopMainLayOutTable #BREADCRUMB a').eq(0).text();
                        CN_maerke_link = 'http://printerpatroner.dk/';
						$('#ShopMainLayOutTable div.title').eq(0).text('');
                        $('#maerke').html(CN_maerke_txt1 +'<br><a href="'+ CN_maerke_link +'" title="'+ CN_maerke_txt1 +'" class="change">Til forside</a>');

                    }

                }

				// Hvis rootcat er Printere/Papir/Hjemmekontoret/Lamineringsmaskiner på disse sider: mellemsider, varelister
				if ($(RootCatagory).val()==2014481226 || $(RootCatagory).val()==122 || $(RootCatagory).val()==1369 || $(RootCatagory).val()==2014481072 && $('#ProductList_TD').length!=0){
                    // Boks 1
                    CN_maerke_txt1 = $('#ShopMainLayOutTable #BREADCRUMB a').eq(0).text().replace('Blækpatroner til','').replace('Lasertoner til','');
                    CN_maerke_link = 'http://printerpatroner.dk/';
					$('#ShopMainLayOutTable div.title').eq(0).text('');
                    $('#maerke').html(CN_maerke_txt1 +'<br><a href="'+ CN_maerke_link +'" title="'+ CN_maerke_txt1 +'" class="change">Til forside</a>');

                    // Boks 2
                    CN_model_txt1 = $('#ShopMainLayOutTable #BREADCRUMB a').eq(1).text();
                    CN_model_link = $('#ShopMainLayOutTable #BREADCRUMB a').eq(0).attr('href');
					$('#ShopMainLayOutTable div.title').eq(1).text('Valgt type');
                    $('#model').html(CN_model_txt1 +'<br><a href="'+ CN_model_link +'" title="'+ CN_model_txt1 +'" class="change">Skift type</a>');
				
				}


*/





































	
		// Laver ny listeform på patroner og toner - overskrift funktion
	
		if (jQuery.browser.version == '7.0'){$('.CmsPageStyleTest .TextInputField_Productlist').css('top','-1px')}
		
		var CountRelatedHeaders = 0;
		_HeadUnit = '';
		
		$('#ShopMainLayOutTable .CmsPageStyleTest .Product').each(function() {
														 
			$(this).find('.BuyButton_ProductList').attr('src','http://img.printerpatroner.dk/images/template/koeb.png')
			$(this).find('.Related_BuyButton_IMG').attr('src','http://img.printerpatroner.dk/images/template/koeb.png')
	
			_ThisUnit = $(this).find('.HeadUnit').text();
			
			if (_HeadUnit != _ThisUnit){
				if (_ThisUnit.indexOf('Kompatible') != -1){var _Erstat = 'Erstatter'}else{var _Erstat = 'Mærke'};
	
				_ThisTable = '<table class="ProductHeader" border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td><div class="ProductNumber">Varenr.</div><div class="ProductMaerke">'+ _Erstat +'</div><div class="ProductName">Beskrivelse</div><div class="ProductMaengde">Mængde</div><div class="ProductPricer">Pris</div><div class="ProductBuyS"></div></td></tr></table>';
			
				$(this).before('<div class="Header Header'+ _ThisUnit.substring(0,1) +'">'+ _ThisUnit +'</div>'+ _ThisTable);
				
			}
	
			_HeadUnit = _ThisUnit;
			
            if ($('#RootCatagory').eq(0).val() == 2014481026 || $('#RootCatagory').eq(0).val() == 2014481027){
            
                var _ProdName = $(this).find('.ProductName a').html().split(" - ")
                if (_ProdName.length == 3){
                    $(this).find('.ProductName a').html(_ProdName[0].replace('</SPAN>',''));
                    $(this).find('.ProductMaerke').text(_ProdName[1].replace('</SPAN>',''));
                    $(this).find('.ProductMaengde').text(_ProdName[2].replace('</SPAN>',''));
                }
            
            }else{

                var _ProdName = $(this).find('.ProductName a').text().split(" - ")
                if (_ProdName.length == 3){
                    $(this).find('.ProductName a').text(_ProdName[0]);
                    $(this).find('.ProductMaerke').text(_ProdName[1]);
                    $(this).find('.ProductMaengde').text(_ProdName[2]);
                }

            }
	
			$(this).show();

		})

		$('.CmsPageStyleTest .HeadUnit').hide();
	
		$('.CmsPageStyleTest .Product .ProductImage img').wrap('<span style="position:absolute;display:none;"><div style="position:relative"></div></span>');
		$('.CmsPageStyleTest .Product .ProductImage div img').css({'position':'absolute','left':'25px','bottom':'15px','border':'1px solid #C5C5C5'});
	
		$('.CmsPageStyleTest .Product .ProductImage').append('<img src="http://img.printerpatroner.dk/images/template/picture.png" class="ProductImageHover" style="margin-left:7px;margin-top:4px;">');
	
		$('.CmsPageStyleTest .ProductImageHover').hover(
			function(){
				$(this).parent().find('a span').show();
			},
			function(){
				$(this).parent().find('a span').hide();
			}		
		)

	///////////////////////////////////// BOXES med billeder
	///////////////////////////////////// BOXES med billeder
    
    
    
    
	if ($('#ShopMainLayOutTable .PictureBoxes').length >= 1){
	
		_HeadUnit = '';
		var _ThisParent = '';
		
		$('#ShopMainLayOutTable .ProductList_Custom_TBL').before('<div id="CustomProductList" class="active"></div>');
	
		$('#ShopMainLayOutTable .CmsPageStyleTest .Product .BuyButton_ProductList').attr('src','/images/template/koeb-small.png');
	
		$('#ShopMainLayOutTable .productboxes .Product').each(function() {
	
			_ThisUnit = $(this).find('.UnitPic').text();
			_ThisContent = $(this).parent().html();
			_ThisParent = '<FORM style="margin:0px;" METHOD="POST" ACTION="/shop/basket.asp" NAME="myform'+ $(this).find('.ProductNumberPic').text() +'" ONSUBMIT="return BuyProduct(this,\'1\',\'0\',\'False\');"><INPUT TYPE="hidden" NAME="VerticalScrollPos" VALUE=""><INPUT TYPE="hidden" NAME="BuyReturnUrl" VALUE="'+ location.href +'"><INPUT TYPE="hidden" NAME="Add" VALUE="1"><INPUT TYPE="hidden" NAME="ProductID" VALUE="'+ $(this).find('.ProductNumberPic').text() +'">'+ _ThisContent +'</form>';
	
			if (_HeadUnit == _ThisUnit){
				$('#CustomProductList').append(''+ _ThisParent +'');
			}
	
			if (_HeadUnit != _ThisUnit){
				$('#CustomProductList').append('<div class="Header" style="float:left;">'+ _ThisUnit +'</div>');
				$('#CustomProductList').append(''+ _ThisParent +'');
			}
			
			_HeadUnit = _ThisUnit;
			
		})







/*
        $('#ShopMainLayOutTable .Product input').click(function() {
        	if($(this).attr('class').indexOf('TextInputField_Productlist') == -1 && $.browser.msie!=true){
  
                $.post("/shop/basket.asp", { BuyReturnUrl: location.href, Add: "1", AMOUNT: "1", ProductID: $(this).parent().parent().parent().find('.ProductNumberPic td').text() }, 
               function(data) {});
  
  			};
        });
*/
/*

if (window.location.href.indexOf("?cn") != -1){


		$('#ShopMainLayOutTable .Product input').each(function() {
        	if($(this).attr('class').indexOf('TextInputField_Productlist') == -1){
//        		$(this).before('<a href="/shop/basket.asp?BuyReturnUrl='+ escape(location.href) +'&Add=1&AMOUNT=1&ProductID='+ $(this).parent().parent().parent().find('.ProductNumberPic td').text() +'"><img border="0" src="/images/template/koeb-small.png" class="BuyButton_ProductList" /></a>');
//        		$(this).before('<a href="'+ location.href +'&add=1&amount=1&productid='+ $(this).parent().parent().parent().find('.ProductNumberPic td').text() +'"><img border="0" src="/images/template/koeb-small.png" class="BuyButton_ProductList" /></a>');
//        		$(this).remove();
			}
        })

//		
   


}
*/











		$('#ShopMainLayOutTable .productboxes .ProductList_Custom_TBL').hide();
	
			//Special liste f.eks. printere
			$('#ShopMainLayOutTable .productboxes .Product').css('border','1px solid #FFFFFF');
		
			$('#ShopMainLayOutTable .productboxes .Product').hover(
				function(){
					$(this).css('border','1px solid #c5c5c5').css('cursor','hand')
				},
				function(){
					$(this).css('border','1px solid #FFFFFF')
				}
			)
			
			$("#ShopMainLayOutTable .productboxes .Product").click(function () { 
				location.href = $(this).find('a').eq(0).attr('href')
			});
	
	}
	
	///////////////////////////////////// BOXES med billeder
	///////////////////////////////////// BOXES med billeder

}




if (location.href.indexOf('s.html') != -1){
	
	
		//Omvendt måde og sotere simplelist i produktgruppe
		var _CountSubs = $('#ShopMainLayOutTable .SubCats_Prodlink').length;
				
		if (_CountSubs >= 1){
		
			var _1Cell = Math.ceil(_CountSubs/3);
			var _2Cell = Math.ceil((_CountSubs-_1Cell)/2);
			var _3Cell = Math.ceil(_CountSubs-(_1Cell+_2Cell));
		
			var i = 1;
			var iDIV = 1;
			var SavedText = '';
			var SavedValue = '';
		
			$('#ShopMainLayOutTable .SubCats_Prodlink').each(function() {
            	var ProdText1 = $(this).text()
                
                ProdText1 = ProdText1.replace('blækprintere','').replace('laserprintere','').replace('lasertonere','')
                
				SavedText = SavedText + '<a class="SubCats_Prodlink" href="'+ $(this).attr('href') +'">'+ ProdText1 +'</a>';

				//SavedText = SavedText + '<a class="SubCats_Prodlink" href="'+ $(this).attr('href') +'" OnClick="Alert(true,999,\'alertloading\',\'http://img.printerpatroner.dk/images/template/loading.png\',\'Siden hentes...\');setTimeout (\'CloseAlert();\', 2000);">'+ ProdText1 +'</a>';
				if ((i == _1Cell && iDIV==1) || (i == _2Cell && iDIV==2) || (i == _3Cell && iDIV==3)){SavedValue = SavedValue + '<td valign="top" class="Cell'+ iDIV +'">'+ SavedText +'</td>';SavedText = '';iDIV++;i=1;}else{i++}
			})
		
			$('#SIMPLELIST').html('<table border="0" cellpadding="0" cellspacing="0"><tr>'+ SavedValue +'</tr></table>')
	
		}
	
		var _CountSubs = $('#ShopMainLayOutTable #ExtraList a').length;
		
		if (_CountSubs >= 1){
		
			var _1Cell = Math.ceil(_CountSubs/3);
			var _2Cell = Math.ceil((_CountSubs-_1Cell)/2);
			var _3Cell = Math.ceil(_CountSubs-(_1Cell+_2Cell));
		
			var i = 1;
			var iDIV = 1;
			var SavedText = '';
			var SavedValue = '';
		
			$('#ShopMainLayOutTable #ExtraList a').each(function() {
				SavedText = SavedText + '<a class="SubCats_Prodlink" href="'+ $(this).attr('href') +'">'+ $(this).text() +'</a>';
				if ((i == _1Cell && iDIV==1) || (i == _2Cell && iDIV==2) || (i == _3Cell && iDIV==3)){SavedValue = SavedValue + '<td valign="top" class="Cell'+ iDIV +'">'+ SavedText +'</td>';SavedText = '';iDIV++;i=1;}else{i++}
			})
			
			$('#ExtraList').after('<table border="0" cellpadding="0" cellspacing="0" id="ExtraList"><tr>'+ SavedValue +'</tr></table>')
		
			$('#ExtraList').eq(0).remove();
	
		}
	
	
}













	if (location.href.indexOf('p.html') != -1){
		// Skjul variantstreg hvis ingen variant er der
        if (avNumVariants == 0){
            $('.VariantsLine').css('display', 'none');
        }
	}
	
	



try{

	var baskettd = document.getElementById('SmallCart');
	
	var baskethtml = baskettd .innerHTML;
	
	if(baskethtml.indexOf('0&nbsp;vare')==-1){
	
		baskettd.style.background='#2aabea';
        SmallCartNumber.style.color='#FFFFFF';    
        TotalPriceSmallBasket.style.color='#FFFFFF';
        white1.style.color='#FFFFFF';
        white2.style.color='#FFFFFF';
        white3.style.color='#FFFFFF';
       
   
	
	}

}

catch(e){}


});


////////////////////////////////////////////////////////

$(document).ready(function() {







if (location.href.indexOf('/shop/order1.html') != -1){
	lTypeContent = function() {
		setCookie('fak_type',$('select[name="CustTypeID"]').val(),365);
		setCookie('lev_type',$('select[name="lCustTypeID"]').val(),365);
		setCookie('lev_check',$('#Orderstep1_AlternativeDelivery_Enabled_CHECKBOX').attr('checked'),365);
	} 
	lTypeContentTimer = setInterval('lTypeContent()', 100);
}
	
if (location.href.indexOf('/shop/order2.html') != -1){


/*

if (location.href.indexOf('cn') != -1){
	old_alert('('+ getCookie('fak_type') +')('+ getCookie('lev_type') +')('+ getCookie('lev_check') +')');
}	

	$("#ShippingMethodID60").attr('checked', false)

	if ((getCookie('fak_type')=='1' && getCookie('lev_type')=='0' && getCookie('lev_check')=='true') || getCookie('fak_type')=='0' && getCookie('lev_check')=='false'){
		$('#ShippingMethod_60, #ShippingMethod_57').hide();
    }else if((getCookie('fak_type')=='1' && getCookie('lev_type')=='0' && getCookie('lev_check')=='false') || (getCookie('fak_type')=='0' && getCookie('lev_type')=='1' && getCookie('lev_check')=='true') || (getCookie('fak_type')=='1' && getCookie('lev_check')=='false')){
		$('#ShippingMethod_1, #ShippingMethod_59, #GLS_ParselShops_59').hide();
    }

*/

}






    $(".FrontModels img").hover(
        function () {
            $(this).attr('src',$(this).attr('src').replace('-100','-100-ak'));
        }, 
    function () {
            $(this).attr('src',$(this).attr('src').replace('-100-ak','-100'));
    });


	// Loading på alle produktgrupper, varelister og varekort
	$('body').append('<img src="http://img.printerpatroner.dk/images/template/loading.png" style="display:none">')

	/*$('#ShopMainLayOutTable a').click(function() {
		if ($(this).attr('href').indexOf('s.html') != -1 || $(this).attr('href').indexOf('p.html') != -1 || $(this).attr('href').indexOf('c1.html') != -1){
			Alert(true,999,'alertloading','http://img.printerpatroner.dk/images/template/loading.png','Siden hentes...')
			setTimeout("CloseAlert();", 2000);
		}
	});*/


	//Title på indkøbskurv
	$('#ShopMainLayOutTable .ActionButtons a').eq(0).attr('title','Tilføje en vare');
	$('#ShopMainLayOutTable .ActionButtons a').eq(1).attr('title','Fjerne en vare');
	$('#ShopMainLayOutTable .ActionButtons a').eq(2).attr('title','Fjerne varelinie');
    
    
	$('.FrontPage_TD .BoxProdContent').click(function() {
		if ($(this).find('a').attr('href').indexOf('http://') != -1)
		{
			window.open($(this).find('a').attr('href'));
		}
		else
		{
			location.href = ($(this).find('a').attr('href'));		
		}
					
	});



});


////////////////////////////////////////////////////////


function findreplace(el, find, rep) {
	try{$(el).html($(el).html().replace(find, rep))}catch(e){};
}



function Alert(Visible,CloseTimeInSec,MsgClass,BackgroundImage,AlertMsg) {
	
	if (Visible){var Visible='';}else{var Visible='display:none;';}
	
	//old_alert(getPageScroll()[1]);

	$('body').prepend('<div id="MsgOverlay" style="z-index:200;position:absolute;left:0px;top:0px;height:0px;width:100%;height:'+ $('#ShopMainLayOutTable').height() +'px;background:#000000;'+ Visible +'"></div><div id="Msg" style="z-index:200;position:absolute;width:100%;height:100%;'+ Visible +'"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%" style="margin-top:' + getPageScroll()[1] + 'px"><tr><td align="center" valign="center"><span style="background-image:url('+ BackgroundImage +');background-repeat:no-repeat;width:327px;height:189px;padding-top:74px;display:block;z-index:100;"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="115"><tr><td align="center" valign="center" class="AlertMsg '+ MsgClass +'">'+ AlertMsg +'</td></tr></table></span></td></tr></table></div>')
	$('#MsgOverlay').css('opacity', 0.25);
	setTimeout("CloseAlert();", CloseTimeInSec*1000);
	$('#MsgOverlay, #Msg').click(function() {
		CloseAlert();
	});

}

//getPageScroll()[1] + ((getPageHeight() / 2) - ($('#facebox').height() / 2) 

function CloseAlert() {
	$('#Msg').hide();
	$('#MsgOverlay').fadeOut('slow');
	$('#MsgOverlay, #Msg').remove();
}

  function getPageScroll() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
      yScroll = self.pageYOffset;
      xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
      yScroll = document.documentElement.scrollTop;
      xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
      yScroll = document.body.scrollTop;
      xScroll = document.body.scrollLeft;	
    }
    return new Array(xScroll,yScroll) 
  }

  // Adapted from getPageSize() by quirksmode.com

