
var XWTShowroomCheck = new XWTObject("showroomCheck");
XWTShowroomCheck.setEventHandler(new XWTShowroomCheckEventHander());
XWTShowroomCheck.setCallbackHandler(new XWTShowroomCheckCallbackHandler());

var showroomid = null;
var userid = null;
var tokenid = null;
var companyid = null;
var link = null;
var locale_str = null;
var pop = null;
var obj = null;

function checkAccessibiliy(thisobj, isprivate, thisshowroomid, thiscompanyid, thisuserid, thistokenid, thislocale, thispop, thislink) {
	if (isprivate) {
		obj=thisobj;
		showroomid = thisshowroomid;
		userid=thisuserid;
		tokenid=thistokenid;
		companyid = thiscompanyid;
		locale_str = thislocale;
		link=thislink;
		pop=thispop;
		XWTShowroomCheck.getEventHandler().handleEvent();
		return false;
	} else {
		window.location = thislink;
		return true;
	}
}

function XWTShowroomCheckEventHander() {
	this.handleEvent = function(){
		var url = "/AJAXControllerServlet";
		if (getContext() != "/") {		
			url = getContext()+ url; //Servlet Location
		}
		XWTShowroomCheck.clear();
		XWTShowroomCheck.setParameter("AJAX_HANDLER","showroomCheck");
		XWTShowroomCheck.setParameter("showroomID",showroomid);
		XWTShowroomCheck.setParameter("userID",userid);
		XWTShowroomCheck.setParameter("tokenID",tokenid);
		XWTShowroomCheck.setParameter("companyID",companyid);
		XWTShowroomCheck.setParameter("locale",locale_str);		

		XWTShowroomCheck.submit(url);
	}
}

function XWTShowroomCheckCallbackHandler(){
	this.callback = function(reqResponseXML) {
		if (reqResponseXML.getElementsByTagName("ShowroomAccessiable")[0].firstChild.data == "true") {
			window.location = link;
		} else {
			openPopUpDiv(pop, obj, true, false);
		}
	}
}