$(document).ready(function(){
if(document.location.hash=="#embed"){
$('#embed').show()}
wColor='#'+$('#embed_color').html()
var flashvars={displayTitle:"true",color:wColor,previewMode:"true",pollId:$('#embed_poll_id').html()}
var params={allowScriptAccess:"always"}
var attributes={id:"widget"}
swfobject.embedSWF('http://'+document.domain+'/themes/front/swf/widget.swf','widget','100%','100%','8.0.0','http://'+document.domain+'/themes/front/swf/expressInstall.swf',flashvars,params,attributes)
colorPicker=$.farbtastic('#colorpicker')
colorPicker.setColor(wColor)
colorPicker.linkTo(cPickerCallback)
setEmbed()
$('#man_w_width').numeric()
$('#man_w_width').keyup(function(){
var val=$('#man_w_width').val()
if(val.length>2){
if(val<140){
val=140}
if(val>600){
val=600}
$('#man_w_width').val(val)
setWidgetWidth(val)
setEmbed()}
})
zc_init('copy_bt')
})
function toggle(){
$('#embed').toggle()
zc_init('copy_bt')}
function cPickerCallback(color){
wColor=color
$('#embed_color').html(color)
setWidgetColor(color.substr(1))
setEmbed()}
function onWidgetLoaded(){
setWidgetWidth(300)}
function setWidgetWidth(w){
$('#flash').width(600)
if(w==null){
w=$('#w_width').val()
$('#man_w_width').val(w)}
$('#widget').externalInterface({
method:'setWidth',
args:w,
success: function(response){
$('#flash').width(w)
$('#flash').height(response)
},
error: function(error){
alert('error: '+error)}
})
setEmbed()}
function setWidgetColor(col){
$('#widget').externalInterface({
method:'setColor',
args:col,
success: function(response){
setEmbed()
},
error: function(error){
alert('error: '+error)}
})}
function setWidgetTitleDisplay(){
$('#widget').externalInterface({
method:'setTitleDisplay',
args:$('#showTitle').attr('checked'),
success: function(response){
$('#flash').height(response)
setEmbed()
},
error: function(error){
alert('error: '+error)}
})}
function setEmbed(){

var fwidth=$('#man_w_width').val()
var fheight=$('#flash').height();
//if(fwidth < 180){
//	fheight=$('#flash').height() + 20;
//}


var poll_id=$('#embed_poll_id').html()
var path="/themes/front/swf/widget.swf"
var title=$('#showTitle').attr('checked')
var embed="<!-- embed opiniondujour.com -->\n<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' id='odjWidget"+poll_id+"' width='"+fwidth+"' height='"+fheight+"'>\n<param name='wmode' value='transparent'/>\n<param name='movie' value='http://"+document.domain+path+"' />\n<param name='AllowScriptAccess' value='always'/>\n<param name='flashVars' value='displayTitle="+title+"&amp;color="+wColor+"&amp;pollId="+poll_id+"' />\n<embed src='http://"+document.domain+path+"' type='application/x-shockwave-flash' name='odjWidget"+poll_id+"' AllowScriptAccess='always' flashVars='displayTitle="+title+"&amp;color="+wColor+"&amp;pollId="+poll_id+"' wmode='transparent' width='"+fwidth+"' height='"+fheight+"'></embed>\n</object>\n<p><a href='http://www.opiniondujour.com'>Sondages quotidiens sur l'actualit&eacute;</a></p>\n<!-- embed opiniondujour.com -->"
$('#embedoutput').val(embed)}

