var susc_text = "";

function applyStyleButtons(){
	var html = "";
	
	$("button").each(function (){
		var html = jQuery("<button class='btnInput "+$(this).attr("class")+"' name='"+$(this).attr("name")+"' style='"+$(this).attr("style")+"' tabindex='"+$(this).attr("tabindex")+"' value='"+$(this).attr("value")+"' type='"+$(this).attr("type")+"'><span>"+$(this).html()+"</span></button>");
		if ($(this).css("display") == 'none'){
			$(this).replaceWith(html);
			$(html).hide();
		}else{
			$(this).replaceWith(html);
		}
	});
	$("input[type='button'], input[type='submit']").each(function (){
		var html = jQuery("<button class='btnInput "+$(this).attr("class")+"' name='"+$(this).attr("name")+"' style='"+$(this).attr("style")+"' value='"+$(this).attr("value")+"' tabindex='"+$(this).attr("tabindex")+"' type='"+$(this).attr("type")+"'><span>"+$(this).attr("value") +"</span></button>");
		if ($(this).css("display") == 'none'){
			$(this).replaceWith(html);
			$(html).hide();
		}else{
			$(this).replaceWith(html);
		}
	});
	
	Cufon.replace('.btnInput span', {fontFamily: 'Helvetica LT Std'});	
	return true;
	
}

$(document).ready(function (){
	applyStyleButtons();
	$("#mc_mv_EMAIL").val("enter your e-mail address");
	susc_text = $("#mc_mv_EMAIL").val();
	$("#mc_mv_EMAIL").focus(function (){
		if (susc_text == $(this).val())
			$(this).val("");
	});
	$("#mc_mv_EMAIL").blur(function (){
		if (jQuery.trim($(this).val()) == "")
			$(this).val(susc_text);
	});
	$("#header #cart").mouseover(function (){
		$("#sidecart", this).show();
	});
	$("#header #cart").mouseout(function (){
		$("#sidecart", this).hide();
	});
	/*
	var visited = getCookie("visited");
	console.log("visited = "+visited);
	if(visited == null || visited == 'true'){
		console.log("before");
		setCookie("visited", "true", 365);
		$.fallr('show', {
			content: '<img src="http://kartellstorela.com/wp-content/themes/kartell/images/warehouse_ad.jpg" width="463" height="601" />',
			width: 600,
		});
		console.log("after");
	}
	*/
});

function setCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

