function changesku(sku_id,attr,new_price) {
        document.getElementById('pricing').innerHTML = new_price;
        document.add_cart_form.sku_id.value= sku_id;
	document.add_cart_form.attr.value= attr;
}

function sellProdColor(product_id,size_chart,color,full_title,front,back,cname,des_id,type,sku_id,alt_media) {
        document.getElementById('selected_color').innerHTML = cname;
        document.getElementById('blank_name').innerHTML = full_title;

        script = 'garment';
        if (document.getElementById('design_photo').className == 'des') {
                script = 'thumb';
        }

	if (alt_media != '') {
                document.getElementById('design_photo').style.backgroundImage = 'url('+alt_media+')';
        } else {
		document.getElementById('design_photo').style.backgroundImage = imageurl(script,'1',des_id,color,front);
	}

	var querystring = 'blank_product_id=' + product_id + '&product_id=' + product_id + '&des_id='+des_id+'&orig_sku_id='+document.add_cart_form.sku_id.value;

	comp = "_view_option_apparel";
	if (type == "bag") {
		comp = "_view_option_bag";
	} else if (type == "blank") {
                comp = "_view_option_blank";
        }

	if (sku_id !='') {
		document.add_cart_form.sku_id.value= sku_id;
	}

        new Ajax.Updater ('viewoptions','/ajax/'+comp,{
                method: 'post',
                asynchronous: true,
                postBody: querystring,
                evalScripts: true
        });

        //refresh size picker
        dispatch('size_picker','/ajax/size_picker',querystring,'');

        if (document.getElementById('todesign')) {
                document.getElementById('todesign').href = "/design?des_id="+des_id+"&blank_product_id="+product_id;
        }

	if (document.getElementById('customize_it_button')) {
		document.getElementById('customize_it_button').href
		 = "/set_des_data?current_tab=blank_picker&des_id="+des_id+"&blank_product_id="+product_id;
	}
}

function imageurl (script,large,des_id,color,blank) {

        return 'url(http://image02.demandmade.com/php/'+script+'.php/large,'+large+'/des_id,'+des_id+'/hex,'+color+'/blank,'+blank+'/des.jpg)';
}

function changeframesku(des_id,blank_product_id,frame_media) {
        //refresh size picker
        var querystring = 'blank_product_id=' + blank_product_id + '&des_id='+des_id+'&attribute_id='+document.add_cart_form.attr.value;
        dispatch('sellprint','/ajax/_sell_comp_print',querystring,'');

	if (frame_media !='') {
		document.getElementById('designframe').style.backgroundImage = 'url(http://image01.demandmade.com/IMGSRV/sc/441x/s/product_media/' +  frame_media + ')';
	}
}

function changedev(des_id) {
	alert(des_id);
}

function switchlineprod(blank_prod_cat_id,product_title,showthumb,product_id,des_id,pageno,category_id) {
        var querystring = 'blank_prod_cat_id=' +  blank_prod_cat_id + '&blank_product_id=' + product_id + '&des_id=' + des_id + '&pageno=' + pageno + '&category_id=' + category_id+ '&sell_type=blank';

        new Ajax.Updater ('sellview','/ajax/_sell_view',{
                method: 'post',
                asynchronous: true,
                postBody: querystring,
                evalScripts: true,
                onComplete: function(){document.getElementById('blank_title').innerHTML = product_title;}
        });

	querystring += '&product_id=' + product_id;
	//refresh size picker
        dispatch('size_picker','/ajax/size_picker',querystring,'');

	if (document.getElementById('back_to_design_link')) {
		document.getElementById('back_to_design_link').href = "/design?des_id="+des_id+"&blank_product_id="+product_id;
	}
}

function switchlinecat(category_id,des_id,pageno) {
        var querystring = 'category_id=' +  category_id + '&pageno=' + pageno + '&des_id=' + des_id;

        new Ajax.Updater ('linepicker','/ajax/_line_cat_pick',{
                method: 'post',
                asynchronous: true,
                postBody: querystring,
                evalScripts: true,
                onComplete: function(){}
        });
}
