/// <reference path="jquery.intellisense.js"/>

if(!bdabd)
	var bdabd = {};

if(!bdabd.bdxm)
	bdabd.bdxm = {};
if(!bdabd.bdxm.openOrderDialog){
	bdabd.bdxm.openOrderDialog = function(parameters){
		
		if(!parameters)
			throw('invalid parameters argument');
		
		if(!parameters.orderType)
			throw('orderType must be defined');		
		if(!parameters.albumId)
			throw('albumId must be defined');
		if(!parameters.popupUrl)
			throw('popupUrl must be defined');
		
		var orderType = parameters.orderType;
		var albumId = parameters.albumId;
		var popupUrl = parameters.popupUrl;
		var matchingOrderId;
		var wornState;
		if(parameters.matchingOrderId){
			matchingOrderId = parameters.matchingOrderId;
			if(typeof(matchingOrderId) != typeof(1))
			throw('matchingOrderId must be integer');
		}
		if(parameters.wornState){
			wornState = parameters.wornState;
			if(typeof(wornState) != typeof(1))
			throw('wornState must be integer');
		}
		if(orderType != 'buy' && orderType != 'sell')
			throw('invalid orderType: ' + orderType);
		if(typeof(albumId) != typeof(1))
			throw 'albumId must be integer';
		var url = popupUrl + '?albumid=' + albumId + '&type=' + orderType;
		if(matchingOrderId)
			url += '&matchingOrderId=' + matchingOrderId;
		if(wornState)
			url += '&etat=' + wornState;
		/*if(window.showModalDialog)
		{
			window.showModalDialog(url,'', 'center:yes;resizable:no;dialogHeight:650px;dialogWidth:570px');
		}
		else{*/
			window.open(url, 'order', 'toolbar=false,location=false,directories=false,status=false,menubar=false,scrollbars=no,resizable=no,width=570px,height=650px').focus();
		//}

	}
}