// JavaScript Document
$.noConflict();
jQuery(document).ready(function($) {
//global variable declaration
var vars = {"11" : "abxy", "8" : "battery", "7" : "bottomtrim", "6" : "bumpers", "4" : "dpad", "10" : "other", "9" : "rol", "2" : "shell", "3" : "thumbsticks", "5" : "triggers"};
var current = {};
//end of global variables
//this builds the image of the controller on the page
function build(image, value, optionid){
type = vars[optionid];
current[type] = value;
type = type.substring(0,4);
$("[id=" + type + "]").html("<img src='" + image + "' />");
}
//end of build function
function parseid(id){
// this just takes "select" and whatnot out of the option
id = id.replace("options[", "");
id = id.replace("]", "");
return id;
}
//facebook stuffs
function modal_fade_out(){
$("#modal_background").fadeOut();
$("#modal_content").fadeOut();
}
$("#modal_background").live('click', function(){
modal_fade_out();
});
function fb_share(){
uniqueid = Math.floor((Math.random()*10000000000)+1);
current["id"] = uniqueid;
$.ajax({
url: "/imagemerge/imagemerge.php",
data: current,
type: 'post'
}).done(function(){
$("#compiled_picture").html("<img src='/imagemerge/" + uniqueid + ".png' id='compiled_picture_img' />");
});
$("#modal_background").fadeIn();
$("#modal_content").fadeIn();
}
function fb_share_final(){
var message = $("#facebook_share_text").val();
$.post("/imagemerge/fbshare.php", { "id": uniqueid, "message": message });
}
// end of facebook stuffs
//this loads if the img element is on the page
if($('.product-img-box').length){
$('.product-img-box').prepend("<div id='shel' class='replace_div'><img src='/imagemerge/basecontrollershell.png' /></div>");
$('.product-img-box').prepend("<div id='abxy' class='replace_div'></div>");
$('.product-img-box').prepend("<div id='bott' class='replace_div'></div>");
$('.product-img-box').prepend("<div id='bump' class='replace_div'></div>");
$('.product-img-box').prepend("<div id='dpad' class='replace_div'></div>");
$('.product-img-box').prepend("<div id='rols' class='replace_div'></div>");
$('.product-img-box').prepend("<div id='thum' class='replace_div'></div>");
}
//end of image thingy
//these two controll the changing of options
$('select').change(function(){
optionid = parseid($(this).attr("id"));
value = $(this).val();
image = $(this).prev().attr("bigimgpath")
build(image, value, optionid);
});
$('input').change(function(){
optionid = parseid($(this).attr("name"));
id = $(this).val();
image = $(this).prev().attr("bigimgpath")
build(image, id, optionid);
});
// end of changing options
//scrollfollow stuff- add later
//end of scrollfollow stuff
});