var MODAL_BOXES = {
	"djbookform": [480, 400, "http://www.zoukclub.com/index/contact/djbooking"],
	"shopfaq": [750, 380, "http://www.zoukclub.com/index/faq/shop"],
	"faq": [750, 380, "http://www.zoukclub.com/index/faq/listing"],
	"marketingform": [480, 340, "http://www.zoukclub.com/index/contact/marketing"],
	"jobsform": [800, 420, "http://www.zoukclub.com/index/job/job_form"],
	"venueform": [560, 470, "http://www.zoukclub.com/index/contact/venue_hire"],
	"general": [480, 360, "http://www.zoukclub.com/index/contact/general"],
	"events": [480, 360, "http://www.zoukclub.com/index/contact/events"],
	"lostfound": [480, 360, "http://www.zoukclub.com/index/contact/lost_found"],
	"membership": [480, 360, "http://www.zoukclub.com/index/contact/membership"],
	"tnc": [860, 560, "http://www.zoukclub.com/index/tnc/listing"]
}





window.addEvent("domready", function(){

	SqueezeBox.parsers.swf = function(preset) {
	return  (preset || (/\.swf/).test(this.url)) ? this.url : false;
	return (preset || this.url.test(/\.swf/)) ? this.url : false;
	
	
	};

SqueezeBox.handlers.swf = function(url) {

	var size = this.options.size;
	return new Swiff(url, {
		id: 'sbox-swf',
		width: size.x,
		height: size.y
	});
};


	
});	


function openPopup(id) {
	var splitArr = MODAL_BOXES[id];
	var w= splitArr[0];
	var h = splitArr[1];
	var newWindow = window.open(splitArr[2],'','height='+h+',width='+w+',resizable=false,scrollbars=yes');
	if (window.focus) {  newWindow.focus() }
}

function openWindow(id) {
	openModalLink(id);
	/*
	var item = $(id+"_link");
	var splitArr = item.rel.split(" ");
	var w= parseInt(splitArr[1]) + 120;
	var h = parseInt(splitArr[2]) + 80;
	var newWindow = window.open("html/"+id+".html",'','height='+h+',width='+w+',resizable=false');
	if (window.focus) {  newWindow.focus() }
	*/
}

function closeWindow() {
	SqueezeBox.close();
}

function modelBoxClosed() {
	flashvars.branch = _returnBranch;
	flashvars.revisit = "1";
	swfobject.embedSWF("main.swf", "flashcontent", "100%", "100%", "9.0.124", "expressInstall.swf", flashvars, params, attributes);
}

var _returnBranch;

function openModalLink(id) {
	
	if (!MODAL_BOXES[id]) {
		alert("NO parameters found for box");
		return;
	}
	var splitArr = MODAL_BOXES[id];
	
	var swfObj = $$('object');
	
	swfObj = swfObj ? swfObj[0] : null;
	
	if (swfObj) {
		_returnBranch = swfObj.getCurrentBranch();
		
		
		var stage = swfObj.parentNode;
		stage.removeChild( swfObj   );
		stage.appendChild(  new Element("div", { "id":"flashcontent" } ) );
	}
	
	SqueezeBox.open(splitArr[2], {
			//handler: 'adopt',
			size: {x: splitArr[0], y: splitArr[1]},
			onClose: modelBoxClosed
	});
}
	
	
function fix_flash(targetMode) {
	targetMode = targetMode || "opaque";

    // loop through every embed tag on the site
    var embeds = document.getElementsByTagName('embed');
    for(i=0; i<embeds.length; i++)  {
        embed = embeds[i];
        var new_embed;
        // everything but Firefox & Konqueror
        if(embed.outerHTML) {
			
            var html = embed.outerHTML;
            // replace an existing wmode parameter
            if(html.match(/wmode\s*=\s*('|")[a-zA-Z]+('|")/i))
                new_embed = html.replace(/wmode\s*=\s*('|")window('|")/i,"wmode='"+targetMode+"'");
            // add a new wmode parameter
            else 
                new_embed = html.replace(/<embed\s/i,"<embed wmode='"+targetMode+"' ");
            // replace the old embed object with the fixed version
            embed.insertAdjacentHTML('beforeBegin',new_embed);
            embed.parentNode.removeChild(embed);
        } else {
            // cloneNode is buggy in some versions of Safari & Opera, but works fine in FF
            new_embed = embed.cloneNode(true);
            if(!new_embed.getAttribute('wmode') || new_embed.getAttribute('wmode').toLowerCase()=='window')
                new_embed.setAttribute('wmode',targetMode);
            embed.parentNode.replaceChild(new_embed,embed);
        }
    }
    // loop through every object tag on the site
    var objects = document.getElementsByTagName('object');
    for(i=0; i<objects.length; i++) {
        object = objects[i];
        var new_object;
        // object is an IE specific tag so we can use outerHTML here
        if(object.outerHTML) {

            var html = object.outerHTML;
            // replace an existing wmode parameter
            if(html.match(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")[a-zA-Z]+('|")\s*\/?\>/i))
                new_object = html.replace(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")window('|")\s*\/?\>/i,"<param name='wmode' value='"+targetMode+"' />");
            // add a new wmode parameter
            else 
                new_object = html.replace(/<\/object\>/i,"<param name='wmode' value='"+targetMode+"' />\n</object>");
            // loop through each of the param tags
            var children = object.childNodes;
            for(j=0; j<children.length; j++) {
                if(children[j].getAttribute('name').match(/flashvars/i)) {
                    new_object = new_object.replace(/<param\s+name\s*=\s*('|")flashvars('|")\s+value\s*=\s*('|")[^'"]*('|")\s*\/?\>/i,"<param name='flashvars' value='"+children[j].getAttribute('value')+"' />");
                }
            }
            // replace the old embed object with the fixed versiony
            object.insertAdjacentHTML('beforeBegin',new_object);
            object.parentNode.removeChild(object);
        }
    }
}


