<!--

/*
    FreePokerAlliance gadgets JavaScript functions
    (c) 2009, MGame Solutions
*/

var fpaGadgets = function() {
    
    // mobile select variables
    this.mobile_manufacturer = undefined;
    this.mobile_model = undefined;
    this.mobile_phonenumber = undefined;
    this.mobile_form = undefined;

	function getObjectById(objectIdStr) {
		var o = document.getElementById(objectIdStr);
		return o;
	}
	    
    return {
        embedPrize: function(data) {
    		$('#'+data.id).addClass(data.stylename);
    		var html='',
    			content='<div>',
    			footer='';
    		if (data.contentpart1 != undefined)
    			content+='<p>'+data.contentpart1+'</p>';
    		if (data.prizeimage != undefined)
    			content+=(data.prizeurl != undefined ? '<a href="'+data.prizeurl+'" target="_blank">' : '')+'<img src="'+data.prizeimage+'">'+(data.prizeurl != undefined ? '</a>' : '');
    		if (data.contentpart2 != undefined)
    			content+='<p>'+data.contentpart2+'</p>';
    		content+='</div>';
    		footer+='<p>';
    		if (data.bottomline1 != undefined)
    			footer+='<span>'+data.bottomline1+'</span><br/>';
    		if (data.bottomline2 != undefined)
    			footer+=data.bottomline2;
    		footer+='</p>';
    		html = '<div class="title"><p>'+data.title+'</p></div><div class="content">'+content+'</div><div class="footer">'+footer+'</div>';
    		$('#'+data.id).html(html);
        },
        
        embedMobile: function(objectIdStr, submitFunc, changeManufacturerFunc, styleStr, titleStr, footStr, sampleStr, selectMan, selectMod, goBtnTitle) {
            var o = getObjectById(objectIdStr);
            if (o) {
                o.className = styleStr;
                var titlediv = document.createElement('div');
                titlediv.className = 'title';
                titlediv.appendChild(document.createElement('p')).appendChild(document.createTextNode(titleStr));
                o.appendChild(titlediv);
                var content = document.createElement('div');
                content.className = 'content';
                var formdiv = document.createElement('div');
                var form = document.createElement('form');
                form.method='POST';
                form.onsubmit = submitFunc;
                var sel = document.createElement('select');
                this.mobile_manufacturer = sel;
                sel.onchange = changeManufacturerFunc;
                form.appendChild(sel);
                var opt = document.createElement('option');
                opt.setAttribute('value','');
                opt.appendChild(document.createTextNode(selectMan));
                sel.appendChild(opt);
                var sel2 = document.createElement('select');
                sel2.disabled = true;
                this.mobile_model = sel2;
                sel2.appendChild(document.createElement('option')).appendChild(document.createTextNode(selectMod));
                form.appendChild(sel2);
                var phonenum = document.createElement('input');
                this.mobile_phonenumber = phonenum;
                phonenum.setAttribute('type','text');
                form.appendChild(phonenum);
                form.appendChild(document.createElement('p')).appendChild(document.createTextNode(sampleStr));
                var btn = document.createElement('input');
                btn.className = 'submit';
                btn.setAttribute('type','submit');
                btn.setAttribute('value',goBtnTitle);
                form.appendChild(btn);
                formdiv.appendChild(form);
                formdiv.appendChild(document.createElement('p')).appendChild(document.createTextNode(footStr));
                content.appendChild(formdiv);
                o.appendChild(content);
            }
        },
        
        embedTechnicalReq: function(data) {
    		$('#'+data.id).addClass(data.stylename);
    		var html='<div class="title"><p>'+data.title+'</p></div><div class="content"><p>'+data.content+'</p></div>';
    		$('#'+data.id).html(html);
        },
        
        addMobileManufacturer: function(nameStr) {
            var opt = document.createElement('option');
            opt.setAttribute('value',nameStr);
            opt.appendChild(document.createTextNode(nameStr));
            this.mobile_manufacturer.appendChild(opt);
        },
        
        getMobileManufacturer: function() {
            return this.mobile_manufacturer[this.mobile_manufacturer.selectedIndex].getAttribute('value');
        },
        
        clearMobileModels: function() {
            while (this.mobile_model.length>0)
                this.mobile_model.remove(0);
        },
        
        addMobileModel: function(nameStr) {
            var opt = document.createElement('option');
            opt.setAttribute('value',nameStr);
            opt.appendChild(document.createTextNode(nameStr));
            this.mobile_model.appendChild(opt);
        },
        
        getMobileModel: function() {
            return this.mobile_model[this.mobile_model.selectedIndex].getAttribute('value');
        },
        
        changeMobileVisibility: function(isVisible) {
            this.mobile_model.disabled = !isVisible;
        },
        
        getMobileNumber: function() {
            return this.mobile_phonenumber.value;
        },
        
        setMobileNumber: function(newval) {
            this.mobile_phonenumber.value = newval;
        },
        
        resetMobileForm: function() {
            this.mobile_manufacturer.selectedIndex = 0;
            this.mobile_phonenumber.value = '';
        }
        
    }

};

//-->
