	$(document).ready(function(){
	
		if (window.location != top.location)
		{
			top.location = window.location;
		}

		updatecart();

		$('a[rel=\'productimage\']').colorbox({ 
			maxHeight:'800px',
			opacity:0.50,
			initialWidth:'500px',
			initialHeight:'500px',
			photoScaling:true,
			title:'Use the arrowkeys to navigate. Press ESC to close.'
		});
		
		if (document.getElementById('alertbox')) {
			$.fn.colorbox({
				opacity:0.50, 
				initialWidth:'500px',
				initialHeight:'500px',
				maxWidth:'500px',
				open:true, 
				inline:true, 
				href:"#alertbox"
			});
		}

		$('#gotocart_button').css('cursor', 'pointer').click(function(){
			location.href = '?view=cart&step=confirmcart';
		});

		$('#ok_button').css('cursor', 'pointer').click(function(){
			if(gotopage != 'undefined') {
				if (gotopage == 'overview')
				{
					location.href = '?brand=' + brand;
				}
				else
				{
					location.href = '?brand=' + brand + '&category=' + category + '&page=' + gotopage;
				}
			}
		});

		$('#loginok_button').css('cursor', 'pointer').click(function(){
			$.fn.colorbox.close()
		});

		//$(document).pngFix(); 
		//$(function(){$(document).pngFix();});
		$('div.cart').pngFix();

		$('select#sortby').change(function(){
			new_location = location.href.replace(/\&[sortby=][^&]*/gi, '') + '&sortby=' + $(this).val();
			location.href = new_location;
		})

		$('#forgotlogin_button').live('click', function(){

			$.get('/sendpassword.asp', {user: $('#forgotlogin_input').val()});

			$('#forgotlogin_container').html('Your password has been sent.<br /><br />This window will close in 3 seconds.');
			setTimeout("$.fn.colorbox.close()", 3000);

		})
	
		$('#forgotlogin').click(function(){
			
			alert('<div id="forgotlogin_container" style="text-align:left;">Enter either login-id or e-mail<br />and your password will be e-mailed to you.<br /><br /><input onBlur="if (this.value==\'\') this.value=\'Login-id or e-mail\'" onFocus="if (this.value==\'Login-id or e-mail\') this.value=\'\'"  class="textfield" type="text" value="Login-id or e-mail" name="forgotlogin_input" id="forgotlogin_input">&nbsp;<input type="button" class="button" value="Send" name="forgotlogin_button" id="forgotlogin_button" /></div>');
			
			$.fn.colorbox({
				opacity:0.50, 
				initialWidth:'500px',
				initialHeight:'500px',
				height:'190px',
				width:'390px',
				open:true, 
				inline:true, 
				href:"#alertbox"
			});
		})
	
		playVideo = function() {
	
			alert('<object type="application/x-shockwave-flash" data="/website/swf/player_flv_maxi.swf" width="620" height="286"><param name="movie" value="/website/swf/player_flv_maxi.swf" /><param name="allowFullScreen" value="true" /><param name="wmode" value="transparent" /><param name="FlashVars" value="flv=/images/Radii_Spring2011.flv&amp;width=620&amp;height=286&amp;showiconplay=1&amp;autoload=1&amp;volume=50&amp;margin=0&amp;showplayer=never&amp;wmode=transparent&amp;buffermessage=&amp;autoplay=1" /></object>');
			
			$.fn.colorbox({
				opacity:0.50, 
				initialWidth:'500px',
				initialHeight:'500px',
				height:'380px',
				width:'680px',
				open:true, 
				inline:true, 
				href:"#alertbox"
			});
	
		}

		if (location.href.indexOf('#46') != -1) {
			window.scrollTo(0, $('#content .product:eq(47)').offset().top-240)
		}

		if (location.href.indexOf('&page=') != -1) {
			$('#blog .text .product a').each(function(){
				$(this).attr('href', $(this).attr('href') + '&page=' + querySt('page'))			
			})
		}

	})

	function updatecart(){
		$('#cartcontent').load('/load.asp?' + Math.floor(Math.random()*10000000));
	}
	
	old_alert = window.alert;

	window.alert = function(txt){
	
		updatecart();

		var alertbox	= document.createElement('div');
			alertbox.id = 'alertbox';

		$(alertbox).html(txt.replace(/\n/g, '<br>')).css('padding', '10px').css('font-size', '12px').prependTo('#hidden');			
	
	}

	window.confirm = function(txt, truecondition){

		updatecart();

		var confirmbox	  = document.createElement('div');
			confirmbox.id = 'confirmbox';		
	
		$(confirmbox).html(txt.replace(/\n/, '<br>') + '<br><br><div style=""height:24px""><img id="ok_button" src="/images/ok.gif"> <img id="cancel_button" src="/images/cancel.gif"></div>').css('padding', '10px').css('font-size', '12px').prependTo('#hidden');	

		$('#ok_button').css('cursor', 'pointer').click(function(){
			location.href=truecondition;
		});

		$('#cancel_button').css('cursor', 'pointer').click(function(){
			$.fn.colorbox.close()
		});

		if (document.getElementById('confirmbox')) {
			$.fn.colorbox({
				opacity:0.50, 
				initialWidth:'500px',
				initialHeight:'500px',
				width:'350px',
				height:'150px',
				open:true, 
				inline:true, 
				href:"#confirmbox"
			});
		}

	}

	function switchto(q){
		if (q){
			document.getElementById('textfield5text').style.display="none";
			document.getElementById('textfield5').style.display="inline";
			document.getElementById('textfield5').focus();
		} else {
			document.getElementById('textfield5').style.display="none";
			document.getElementById('textfield5text').style.display="inline";
		}
	}

function querySt(ji) {
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i=0;i<gy.length;i++) {
ft = gy[i].split("=");
if (ft[0] == ji) {
return ft[1];
}
}
}
