var pp_pic_holder = null; var windowHeight = $(window).height(); var windowWidth = $(window).width(); var selected_vehicle_no = ''; $.fn.prettyPhoto( { markup: '
\
 
\
\
\
\
\
\
\
\
\
\
\
\
\
\ Previous \

0/0

\ Next \
\

\ {pp_social} \ Close \
\
\
\
\
\
\
\
\
\
\
\
\
\
', changepicturecallback: function() { pp_pic_holder = $('.pp_pic_holder'); center_overlay(); $(window).bind('scroll.prettyphoto',function(){ center_overlay(); }); if (selected_vehicle_no != '') { const url = new URL(location); history.replaceState('','',url.pathname+'?vehicle_no='+selected_vehicle_no); } }, callback: function() { $(window).unbind('scroll.prettyphoto'); const url = new URL(location); history.replaceState('','',url.pathname); }, } ); function center_overlay(){ if(doresize && pp_pic_holder!=null){ scroll_pos = get_scroll(); contentHeight=pp_pic_holder.height(); contentwidth=pp_pic_holder.width(); projectedTop=(windowHeight/2)+scroll_pos['scrollTop']-(contentHeight/2); if(projectedTop<0)projectedTop=0; if(contentHeight>windowHeight)return; pp_pic_holder.css({'top':projectedTop,'left':(windowWidth/2)+scroll_pos['scrollLeft']-(contentwidth/2)}); } } function get_scroll(){ if (self.pageYOffset) { return {scrollTop:self.pageYOffset,scrollLeft:self.pageXOffset}; } else if(document.documentElement&&document.documentElement.scrollTop) { return {scrollTop:document.documentElement.scrollTop,scrollLeft:document.documentElement.scrollLeft}; } else if (document.body) { return {scrollTop:document.body.scrollTop,scrollLeft:document.body.scrollLeft}; } } //---------------------------------------------------------------------- $(window).on('load', function() { $('.pp_overlay').css({opacity:0,height:$(document).height(),width:$(window).width()}); }); if (window.addEventListener) { window.addEventListener ("message", receiveSize, false); window.addEventListener ("resize", receiveCallAnchor, false); } else if (window.attachEvent) { window.attachEvent("onmessage", receiveSize); window.attachEvent("onresize", receiveCallAnchor); } var param = "sight_dir=&disp_mode=&limit=30"; function appoint_init(add_element) { const url = new URL(location); if (url.search.indexOf("clear") != "-1") { param += '&clear=1'; history.replaceState('','',url.pathname); } let sight_url = encodeURIComponent(url.href); param += '&url='+sight_url; var base_url = "https://newcartrade.jp/api/index.html?"+param; document.getElementById(add_element).innerHTML = ""; document.getElementById('id_prev').src = base_url; } function nicosoku_init(add_element) { const url = new URL(location); if (url.search.indexOf("clear") != "-1") { param += '&clear=1'; history.replaceState('','',url.pathname); } let sight_url = encodeURIComponent(url.href); param += '&url='+sight_url; var base_url = "https://newcartrade.jp/api/index_nicosoku.html?"+param; document.getElementById(add_element).innerHTML = ""; document.getElementById('id_prev').src = base_url; } function header_init(header_element) { const url = new URL(location); let sight_url = encodeURIComponent(url.origin+url.pathname); var base_url = "https://newcartrade.jp/api/header.html?sight_dir=&url="+sight_url; document.getElementById(header_element).innerHTML = ""; document.getElementById('header_iframe').src = base_url; } function header_sub_init(header_sub_element) { const url = new URL(location); let sight_url = encodeURIComponent(url.origin+url.pathname); var base_url = "https://newcartrade.jp/api/header_sub.html?sight_dir=&url="+sight_url; document.getElementById(header_sub_element).innerHTML = ""; document.getElementById('header_sub_iframe').src = base_url; } function footer_init(footer_element) { var base_url = "https://newcartrade.jp/api/footer.html?sight_dir="; document.getElementById(footer_element).innerHTML = ""; document.getElementById('footer_iframe').src = base_url; } function slider_init(slider_element) { const url = new URL(location); let sight_url = encodeURIComponent(url.origin+url.pathname); var base_url = "https://newcartrade.jp/api/slider.html?sight_dir=&show_num=5&max_num=10&cid=&url="+sight_url; document.getElementById(slider_element).innerHTML = ""; document.getElementById('slider_iframe').src = base_url; } //--------------------------------------------------------------------------------- function receiveCallAnchor(){ if (document.getElementById("id_prev")) { var response = "width:" + document.body.clientWidth; document.getElementById("id_prev").contentWindow.postMessage(response,"*"); document.getElementById("id_prev").contentWindow.postSize(); } if (document.getElementById("header_iframe")) { document.getElementById("header_iframe").contentWindow.postSize(); } if (document.getElementById("header_sub_iframe")) { document.getElementById("header_sub_iframe").contentWindow.postSize(); } if (document.getElementById("footer_iframe")) { document.getElementById("footer_iframe").contentWindow.postSize(); } if (document.getElementById("slider_iframe")) { var response = "width:" + document.body.clientWidth; document.getElementById("slider_iframe").contentWindow.postMessage(response,"*"); document.getElementById("slider_iframe").contentWindow.postSize(); } } function receiveSize(e) { var cStr = e.data; var sp = ""; var UA = navigator.userAgent; if ( (UA.indexOf('iPhone') !== -1)//iphone恋 || ((UA.indexOf('Android') !== -1) && (UA.indexOf('Mobile') !== -1)) || (UA.indexOf('Windows Phone') !== -1) || (UA.indexOf('BlackBerry') !== -1) || (UA.indexOf('iPad') !== -1) ) { sp = "1"; }; if( cStr.indexOf("list_frame_height") != "-1"){ var frame_height = cStr.replace("list_frame_height", ""); document.getElementById("id_prev").style.height = frame_height + "px"; var response = "width:" + document.body.clientWidth; document.getElementById("id_prev").contentWindow.postMessage(response,"*"); } if( cStr.indexOf("header_frame_height") != "-1"){ var frame_height = cStr.replace("header_frame_height", ""); document.getElementById("header_iframe").style.height = frame_height + "px"; } if( cStr.indexOf("header_sub_frame_height") != "-1"){ var frame_height = cStr.replace("header_sub_frame_height", ""); document.getElementById("header_sub_iframe").style.height = frame_height + "px"; } if( cStr.indexOf("footer_frame_height") != "-1"){ var frame_height = cStr.replace("footer_frame_height", ""); document.getElementById("footer_iframe").style.height = frame_height + "px"; } if( cStr.indexOf("slider_frame_height") != "-1"){ var frame_height = cStr.replace("slider_frame_height", ""); document.getElementById("slider_iframe").style.height = frame_height + "px"; var response = "width:" + document.body.clientWidth; document.getElementById("slider_iframe").contentWindow.postMessage(response,"*"); } //------------------------------------------------------------------------- if ( cStr.indexOf("search_popup") != "-1") { var search_param = cStr.replace("search_popup_", ""); var width = sp == 1 ? document.body.clientWidth - 40 : '900'; var height = window.innerHeight - 100; if (sp == 1) { height = height >= 450 ? 450: height; } selected_vehicle_no = ''; $.prettyPhoto.open('https://newcartrade.jp/api/search_popup.html'+search_param+'&iframe=true&width='+width+'&height='+height,'',''); } if ( cStr.indexOf("zaiko_popup") != "-1") { var width = sp == 1 ? document.body.clientWidth - 40 : '900'; var height = window.innerHeight - 100; if (sp == 1) { height = height >= 450 ? 450: height; } $.prettyPhoto.open('https://newcartrade.jp/api/zaiko_popup.html?iframe=true&width='+width+'&height='+height,'',''); } if ( cStr.indexOf("searched") != "-1") { var search_param = cStr.replace("searched_", ""); document.getElementById('id_prev').src = "https://newcartrade.jp/api/index.html?"+search_param; $.prettyPhoto.close(); } if ( cStr.indexOf("scroll_to_top") != "-1"){ this.scrollTo(0,0); } if( cStr.indexOf("vehicle_no") != "-1"){ var vehicle_no = cStr.replace("vehicle_no_", ""); // if( document.body.clientWidth < 1000 || sp == "1" ){ if( sp == "1" ){ var detail_url = "https://newcartrade.jp/api/sp_details.html?vehicle_no=" + vehicle_no + "&screen_width=" + document.body.clientWidth + "&pc=0"; location.href = detail_url; //window.open(detail_url, "_blank"); } else { if( document.body.clientWidth < 950 ) { var detail_url = "https://newcartrade.jp/api/details.html?vehicle_no=" + vehicle_no + "&screen_width=" + document.body.clientWidth + "&pc=1"; location.href = detail_url; //window.open(detail_url, "_blank"); } else { var date = new Date(); selected_vehicle_no = vehicle_no; const url = new URL(location); $.prettyPhoto.open('https://newcartrade.jp/api/details.html?vehicle_no=' + vehicle_no + '&screen_width=' + document.body.clientWidth +'&url='+url.origin+url.pathname + "&pc=1&v=" + date.getTime() + '&iframe=true&width=945&height='+(window.innerHeight - 100),'',''); } } } }