$(function() { /* * C-Unit 2011-11-25 Start * #5417,#6163,#6263 * 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(ssl == '0') { url=document.location.href; if(url.substring(0,5) == "https") { urlssl ="http" + url.substring(5); document.location.href = urlssl; } } /* * 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 = path_system_user + 'siteuser/' + 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; } if (search_flag == ""){ $.ajax({ async:true, url:url, success:function(data, status) { if(cms_tag == 'itemview'){ if(loadSearchResult() == false){ $(target) .html(data) .show() ; } }else{ $(target) .html(data) .show() ; } try { initGoogleMapContent(); acco(); } catch (ex) {} setIframeHeight(0); }, failure:function(data, status) { } }); } }); // 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 */ var thisLastHash = 'category=&keyword=&page_custom=1'; 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_', ''); // 2011/08/03 C-UNIT Edit start var url = path_system + 'site/' + cms_tag + '/id_site/' + id_site + '/id/' + id_contents; if (user_id != '') { url = path_system_user + 'siteuser/' + cms_tag + '/id_site/' + id_site + '/id/' + id_contents + '/user_id/' + user_id; } // 2011/08/03 C-UNIT Edit End 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 =""; } // Add serching params into browser url setLocationUrl(str_category, str_keyword, pageNumber); int_page_custom = pageNumber; // 2011/08/03 C-UNIT add end // Send AJAX request to server for getting data $.post(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(); onLoad(); acco(); } catch (ex) {} setIframeHeight(0); } ); window.scrollTo(0,0); } else { return true; } thisLastHash = 'category=' + str_category + '&keyword=' + str_keyword + '&page_custom=' + int_page_custom; new Paginator(window.location.href); // 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; } } 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(); } if($(document).height() > intContentHeight){ 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('/','')){ if(intContentHeight > 0){ topiFrames[i].style.height = intContentHeight + 'px'; topiFrames[i].scrolling = "no"; } } } } if(parentiFrames){ for (var i = parentiFrames.length - 1; i >= 0; i--){ if(topiFrames[i].src == window.location || topiFrames[i].src == window.location.pathname.replace('/','')){ if(intContentHeight > 0){ parentiFrames[i].style.height = intContentHeight + 'px'; topiFrames[i].scrolling = "no"; } } } } } else { allFrames = document.getElementsByTagName('iframe'); for (i=0; i < allFrames.length; i++){ intContentHeightAll = 0; var UrlIfame = allFrames[i].src; var UrlLocation = window.location + ''; var arrUrlDomainLocation = UrlLocation.split('/'); var arrUrlIfame = UrlIfame.split('/'); DomainLocation = arrUrlDomainLocation[2]; DomainIfame = arrUrlIfame[2]; if(DomainIfame == DomainLocation){ intContentHeightAll = allFrames[i].contentWindow.document.body.scrollHeight; if( intContentHeightAll > 0){ allFrames[i].height = allFrames[i].contentWindow.document.body.scrollHeight; //IE6, IE7 and Chrome allFrames[i].scrolling = "no"; } else { allFrames[i].height = "100%"; allFrames[i].scrolling = "no"; } } } } } catch(err) { } $(document).ready(function () { while(setHeightLoop < 400){ try { setTimeout('setIframeHeight(' + intContentHeight + ');', 100); } catch(err) { } setHeightLoop++; } }); } /**---------------------------------------------------------------------- * Load search result by url * * @return string * ----------------------------------------------------------------------*/ function loadSearchResult() { //var strQuery = window.location.search.substring(1); var arrUrl = window.location.href.split('#'); var blnValue = false; 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") { blnValue = true; strParamValue = arrParams[i].substring(arrParams[i].indexOf('=') + 1); $('[name=searchForm]').find( 'select[name="category"]' ).val(decodeURI(strParamValue)); } if (strParamName == "keyword") { blnValue = true; strParamValue = arrParams[i].substring(arrParams[i].indexOf('=') + 1); $('[name=searchForm]').find( 'input[name="keyword"]' ).val(decodeURI(strParamValue)); } if (strParamName == "page_custom") { blnValue = true; strPageNo = arrParams[i].substring(arrParams[i].indexOf('=') + 1); } } if (blnValue == true) { ajaxRequest(strPageNo, false, $('[name=searchForm]')); return true; } else { return false; } } return false; } /**---------------------------------------------------------------------- * Add serching params into browser url * * @return string * ----------------------------------------------------------------------*/ function setLocationUrl(strCategory, strKeyword, strPageCustom) { if(strCategory != '' || strKeyword != '' || strPageCustom != ''){ var arrUrl = window.location.href.split('#'); window.location.href = arrUrl[0] + '#category=' + encodeURI(strCategory) + '&keyword=' + strKeyword + '&page_custom=' + strPageCustom; } } /**---------------------------------------------------------------------- * Site Search * @return null * ----------------------------------------------------------------------*/ function submitSiteSearch(strUrl,objfrom) { var $form = objfrom, str_keyword = $form.find( 'input[name="keyword"]' ).val(); window.location.href = strUrl + '/keyword/' + str_keyword; } /**---------------------------------------------------------------------- * If you use link from dynamic list page to same dynamic list page with parameter, you will need this function. * @return null * ----------------------------------------------------------------------*/ function goToURL(strUrl) { window.location.replace(strUrl); }