$(document).ready(function(){
	var newHeight = document.getElementById('content').offsetHeight;
	if(document.getElementById('sidecol'))
	{	
		var sidecolHeight = document.getElementById('sidecol').offsetHeight;
		if(newHeight > sidecolHeight)
		{
			$('.sidecol').css('height',newHeight+"px");
		}
		else if(newHeight < sidecolHeight)
		{
			$('.content').css('height',sidecolHeight+"px");
		}
	}
	
	if(document.getElementById('sub-left'))
	{
		var slheight = document.getElementById('sub-left').offsetHeight;
		var srheight = document.getElementById('sub-right').offsetHeight;
		if(newHeight > slheight && newHeight > srheight)
		{
			$('.sub-left').css('height',newHeight+"px");
			$('.sub-right').css('height',newHeight+"px");	
		}
		else if(slheight > newHeight && sl-height > srheight)
		{
			$('.sub-right').css('height',slheight+"px");	
			$('.content').css('height',slheight+"px");
		}
		else if(srheight > newHeight && srheight > slheight)
		{
			$('.sub-left').css('height',srheight+"px");	
			$('.content').css('height',srheight+"px");
		}
		
	}
	
	$("#ddlShippingCountry").change(
		function() {
			if(document.getElementById('chkShippingTo').checked || $("#chkShippingTo").attr("checked")) {
				$("#ddlBillingCountry :contains('"+$(":selected", this).text()+"')").each(function() { this.selected=true; })
			}
		}
	)
	
	$("#ddlBillingCountry").change(
		function() {
			if(document.getElementById('chkShippingTo').checked || $("#chkShippingTo").attr("checked")) {
				$("#ddlShippingCountry :contains('"+$(":selected", this).text()+"')").each(function() { this.selected=true; })
			}
		}
	)
	
	$(".content-rightcol input").change(
		function() {
			if($(this).attr('class') == 'chk')
			{}
			else if(document.getElementById('chkShippingTo').checked || $("#chkShippingTo").attr("checked")) {
				$(".content-rightcol label").each(
					function() {
						var thislabel = $(this).text();
						var temp = $(this).next().attr('value');
						$(".content-leftcol label").each(
							function()
							{
								if(thislabel == $(this).text())
								{
									$(this).next().attr('value',temp);
								}
							}
						)
					}
				)
			}
		}
	)
	
	$(".content-leftcol input").change(
		function() {
			if(document.getElementById('chkShippingTo').checked || $("#chkShippingTo").attr("checked")) {
				$(".content-leftcol label").each(
					function() {
						var thislabel = $(this).text();
						var temp = $(this).next().attr('value');
						$(".content-rightcol label").each(
							function()
							{
								if(thislabel == $(this).text())
								{
									$(this).next().attr('value',temp);
								}
							}
						)
					}
				)
			}
		}
	)
	
	$("#chkShippingTo").click(
		function() {
			if(document.getElementById('chkShippingTo').checked || $("#chkShippingTo").attr("checked")) {
				$(".content-leftcol label").each(
					function() {
						var thislabel = $(this).text();
						var temp = $(this).next().attr('value');
						$(".content-rightcol label").each(
							function()
							{
								if(thislabel == $(this).text())
								{
									$(this).next().attr('value',temp);
								}
							}
						)
					}
				)
			}
		}
	)
	/*
	
	if($(".gallery").length==1) {
	//if(document.getElementById('gallery')) {
		$.ImageBox.init(
			{
				loaderSRC: '/basemedia/images/imagebox/loading.gif',
				closeHTML: '<img src="/basemedia/images/imagebox/close.jpg" />'
			}
		); 
	}*/
	insertSWFs();
});
	

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};

jQuery.fn.vjustify=function() {
    var maxHeight=0;
    this.each(function(){
        if (this.offsetHeight>maxHeight) {maxHeight=this.offsetHeight;}
    });
    this.each(function(){
        $(this).height(maxHeight + "px");
        if (this.offsetHeight>maxHeight) {
            $(this).height((maxHeight-(this.offsetHeight-maxHeight))+"px");
        }
    });
};



function insertSWFs() 
{
	if(document.getElementById('flash-showreel')) insertBannerSWF();
};

function insertBannerSWF() 
{
	var so = new SWFObject("basemedia/flash/showreel.swf", "sotester", "850", "126", "8", "#FF6600");
	so.addParam("wmode", "transparent");
	//so.addVariable("variable1", "value1");
	so.write("flash-showreel");
};