var sm_deals = {

    sm_redirect : function (id)
    {
        id = parseInt(id);
        if (id > 0)
        {
            location.href = '/deals/browse?id=' + id;
        }

    }

}

function elementSupportsAttribute(element,attribute) {
	var test = document.createElement(element);
	if (attribute in test) {
		return true;
	} else {
		return false;
	}
}

function placeholder(id, value) {
	if (!elementSupportsAttribute('input', 'placeholder')) {

		if ($('#' + id).val() == '') {
			$('#' + id).val(value);
		}
		$('#' + id).click(
			function () {
				var bval = $(this).val();
				if (bval == value) {
					$(this).val('');
				}
			}
		);
		$('#' + id).blur(
			function () {
				var bval = $(this).val();
				if (bval == '') {
					$(this).val(value);
				}
			}
		)
	}
}

$(document).ready(function () {
	//placeholder('nemail', 'Enter your email address here');
	//placeholder('email', 'Your Email Address Here...');
	jQuery.support.placeholder = true;
	test = document.createElement('input');
	if('placeholder' in test) jQuery.support.placeholder = true;

	if(!$.support.placeholder) {
		var active = document.activeElement;
		$(':text').focus(function () {
			if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
				$(this).val('').removeClass('hasPlaceholder');
			}
		}).blur(function () {
			if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
				$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
			}
		});
		$(':text').blur();
		$(active).focus();
		$('form').submit(function () {
			//$(this).find('.hasPlaceholder').each(function() { $(this).val(''); });
		});
	}
});
