﻿$(document).ready(function() {

    // sodaHead poll widgets embed code
    var qArr = [];
    var q1 = 'http://www.sodahead.com/living/has-your-us-credit-or-debit-card-been-declined-while-you-are-traveling-internationally/question-1110481';
    var q2 = 'http://www.sodahead.com/living/if-youve-had-your-credit-or-debit-card-decline-while-traveling-internationally-what-type-of-card-d/question-1111181';
    var q3 = 'http://www.sodahead.com/united-states/if-youve-had-your-us-credit-or-debit-card-been-declined-while-you-are-traveling-internationally/question-1111185';
    var q4 = 'http://www.sodahead.com/living/if-youve-had-your-us-credit-or-debit-card-been-declined-while-you-are-traveling-internationally/question-1111193';
    qArr.push(q1, q2, q3, q4);

    // random num from 1-4
    var random = Math.floor(Math.random() * 4 + 1);

    var pollEl = document.getElementById('poll');
    if (pollEl != null && qArr.length > 0) {
        // show certain question
        var embed = '<img style="visibility:hidden;width:0px;height:0px;" border=0 width=0 height=0 src="http://counters.gigya.com/wildfire/IMP/CXNID=2000002.0NXC/bT*xJmx*PTEyNzk1MDQwMzIxNTYmcHQ9MTI3OTUwNDA4NDk2OCZwPTEyNzQxJmQ9Jmc9MiZvPTVlMTQzMmEzMWY3YjQ*OGE4Y2Fh/NWIzZTgwNzU2NjFjJm9mPTA=.gif" /><div class="widgetContainer" style="display: table; margin: 5px auto; font-family: arial, helvetica, sans-serif; text-align: center; width: 336px; *display: inline; *zoom: 1;"><object width="336" height="170" style="display: block;"><param name="allowScriptAccess" value="always" /><param value="transparent" name="wmode"/><param name="movie" value="http://widgets.sodahead.com/images/flash/poll.swf" /><param name="flashvars" value="height=170&width=336&widgetHeight=170&widgetWidth=336&poll_id=1110481" /><embed type="application/x-shockwave-flash" src="http://widgets.sodahead.com/images/flash/poll.swf" width="336" height="170" flashvars="height=170&width=336&widgetHeight=170&widgetWidth=336&poll_id=1110481" wmode="transparent" style="display: block;" allowScriptAccess="always" /></object><div class="widgetFooter" style="background: #fff url(http://widgets.sodahead.com/images/flash/footerGradient.gif) repeat-x scroll bottom center; border: 1px solid #e6e6e6; font-size: 0; height: 13px; line-height: 13px; padding: 0 3px; text-align: right;"><a href="http://www.sodahead.com/questions/" style="color: #484747; font-size: 10px; text-decoration: none;float: left;">Questions</a><a href="' + qArr[random - 1 ] + '" style="color: #484747; font-size: 10px; text-decoration: none;">View Results</a></div></div>';
        pollEl.innerHTML = embed;
    }

    $('.inSearch').each(function() {
        var $this = $(this);
        var searchDefault = this.value;
        $('#fldFld > select').bind('change', function() {
            var selected = $(this).find(':selected').html();
            if ($this.val().match(/Enter \w*/)) $this.attr('value', 'Enter ' + selected);
            searchDefault = 'Enter ' + selected;
            $this.unbind('blur').bind('blur', function() {
                this.value = (this.value == '') ? searchDefault : this.value;
            });
            $this.unbind('focus').bind('focus', function() {
                this.value = (this.value == searchDefault) ? '' : this.value;
            });
        });
        $this.bind('blur', function() {
            this.value = (this.value == '') ? searchDefault : this.value;
        });
        $this.bind('focus', function() {
            this.value = (this.value == searchDefault) ? '' : this.value;
        });


    });   
});

     

