/* App.js v0.1 | (c) 2014 Mighty JS | mightyjs.com/license */
//reset scroll
localStorage.removeItem("lastScroll");
//app life cycle
var birth = new Date().getTime(),
life = '0.0';
window.setInterval(function()
{
var time = new Date().getTime() - birth;
life = Math.floor(time / 100) / 10;
if(Math.round(life) == life) { life += '.0'; }
}, 100);
function globalRespond()
{
var cw = $( window ).width();
if ( cw < 1120 )
{
$("#inn_txt").css({"left": "", "right": "15px", "top": "571px"});
$("#whiteout").css({"height": "616px"});$("#orange_bar").css({"top": "616px"});$("#hosp_market_txt").css({"top": "638px"});
if ( cw < 1000 )
{
$("#phrase").hide();
}else{
$("#phrase").show();
}
}else if ( cw > 1120 )
{
$("#inn_txt").css({"left": "585px", "right": "", "top": "271px"});
$("#whiteout").css({"height": "316px"});$("#orange_bar").css({"top": "316px"});$("#hosp_market_txt").css({"top": "338px"});
}
//setup page
var tpad = $("#bluebar").height() + 1;
var dh = $(document).height();
var lpad = $("#body_page").attr("data-menu-offset"); //console.log("lpad is " + lpad);
var dw = $(document).width();
if ( $('html').data('hash') !== 'home$' && lpad > 0 ) { dw -= 8; }
var w;
if ( lpad == 0 )
{
w = dw; ml = 300;
}else{
w = dw - lpad; ml = 300;
if ( $('html').data('hash') !== 'home$' )
{
ml += 130;
w -= 130;
}
}
if ( $('html').data('hash') === 'home$' )
{
var hh = $("#mainscreen").height() + 152;
$("#container").css("height", hh + "px");
}else{
$("#container").css("height","100%");
}
$("#body_page").css(
{
"width": w + "px"
});
$("#page").css(
{
"width": w + "px",
"margin-top": tpad + "px",
"height": (dh-tpad) + "px",
"margin-left": ml + "px"
});
$("#mainscreen").css(
{
"top": tpad + 10 + "px",
});
//colorways center
$("#colorways").css("width", "auto");
var width = $("#colorways").width();
var perrow = Math.floor(width/280);
$("#colorways").css("width", perrow*280 + "px");
$("[data-respond-width]").each(function( index )
{
//put data-respond-width="size of children in pixels" to auto calculate the container size on respond
var t = $(this); var children_width = t.attr("data-respond-width");
t.css("width", "auto");
var width = t.width(); var perrow = Math.floor(width/children_width);
t.css("width", perrow*children_width + "px");
});
if ( $("#returntop").length > 0 )
{
var bbh = $("#bluebar").height() + 10; //console.log(bbh);
$("#returntop").css("top", bbh + "px");
}
}
function respond()
{
globalRespond();
}
$( window ).resize(function()
{
respond();
});
//var listener = new window.keypress.Listener();
//listener.simple_combo("`", function() {
// toggleNav();
//});
function toggleNav(s)
{
var el = $("#body_page");
//var l = el.offset().left; console.log(l);
//respond();
if ( s == undefined ) { }
if ( (el.attr("data-menu-offset")*1) !== 0 )
{
//console.log("run close");
//close
//$("#pagesection").css("margin-left", "80px");
//$("#promosection").css("margin-left", "580px");
el.attr("data-menu-offset", 0);
$("#logo").animate({top:"4px",left:"0px"}, 100);
$("#logo img").animate({height:"72px"}, 100);
$(".navmove").animate({left:"-=300px"}, 100, function()
{
//console.log("respond() from toggleNav menu is open line 182 app.js"); respond();
});
$("#bluebar").animate({height:"80px"}, 10);
$("#phrase").animate({"font-size":"1.4em", left:"60%", top:"26px"}, 100);
//$("#phrase .innerfx").css({"font-weight": "200", "color":"#fff;"});
}else{
if ( s !== 0 )
{
//console.log("run open");
//open
//$("#pagesection").css("margin-left", "580px");
//$("#promosection").css("margin-left", "1100px");
el.attr("data-menu-offset", 250);
$("#logo").animate({top:"4px",left:"0px"}, 100);
$("#logo img").animate({height:"72px"}, 100);
$(".navmove").animate({left:"+=300px"}, 100, function()
{
//console.log("respond() from toggleNav menu is closed line 204 app.js"); respond();
});
$("#bluebar").animate({height:"80px"}, 10);
$("#phrase").animate({"font-size":"1.4em", left:"60%", top:"26px"}, 100);
//$("#phrase .innerfx").css({"font-weight": "100", "color":"inherit"});
}
}
setTimeout('respond()', 100);
}
function getRandomInt (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function animatePhrase()
{
var mySplitText = new SplitText("#phrase", {type:"chars,words, lines"}),
tl = new TimelineLite();
TweenLite.set("#phrase", {css:{perspective:500, perspectiveOrigin:"50% 50%", transformStyle:"preserve-3d"}});
var numChars = mySplitText.chars.length;
for(var i = 0; i < numChars; i++){
tl.from(mySplitText.chars[i], 0.8, {css:{y:getRandomInt(-75, 75), x:getRandomInt(-150, 150), rotation:getRandomInt(0, 720), autoAlpha:0}, ease:Back.easeOut}, i * 0.02, "dropIn");
}
tl.staggerTo(mySplitText.chars, 4, {css:{transformOrigin:"50% 50% -30px", rotationY:-360, rotationX:360, rotation:360}, ease:Elastic.easeInOut}, 0.02, "+=1");
setTimeout(function()
{
animatePhrase();
}, 11000);
}
function animateCircles(s)
{
}
setTimeout(function()
{
animatePhrase();
}, 6000);
function splash(tt)
{
var transtime = 320;
var opacity = 1;
if ( tt == 0 )
{
transtime = 0;
opacity = 0;
}
if ( tt !== undefined )
{
transtime = tt;
}
//$("#inn_txt").fadeIn(transtime);
$("#inn_txt").animate({opacity:opacity}, transtime);
if ( $('html').data('hash') === 'home$' )
{
$("#splashimg").delay(transtime).fadeIn(transtime*5, function()
{
//empty callback
});
}
$("#orange_bar").delay(transtime*2).animate({right:"0px", opacity:opacity}, transtime, function()
{
$("#hosp_market_txt").animate({opacity:opacity}, transtime, function()
{
animateCircles( ((transtime/3)/1000) );
});
$("#splashimg").animate({left:"300px"}, transtime*2, function()
{
$("#inn_txt").delay(transtime*2).fadeOut(transtime/3, function()
{
$("#hosp_market_txt").delay(transtime*3).fadeOut(transtime/2);
$("#orange_bar").delay(transtime*3).fadeOut(transtime/1.5);
$("#whiteout").delay(transtime*3).fadeOut(transtime/6);
$("#bluebar").delay(transtime*5).fadeIn(transtime/1.25, function()
{
$("#logo").fadeIn(transtime/2);
$("#menu").animate({opacity:1}, transtime/2);
if ( $('html').data('hash') === 'home$' )
{
$("#bg_circles").fadeIn(transtime/2);
}
$("#phrase").fadeIn(transtime*3, function()
{
});
$("#trigger").unbind("click").click(function()
{
toggleNav();
});
$("#logo").unbind("click").click(function()
{
if ( $('html').data('hash') == "showcase$" )
{
window.open("http://welinternational.com", "_self");
}else{
window.open("#showcase$", "_self");
}
//window.history.back();
//toggleNav(1);
});
});
$("#splashimg").delay(transtime*2).fadeOut(transtime*2, function()
{
$("#page").fadeIn(transtime);
if ( $('html').data('hash') === 'home$' ) { $("#mainscreen").fadeIn(300); }
});
});
});
});
}
function showNotice()
{
$('#loadingDiv').fadeIn(5000);
}
function hideNotice()
{
$('#loadingDiv').stop().fadeOut(50);
}
//loader
$('#loadingDiv')
.hide() // hide it initially
.ajaxStart(function() {
showNotice();
})
.ajaxSuccess(function() {
hideNotice();
})
.ajaxError(function() {
showNotice();
})
;
var default_page = "#showcase$";
$("#relaunchapp").click(function(){
window.open(default_page, "_self");
});
function addCache()
{
return '&cache=' + Math.ceil(Math.random()*9000000000000) ;
}
function readHash() {
//get location.href
var loc = decodeURI(window.location.href) + '';
var hashcheck = loc.indexOf("#");
//if we don't have a hash
if (hashcheck < 0)
{
//send to homepage
window.open(default_page, '_self');
}else{
//look for && as dblhash
var dblcheck = loc.indexOf("&&");
//if it we don't have a dblhash
if (dblcheck < 0)
{
//we don't have a double hash
var hash = (loc).split('#');
hash = hash[1];
var curhash = $('html').data('hash'); //get current hash
//dblhash
var dblhash = null;
var curdblhash = $('html').data('dblhash'); //get current dblhash
//page viewdesign
if ( dblhash == null && curdblhash == "zoom" )
{
pgLoad.closePan();
$('html').data('dblhash', '');
}
}else{
//we have a double hash
var loc = (loc).split('&&');
var hash = (loc[0]).split('#');
hash = hash[1];
var curhash = $('html').data('hash'); //get current hash
//dblhash
var dblhash = loc[1];
var curdblhash = $('html').data('dblhash'); //get current dblhash
}
//hash change
if (hash != curhash)
{
//update current hash
$('html').data('hash', hash);
//reset dblhash
$('html').data('dblhash', "none");
$("#mainscreen").fadeOut(0);
//animate
$("#body_page").fadeIn(100, function()
{
//update menu
$("#menu ul li a").each(function(index, element)
{
$(this).siblings("span.circle").css("background-color", "")
var thishref = $(this).attr("href");
var thislength = hash.length + 1;
//console.log( thishref.slice(1,thislength) + ' == ' + hash );
if ( thishref.slice(1,thislength) == hash )
{
$(this).siblings("span.circle").css("background-color", "#1868a5");
}
});
//replace for load
hash = hash.split('-').join('/');
hash = hash.replace("$", ".php?");
//$("#container").css("min-width", "");
//set core recolor attr
//$("#page-core").attr("data-recolor", "");
//$("#container_body").css("height", "0px");
//$("#page").fadeOut(800);
$("#page").load("pages/"+hash, function()
{
//run pagecall function after load
//window.pagecall.instance();
//$("#container_body").css("height", "auto");
$("#body_page").fadeIn(500, function(){
//$(document).scrollTop(0);
//$("#page").fadeIn(800);
//$("#credits").fadeIn(800);
$('#user_panel').fadeOut(200);
$('#panel_content').html('');
});
});
});
}else if (dblhash != curdblhash && dblhash != null)
{
//make a change to the loaded hash page of dblhash content
//update current hash
$('html').data('dblhash', dblhash);
var arr_dblhash = dblhash.split("_");
$("#" + arr_dblhash[0]).load("jax/" + arr_dblhash[0] + ".php?ID=" + arr_dblhash[1] + "&" + Math.random());
}
}
setTimeout('readHash()',500); //half seconds
}
$(document).ready(function() {
//hash settngs
$('html').data('hash', "");
$('html').data('dblhash', "");
readHash();
//globalRespond();
$(".container-top-logo img").click(function()
{
window.open('#home$', '_self');
});
$(document).on('dragstart','img', function(event) {
//console.log('dragstart');
return false;
});
//$("body").delay(200).fadeIn(200);
if ( window.location.hostname !== 'wel.showroom.one')
{
$("#logo").remove();
$("title").text("Custom Carpet");
$("#phrase").text("Customize your carpet today!").css("color", "#555");
$("#bluebar").css("background-color", "rgba(255,255,255,.8)");
$("#trigger div.ham").css("background-color", "#ccc");
console.log('private label mode');
}
});
//no select
function disableSelect(th){
th.css("-webkit-touch-callout", "none")
.css("-moz-user-select", "none")
.css("-webkit-user-select", "none")
.css("-khtml-user-select", "none")
.css("-o-user-select", "none")
.css("user-select", "none")
.css("-webkit-user-drag", "none");
}
disableSelect($("*"));
function enableSelect(th){
th.css("-webkit-touch-callout", "default")
.css("-moz-user-select", "text")
.css("-webkit-user-select", "text")
.css("-khtml-user-select", "text")
.css("-o-user-select", "text")
.css("user-select", "text")
.css("-webkit-user-drag", "text");
}
//hover function
$("html").on("mouseenter", ".hand", function() {
$(this).css( 'cursor', 'pointer' );
});
//for homepage
$("html").data("loadedrotator", 0);
//function to show simple dialog
function simpleDialog(msg, dur, w, h)
{
$("#modals").append('
' + msg + '
');
$("#modal_simple").dialog({
dialogClass: 'noTitleStuff',
width:w,
height:h,
modal: false,
resizable: false,
open: function(event, ui) {
$("#modal_simple").css("background-color", "#fff");
$(this).parent().css("position", "fixed");
$(this).parent().css("top", ($(window).height() - $(this).outerHeight()) / 2 + "px");
$(this).parent().css("left", ($(window).width() - $(this).outerWidth()) / 2 + "px");
var th = $(this);
//close modal
setTimeout(function() {
$(th).parent().fadeOut(900, function() { $(th).remove(); } );
}, dur);
},
close: function(event, ui) {
$(this).remove();
}
});
}
//full dialog
function fullDialog(id, src, w, h)
{
$("#modals").append('');
$("#" + id).load(src + "?" + Math.random());
$("#" + id).dialog({
dialogClass: 'noTitleStuff',
width:w,
height:h,
modal: true,
resizable: true,
open: function(event, ui) {
$("#modal_full").css("background-color", "#fff");
$(this).parent().css("position", "fixed");
$(this).parent().css("top", ($(window).height() - $(this).outerHeight()) / 2 + "px");
$(this).parent().css("left", ($(window).width() - $(this).outerWidth()) / 2 + "px");
},
close: function(event, ui) {
$(this).remove();
}
});
}
function loadPanel(src)
{
$('#panel_content').load(src, function(){
//changeZoomLevel(1040); //didn't seem to work
//$(this).parent().fadeIn(300);
$("#user_panel").show().animate({
height: 300,
/*width: '100%',*/
opacity: 1,
marginBottom: '0px'
}, 1200, function() {
//nothing
});
});
}
function loadIMG(elementID, imgURL, callback)
{
//override src tag to display loading
//$(elementID).attr("src", "html_imgs/img_pixel_loader.gif");
$(elementID).parent().prepend('').animate({ scrollTop: "0px" }, 0);
var img = new Image();
var imgsrc = imgURL + addCache();
img.src = imgsrc;
img.onload = function()
{
//clearTimeout(timeout);
//set target src
$(elementID).attr("src", img.src);
//remove loader
$(elementID).siblings('div.imgloader').fadeOut(600, function(){ $(this).remove(); });
//run callback
if ( typeof(callback) === "function" )
{
$(elementID).fadeOut(0, function(){
callback(img);
$(elementID).fadeIn(1200);
});
}
}
img.onError = function()
{
//do something
}
/*var timeout = setTimeout(function(){
if ( $(elementID).attr("src") != imgsrc )
{
console.log(elementID + " failed to load " + imgsrc + " in time");
//console.log($(elementID).attr("src") + " match " + timeout_src);
//loadIMG(elementID, imgURL, callback);
}
}, 6500);
*/
}
//view design
function loadDesignViewer(simID, showColors, DPI, Width, Height, Type_REF, Base)
{
if ( typeof showColors === "undefined" )
{
showColors = false;
}
if ( typeof Base === "undefined" )
{
Base = 'cutpile';
}
//commons/sim_tiled.php?simID=67&scale=25&w=830&h=400
//product_image.php?simID=" + simID + "&r=830&d=830x400&s=single&base=" + Base
loadIMG("#defaultpimg", "commons/sim_tiled.php?simID=" + simID + "&scale=25&w=830&h=600", function(img){
//callback
if ( showColors )
{
$("#options").load('commons/load_recolor_screen.php?simID=' + simID + addCache(), function(){
//show
$("#options").slideDown(800, "easeInOutQuart");
});
}
//get width
var w = 830;//820-img.width;
$("#sceneholder").css("width", w + "px");
// was "/product_image.php?simID=" + simID + "&r=100&d=" + w + "x195"
if ( Type_REF.indexOf("@2@") >= 0 ) //Type 2 was Corridor on 06-04-2017
{
//if ( Width > 36 )
//{
var sceneID = 5; //corridor
//}else{
// var sceneID = 2; //border
//}
}else if ( Type_REF.indexOf("@5@") >= 0 ){
var sceneID = 5; //arearug
}else if ( Type_REF.indexOf("@4@") >= 0 ){
var sceneID = 5; //publc
}else {
var sceneID = 5; //guestroom
}
//override for last chosen scene
if ( $("#viewdesign").attr("data-scene") != 0 )
{
sceneID = $("#viewdesign").attr("data-scene");
}
//load scene
loadIMG("#sceneimg", "commons/getscene_image.php?s=" + sceneID + "&r=" + simID + "&w=" + 3000 + "&h=400", function(){
$("#sceneimg").css("width", "100%");
$.easing.def = "easeOutQuart";
//$('#sceneholder').delay(1600).animate({ scrollTop: "830px" }, 900);
//$('#mCSB_1_container').delay(1000).animate({ position: "relative", top: "-260px", left: "0px" }, 900);
//callback
loadPan(simID, DPI, Width, Height, w, Base);
});
});
//load each image at once
}
function loadScene(sceneID, simID)
{
//select scene in attr of #viewdesign for same scene on recolor
$("#viewdesign").attr("data-scene", sceneID);
//load scene
loadIMG("#sceneimg", "/commons/getscene_image.php?s=" + sceneID + "&r=" + simID + "&w=" + 3000 + "&h=195", function(){
$("#sceneimg").css("width", "100%");
$.easing.def = "easeOutQuart";
var parent = $('#sceneimg').parent();
if ( parent.attr("id") == 'sceneholder' )
{
var scoll_pos = 140;
}else{
var scoll_pos = 300;
}
$('#sceneimg').parent().delay(400).animate({ scrollTop: scoll_pos + "px" }, 900);
});
}
function loadPan(simID, DPI, Width, Height, view_w, Base){
z = 1.4; //fized zoom
if ( typeof Base === "undefined" )
{
Base = 'cutpile';
}
//destroy previous draggable event
if ( $('#pan').is('.ui-draggable') )
{
$('#pan').draggable("destroy");
}
$('#pan').html('').parent().prepend('');
//set load_default_img w h
var w_w = view_w;
var w_h = 195;
//$("#zoomimg").css({"width":w_w});
//$("#zoomimg").css({"height":w_h});
//calc tile
w = Math.round( Math.floor(Width*DPI) / z );
h = Math.round( Math.floor(Height*DPI) / z );
$(function(){
window.t2 = new bgViewer(
$('#pan'),
'/product_image.php?simID=' + simID + '&s=true&r=8000&base=cutpile&.jpg',
5
);
});
$("#pan").siblings('div.imgloader').fadeOut(600, function(){ $(this).remove(); /*$('#mCSB_1_container').delay(300).animate({ position: "relative", top: "-260px", left: "0px" }, 3000);*/ });
}
/*
==========================================================================
_prototypes Functions
==========================================================================
*/
function changeZoomLevel(w) { //was trying to change zoom level back out after login
//http://stackoverflow.com/questions/5574189/is-is-possible-to-change-page-zoom-in-mobile-safari-via-javascript
/* NOT working
var sViewport = '';
var jViewport = $('meta[name="viewport"]');
if (jViewport.length > 0) {
jViewport.replaceWith(sViewport);
} else {
$('head').append(sViewport);
}
*/
}
function _up()
{
$(window).scrollTop(0);
}
function _setfocus(id)
{
setTimeout(function()
{
$('#' + id).focus();
}, 200);
}
function _exist(el)
{
return $(el).length;
}
//create a cookie
function createCookie(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=/; domain=" + _APP_cookie_domain;
}
/*
==========================================================================
User Functions
==========================================================================
*/
function logout()
{
if (window.localStorage)
{
var uid = localStorage.getItem("UID");
}else{
var uid = 0;
}
window.open('/logout.php?u='+$('#account_panel').data('data-userid')+'&uid='+uid, '_self');
}
function isUserReal(e)
{
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
if ( e.length > 2 && emailPattern.test(e) ) {
//if valid user exist in database
//send email to server for true or false responce
$.get("/commons/checkEmail.php?e=" + e, function( data ) //had difficulty getting data out of event
{
if ( data > 0 )
{
promptPassword();
}else{
createAccount();
}
});
}else{
setText('#login h3', "Email address is not yet a valid format");
clearPassword();
clearCreateAccount();
}
}
function loadSignin(el, html_load)
{
$('#' + el).html(html_load);
_up();
_setfocus('user_email');
$('#user_email').keyup(function()
{
var e = $(this).val();
if ( e.length > 3 )
{
isUserReal(e);
}
});
}
function setText(el, msg)
{
$(el).text(msg).stop().animate({opacity:0},400,"linear",function(){
$(this).animate({opacity:1},600);
});
}
function promptPassword()
{
if ( $('#user_pass').length == 0 )
{
setText('#login h3', "Account found please provide the password");
//prompt for password
$("#login").append('
Password
Login
Reset my password
');
_setfocus('user_pass');
$('#user_pass').keypress(function(event)
{
if (event.keyCode == 13) {
usercheck();
}
});
}
clearCreateAccount();
}
function pwReset()
{
//post
$.post("modals/send_passwordreset.php", {
email: $("#user_email").val()
},
function(data) {
if (data)
{
setText('#login h3', "Check your email for new password");
}
}
);
}
function clearPassword()
{
if ( $('#user_pass').length != 0 )
{
//clear it
$("#login #user_pass_content").remove();
}
}
function usercheck()
{
var e = $("#user_email").val();
var pw = $("#user_pass").val();
var errors = [];
var ready = [];
//password
if ( pw.length < 8 ) {
errors.push("user_pass");;
}else{
ready.push("user_pass");
}
if ( errors.length > 0 )
{
for(i=0; i 0 )
{
for(i=0; i -1 )
{
user = data.split(":");
userLogin(user[0], user[1], 400);
}else{
setText('#login h3', "Password does not match");
}
}
);
}
}
function login()
{
loadPanel('/modals/login.php');
}
function reloadSignIn()
{
loadPanel('/modals/get_pdf.php');
}
function registerAccount()
{
var errors = [];
var ready = [];
//firstname check
if ( $("#first_name").val().length < 2 ) {
errors.push("first_name");
}else{
ready.push("first_name");
}
//lastname check
if ( $("#last_name").val().length < 2 ) {
errors.push("last_name");;
}else{
ready.push("last_name");
}
//company check
if ( $("#company_name").val().length < 2 ) {
errors.push("company_name");;
}else{
ready.push("company_name");
}
//phone check
if ( $("#phone_number").val().length < 10 ) {
errors.push("phone_number");;
}else{
ready.push("phone_number");
}
//zip code
if ( $("#zip_code").val().length < 5 ) {
errors.push("zip_code");;
}else{
ready.push("zip_code");
}
//console.log($("#account_type").val());
//account_type
if ( $("#account_type").val() < 1 ) {
errors.push("account_type");;
}else{
ready.push("account_type");
}
//password
if ( $("#user_pass").val().length < 8 ) {
errors.push("user_pass");;
}else{
ready.push("user_pass");
}
if ( errors.length > 0 )
{
for(i=0; i 0 )
{
for(i=0; i\
\
\
\
First Name
\
\
\
\
\
Last Name
\
\
\
\
\
\
\
Company Name
\
\
\
\
\
Phone Number
\
\
\
\
\
Zip Code
\
\
\
\
\
\
\
Account Type
\
' + select + '
\
\
\
\
\
\
Password (minimum of 8 characters)
\
\
\
\
\
\
\
Remember your password if you forget it you will need to reset it. We cannot provide passwords as they are encrypted to us always. Your privacy is a top priority for us. Your information will not sold or disclosed. Account status is subject to approval and access can be denied for any reason at any time.\
\
\
\
\
\
\
\
';
//---------------------------
_setfocus('first_name');
$('#login').html(html_load);
//}); //should create select variable
}
function createAccount()
{
//prompt to create new account
//we need
//email, password, company name, phone number, and zip code
clearPassword()
if ( $('#user_create_content').length == 0 )
{
setText('#login h3', "That email address is not recognized");
$("#login").append('');
//_setfocus('create_account_btn');
}
}
function clearCreateAccount()
{
$("#login #user_create_content").remove();
}
function closeUserPanel()
{
//changeZoomLevel(1000); //not working
$("#user_panel").animate({
height: "0px",
/*width: '0px',*/
opacity: 1,
marginBottom: '0px'
}, 0, function() {
$("#user_panel #panel_content").html('');
$("#user_panel").hide();
//_setfocus("search_box"); //trying to zoom out
});
}
function autoLogin()
{
if (window.localStorage){
//create a local storage method of the user
var uid = localStorage.getItem("UID"); //saves to the database, key/value
var autologin = localStorage.getItem("autologin");
if ( uid !== null && autologin !== null )
{
//fire post
$.post("modals/autologin.php", {
uid: uid,
autologin: autologin
},
function(data) {
if ( data.indexOf(":") > -1 )
{
user = data.split(":");
userLogin(user[0], user[1], 400);
}else{
//do nothing graceful fail
}
}
);
}
}
}
//initial run
autoLogin();
function userLogin(UID, userID, days)
{
//establish a new login
if (window.localStorage){
//create a local storage method of the user
localStorage.setItem("UID", UID); //saves to the database, key/value
localStorage.setItem("autologin", userID);
}else{
createCookie("UID", UID, days);
}
closeUserPanel();
$("#account_panel").html('