$(function() { /* * C-Unit 2011-11-25 Start * #5417,#6163,#6115 * ssl => https */ //Check SSL if(ssl == 1) { url=document.location.href; if(url.substring(0,5) != "https") { urlssl ="https" + url.substring(4); document.location.href = urlssl; } if(path_system_user.substring(0,5) != "https") { path_system_user ="https" + path_system_user.substring(4); } if(domain_user.substring(0,5) != "https") { domain_user ="https" + domain_user.substring(4); } } if(ssl == '0') { url=document.location.href; if(url.substring(0,5) == "https") { urlssl ="http" + url.substring(5); document.location.href = urlssl; } } if(ssl == ''){ strLocation=document.location.href; if(strLocation.substring(0,5) == "https") { if(domain_user.substring(0,5) != "https") { domain_user ="https" + domain_user.substring(4); } } else { if(domain_user.substring(0,5) == "https") { domain_user ="http" + domain_user.substring(5); } } } /* * C-Unit 2011-11-25 End */ $('[class^=cms_replace]').each(function() { var target = this; var cms_tag = $(this).attr('class'); cms_tag = cms_tag.replace('cms_replace_', ''); var url = path_system + 'site/' + cms_tag + '/id_site/' + id_site + '/id/' + id_contents; // Re-generate URL value in case of user mode if (user_id != '') { url = 'site/' + cms_tag + '/id_site/' + id_site + '/id/' + id_contents + '/user_id/' + user_id; } if ('' != $(this).html()) { url += '/target/' + $(this).html(); } if ('itemview' == cms_tag) { url += '/id_dynamic/' + id_dynamic; } // Make AJAX request in URL data url += '/ajax_request/true'; var query = window.location.search.substring(1); if ('' != query) { url += '?' + query; } $.post( domain_user + '/getcontents.php', { url_content: url }, function( data ) { if(loadSearchResult() == false){ $(target) .html(data) .show() ; } try { initGoogleMapContent(); } catch (ex) {} } ); }); // submit form searchForm jQuery(document).ready(function(){ jQuery('form[name=searchForm]').submit(function () { ajaxRequest('1',true); return false; }); }); }); /** * Make ajax request and fill receive data into specified HTML control */ function ajaxRequest(pageNumber, isFormRequest, objfrom) { var objControl = $('[class^=cms_replace_itemview]'); if (objControl.length > 0) { objControl = objControl[0]; var cms_tag = $(objControl).attr('class'); cms_tag = cms_tag.replace('cms_replace_', ''); var url = 'site/' + cms_tag + '/id_site/' + id_site + '/id/' + id_contents; if ('itemview' == cms_tag) { url += '/id_dynamic/' + id_dynamic; } url += '/ajax_request/true'; var query = window.location.search.substring(1); if ('' != query) { url += '?' + query; } // Get paging information jQuery('#page_custom').val(pageNumber); if(typeof objfrom =="undefined") { objfrom = $('[name=searchForm]') } var $form = objfrom, str_search_flag = $form.find( 'input[name="search_flag"]' ).val(), str_keyword = $form.find( 'input[name="keyword"]' ).val(), str_category = $form.find( 'select[name="category"]' ).val(); if (typeof str_search_flag == "undefined") { str_search_flag = ""; } if(typeof str_keyword =="undefined") { str_keyword =""; } if(typeof str_category =="undefined") { str_category =""; } int_page_custom = pageNumber; // Send AJAX request to server for getting data $.post(domain_user + '/getcontents.php', { cms_tag: cms_tag, url_content: url, search_flag : str_search_flag, keyword : str_keyword, category : str_category, page_custom : int_page_custom }, function(data) { $(objControl) .html(data) .show() ; // Loading GoogleMap data try { initGoogleMapContent(); } catch (ex) {} setIframeHeight(0); } ); } else { return true; } // Return the result in case of ajax request from main form // If the ajax request is called from Hyperlink, this return value will cause an error if (isFormRequest == 'true') { return false; } } function ajaxgetcontents(action) { if (action == 'compare'){ var getstr = ''; obj = document.getElementById('iv_b'); var data = new Array(); $("input[name='record_select[]']:checked").each(function(i) { data += 'record_select[]=' +$(this).val()+ "&" ; }); var url = 'site/itemview?mode=compare&' + data; $.post( domain_user + '/getcontents.php', { url_content: url }, function( data ) { $('body') .html(data) .show() ; setIframeHeight(0); } ); } } var setHeightLoop = 0; /**---------------------------------------------------------------------- * Set Iframe height * @param int intContentHeight * @return * ----------------------------------------------------------------------*/ function callFunction(intContentHeight) { easyXDM.DomHelper.requiresJSON("../json2.js"); var remote = new easyXDM.Rpc(/** The channel configuration*/{ local: "../name.html", swf: "../easyxdm.swf", onReady: function(){ /** * Call a method on the other side */ remote.noOp_height(intContentHeight); } }, /** The configuration */ { remote: { noOp_height: {} }, local: { } }); } /**---------------------------------------------------------------------- * Set Iframe height * @param int intContentHeight * @return * ----------------------------------------------------------------------*/ function setIframeHeight(intContentHeight) { // Set specific variable to represent all iframe tags. try { // Set specific variable to represent all iframe tags. if(window.top != window.self){ var topiFrames = window.top.document.getElementsByTagName('iframe'); if(window.top != window.parent){ var parentiFrames = parent.document.getElementsByTagName('iframe'); } if(intContentHeight < 1){ if($("body").height() > 0){ intContentHeight = $("body").height(); } else{ intContentHeight = $(document).height(); } } // Iterate through all iframes in the page. if(topiFrames){ for (var i = topiFrames.length - 1; i >= 0; i--){ if(topiFrames[i].src == window.location || topiFrames[i].src == window.location.pathname.replace('/','')){ topiFrames[i].style.height = intContentHeight + 'px'; } } } if(parentiFrames){ for (var i = parentiFrames.length - 1; i >= 0; i--){ if(topiFrames[i].src == window.location || topiFrames[i].src == window.location.pathname.replace('/','')){ parentiFrames[i].style.height = intContentHeight + 'px'; } } } } } catch(err) { } while(setHeightLoop < 400){ setTimeout('setIframeHeight(' + intContentHeight + ');', 100); setHeightLoop++; } } /**---------------------------------------------------------------------- * Load search result by url * * @return string * ----------------------------------------------------------------------*/ function loadSearchResult() { //var strQuery = window.location.search.substring(1); var arrUrl = window.location.href.split('#'); if (arrUrl[1] && '' != arrUrl[1]) { var arrParams = arrUrl[1].split("&"); var arrParamItems = Array(); for (i = 0; i < arrParams.length; i++) { strParamName = arrParams[i].substring(0, arrParams[i].indexOf('=')); if (strParamName == "category") { strParamValue = arrParams[i].substring(arrParams[i].indexOf('=') + 1); $('[name=searchForm]').find( 'select[name="category"]' ).val(decodeURI(strParamValue)); } if (strParamName == "keyword") { strParamValue = arrParams[i].substring(arrParams[i].indexOf('=') + 1); $('[name=searchForm]').find( 'input[name="keyword"]' ).val(decodeURI(strParamValue)); } } ajaxRequest('1', false, $('[name=searchForm]')); return true; } return false; } /**---------------------------------------------------------------------- * Add serching params into browser url * * @return string * ----------------------------------------------------------------------*/ function setLocationUrl(strCategory, strKeyword) { if(strCategory != '' || strKeyword != ''){ var arrUrl = window.location.href.split('#'); window.location.href = arrUrl[0] + '#category=' + encodeURI(strCategory) + '&keyword=' + strKeyword; } }