var ajsm_jquery;
// Help functions
// loads jquery
function ajSEM_LoadScript(type, sScriptSrc, oCallback) {
var head = document.getElementsByTagName("head")[0] || document.documentElement;
var oScript = document.createElement(type);
oScript.type = 'text/javascript';
oScript.src = sScriptSrc;
if (typeof(oCallback) == "function") {
var done = false;
oScript.onload = oScript.onreadystatechange = function() {
if ( !done && (!this.readyState ||
this.readyState === "loaded" || this.readyState === "complete") ) {
done = true;
oCallback();
// Handle memory leak in IE
oScript.onload = oScript.onreadystatechange = null;
}
}
}
head.insertBefore(oScript, head.firstChild);
}
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function ajToggleBar()
{
if (ajsm_jquery('div.ajBar div.mainBar').is(':visible'))
{
ajsm_jquery("div.ajBar div.barHidden").show();
ajsm_jquery("div.ajBar div.mainBar").animate({
bottom: -30
}, 750, function() {ajsm_jquery(this).hide();} );
ajsm_jquery("div.ajBar div.barHidden").animate({
bottom: 0
}, 750 );
ajsm_jquery.cookie('ajBarHidden', '1');
}
else
{
ajsm_jquery("div.ajBar div.mainBar").show();
ajsm_jquery("div.ajBar div.mainBar").animate({
bottom: 0
}, 750 );
ajsm_jquery("div.ajBar div.barHidden").animate({
bottom: -30
}, 750, function() {ajsm_jquery(this).hide();} );
ajsm_jquery.cookie('ajBarHidden', '0');
}
}
function ajBarToggleElem(elm, bottomPos)
{
if (ajsm_jquery(elm).is(':visible'))
{
ajsm_jquery(elm).animate({
bottom: -650
}, 750, function() {
ajsm_jquery(this).hide();
ajsm_jquery(this).find('iframe').attr('src','');
});
}
else
{
ajsm_jquery(elm).show();
ajsm_jquery(elm).animate({
bottom: bottomPos
}, 750 );
}
}
// **** END HELPER FUNCTIOn ***
function ajSM_LoadOthercripts()
{
ajSEM_LoadScript('script','//www.autojini.com/jScripts/jquery/jquery.cookie.js');
ajSEM_LoadScript('script','//www.autojini.com/jScripts/jquery/tipsy/jquery.tipsy.js', ajSEM_ajaxBarHTML);
}
// once jquery is loaded do our call..
function ajSEM_jQueryLoaded()
{
ajsm_jquery= jQuery.noConflict();
ajsm_jquery('head').append('');
ajsm_jquery('head').append('');
ajsm_jquery('head').append('');
ajSM_LoadOthercripts();
}
function ajSEM_ajaxBarHTML()
{
ajsm_jquery.ajax({
type: 'GET',
url: '//www.autojini.com/guest/bar/barHTML.cfm?dealerID=50074',
timeout: 80000,
dataType: 'jsonp',
error: function (XMLHttpRequest, textStatus, errorThrown) {
console.log(errorThrown);
},
success: function(html){
// append the html
//ajsm_jquery('div#ajSEMBar').html(html);
document.getElementById("ajSEMBar").innerHTML = html;
// attach our events
barHTMLLoaded();
}});
}
// attach our events
function barHTMLLoaded() {
if (parseInt(ajsm_jquery.cookie('ajBarHidden')) == 0 || ajsm_jquery.cookie('ajBarHidden') == null)
{
ajToggleBar();
}
else
{
ajsm_jquery("div.ajBar div.barHidden").show();
ajsm_jquery("div.ajBar div.mainBar").css("bottom", '-30px');
ajsm_jquery("div.ajBar div.barHidden").animate({
bottom: 0
}, 750 );
}
ajsm_jquery("[rel=tooltip]").tipsy({fade: true, gravity: ajsm_jquery.fn.tipsy.autoNS});
ajsm_jquery('div.ajBar > div > div.fl, div.ajBar > div > div.fr').mouseover(function() {
ajsm_jquery(this).addClass('hover');
});
ajsm_jquery('div.ajBar > div > div.fl, div.ajBar > div > div.fr').mouseout(function() {
ajsm_jquery(this).removeClass('hover');
});
ajsm_jquery('div.ajBar div div.fr.showHide').click(function(){
ajToggleBar();
});
ajsm_jquery('div[data-url]').click(function(){
if (ajsm_jquery('div.ajDataDiv').is(':visible')) {
ajBarToggleElem('div.ajDataDiv');
}
var title = ajsm_jquery(this).attr('data-original-title');
var iframeUrl = ajsm_jquery(this).attr('data-url');
iframeUrl = iframeUrl.replace('{ADDRESS}', encodeURIComponent(location.href));
iframeUrl = iframeUrl.replace('{TITLE}', encodeURIComponent(document.title));
var origUrl = ajsm_jquery('div#ajContentwindow > .ajBarWindowContent > iframe').attr('src');
if (iframeUrl != origUrl) {
if (ajsm_jquery(this).hasClass('fl'))
{
ajsm_jquery('div#ajContentwindow').css("left", '40px');
ajsm_jquery('div#ajContentwindow').css("right", 'auto');
}
if (ajsm_jquery(this).hasClass('fr'))
{
ajsm_jquery('div#ajContentwindow').css("right", '40px');
ajsm_jquery('div#ajContentwindow').css("left", 'auto');
}
ajsm_jquery('div#ajContentwindow > div.ajBarWindowTitle > div.title').html(title);
ajsm_jquery('div#ajContentwindow > .ajBarWindowContent > iframe').attr('src', iframeUrl);
if (ajsm_jquery('div#ajContentwindow').is(':hidden')) {
ajBarToggleElem('div#ajContentwindow', 44);
}
} else if (ajsm_jquery('div#ajContentwindow').is(':visible')) {
ajBarToggleElem('div#ajContentwindow', -1500);
}
});
ajsm_jquery('div[data-urlNewWindow]').click(function(){
var windowName = 'ajBarWindow';
var url = ajsm_jquery(this).attr('data-urlNewWindow');
url = url.replace('{ADDRESS}', encodeURIComponent(location.href));
url = url.replace('{TITLE}', encodeURIComponent(document.title));
var width = ajsm_jquery(this).attr('data-div-width');
var height = ajsm_jquery(this).attr('data-div-height');
var w = width;
var h = height;
var s = 1;
var x = 100;
var y = 150;
var winX = (document.all) ? window.screenLeft : window.screenX;
var winY = (document.all) ? window.screenTop : window.screenY;
var currentWindowWidth = ajsm_jquery(window).width();
var currentWindowHeight = ajsm_jquery(window).height();
var newWindowX = (winX + (currentWindowWidth / 2)) - (w / 2);
var newWindowY = (winY + (currentWindowHeight / 2)) - (h / 2);
options = "top=" + newWindowY + ",left=" + newWindowX + ",directories=0,toolbar=0,status=0,menubar=0,scrollbars="+ s +",resizable=1,width=" + w +",height=" + h;
dataUrlPopup = window.open(url,windowName,options);
if (dataUrlPopup.opener == null)
dataUrlPopup.opener = self;
dataUrlPopup.focus();
});
ajsm_jquery('div[data-div]').click(function(){
if (ajsm_jquery('div#ajContentwindow').is(':visible')) {
ajBarToggleElem('div#ajContentwindow');
}
if (ajsm_jquery('div.ajDataDiv').is(':visible') && ajsm_jquery('div.ajDataDiv:visible').attr('id') != ajsm_jquery(this).attr('data-div')) {
ajBarToggleElem('div#' + ajsm_jquery('div.ajDataDiv:visible').attr('id'));
}
var title = ajsm_jquery(this).attr('data-original-title');
var width = ajsm_jquery(this).attr('data-div-width');
var height = ajsm_jquery(this).attr('data-div-height');
var div = '#' + ajsm_jquery(this).attr('data-div');
var leftPosition = ajsm_jquery(this).offset().left;
var rightPosition = (ajsm_jquery(window).width() - (ajsm_jquery(this).offset().left + ajsm_jquery(this).outerWidth()));
ajsm_jquery(div).css("width", width);
ajsm_jquery(div).css("height", height);
if (ajsm_jquery(div).is(':hidden')) {
if (ajsm_jquery(this).hasClass('fl'))
{
ajsm_jquery(div).css("left", leftPosition);
ajsm_jquery(div).css("right", 'auto');
}
if (ajsm_jquery(this).hasClass('fr'))
{
ajsm_jquery(div).css("right", rightPosition);
ajsm_jquery(div).css("left", 'auto');
}
ajsm_jquery(div + '> div > div.title').html(title);
ajBarToggleElem(div, 32);
}
else
{
ajBarToggleElem(div, -1500);
}
});
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
};
//Actuall starting point... to load the jquery
if (typeof(jQuery) == "undefined")
{
ajSEM_LoadScript('script','https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', ajSEM_jQueryLoaded);
}
else
{
ajSEM_jQueryLoaded();
}
function add_pinit_marklet() {
var e=document.createElement('script');
e.setAttribute('type','text/javascript');
e.setAttribute('charset','UTF-8');
e.setAttribute('src','//assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);
document.body.appendChild(e);
}