var ad_reload_time=180000;var single_baner_enabled=0;var two_baners_enabled=0;var single_baner="";var two_baners="";var mm_ad_context="";var mm_ad_contextType;function getMMAds(divId,limit,searchFor){try{var queryString="limit="+limit+"&searchFor="+searchFor;if(mm_ad_context!=""){queryString=queryString+"&context="+mm_ad_context+"&contextType="+mm_ad_contextType+"&divId="+divId+"&searchFor="+searchFor;}var url="/mmadsense/getMMAds?"+queryString;var xmlHttp=getXMLHTTP();if(xmlHttp){xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){if(divId=="div_mm_adsense"){document.getElementById("div_mm_adsense").innerHTML=xmlHttp.responseText;single_baner=setTimeout("getMMAds('div_mm_adsense',"+limit+","+searchFor+")",ad_reload_time);}else{category_Name=popUp_category_Name.replace("&","&amp;");if(mm_ad_context==category_Name){document.getElementById("mmaddSense2").innerHTML=xmlHttp.responseText;two_baners=setTimeout("getMMAds('mmaddSense2',"+limit+","+searchFor+")",ad_reload_time);}}}else{}}};xmlHttp.open("GET",url,true);xmlHttp.send(null);}}catch(err){}}function showAdds(divId,limit,searchFor){try{if(divId=="div_mm_adsense"){if(!single_baner_enabled){single_baner_enabled=1;}else{clearTimeout(single_baner);}getMMAds(divId,limit,searchFor);}else{if(!two_baners_enabled){two_baners_enabled=1;}else{clearTimeout(two_baners);}getMMAds(divId,limit,searchFor);}}catch(err){}}function saveVendorClicks(vendorId,vendorUrl){window.open(vendorUrl,"metromela");try{url="mmadsense/onMMAdClick?vendorId="+vendorId;var xmlHttp=getXMLHTTP();if(xmlHttp){xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){return true;if(xmlHttp.status==200){}}};xmlHttp.open("GET",url,true);xmlHttp.send(null);}}catch(err){}}function changeAdsStatusType(statusMode){for(var i=0;i<document.businessAdsForm.adsRadio.length;i++){if(document.businessAdsForm.adsRadio[i].checked){var adId=document.businessAdsForm.adsRadio[i].value;}}if(!document.businessAdsForm.adsRadio.length){var adId=document.getElementById("adsRadio").value;}if(adId){var adsType=document.getElementById("adsType_"+adId).value;var businessId=document.getElementById("businessId").value;var url="/changeAdsStatusType?statusMode="+statusMode+"&businessAdId="+adId+"&adsType="+adsType+"&businessId="+businessId;var xmlHttp=getXMLHTTP();if(xmlHttp){xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var response=xmlHttp.responseText;if(response==101){document.getElementById("adStatus_"+adId).innerHTML="Enabled";}else{if(response==102){document.getElementById("adStatus_"+adId).innerHTML="Saved as Draft";}else{if(response==103){document.getElementById("adStatus_"+adId).innerHTML="Disabled";}else{if(statusMode==104){document.getElementById("adStatus_"+adId).innerHTML="Download and Enable";document.getElementById("adsWidgetTd").innerHTML=response;var xypos=getPosition(document.getElementById("statusBar"));var xyposarray=xypos.split("|");var xpos=xyposarray[0];var ypos=xyposarray[1];document.getElementById("adsEmbedWidgetDiv").style.display="block";document.getElementById("adsWidgetTd").style.display="block";}}}}}}};xmlHttp.open("GET",url,true);xmlHttp.send(null);}}else{alert(select_radio);}}function showAdImage(){for(var i=0;i<document.businessAdsForm.adsCheckBox.length;i++){if(document.businessAdsForm.adsCheckBox[i].checked){var adId=document.businessAdsForm.adsCheckBox[i].value;}}if(adId){var adImageSize=document.getElementById("imageSizeDropDown").value;var businessId=document.getElementById("businessId").value;var url="/mmadsense/getBusinessAdImage?businessId="+businessId+"&bannerAdId="+adId+"adImgSize="+adImageSize;var xmlHttp=getXMLHTTP();if(xmlHttp){xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var response=xmlHttp.responseText;}}};xmlHttp.open("GET",url,true);xmlHttp.send(null);}}}function changeAdType(obj){var campaignId=document.getElementById("campaignId").value;var businessId=document.getElementById("businessId").value;if(document.getElementById("campaignId").value==0){alert("Please select campaign");for(var i=0;i<document.businessAdThemeForm.adsType.length;i++){document.businessAdThemeForm.adsType[i].checked=false;}document.getElementById("campaignId").focus();return false;}else{if(campaignId&&obj.value=="couponDownload"){var businessId=document.getElementById("businessId").value;var url="/adsTheme/"+businessId+"?campaignId="+campaignId+"&adType="+obj.value+"&from=adTheme";var xmlHttp=getXMLHTTP();if(xmlHttp){xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var response=xmlHttp.responseText;if(response==true){var url="/adsTheme/"+businessId+"?&adType="+obj.value;document.businessAdThemeForm.method="post";document.businessAdThemeForm.action=url;document.businessAdThemeForm.submit();}else{alert("No deal widget created for this campaign.");document.location.href=response;}}}};xmlHttp.open("GET",url,true);xmlHttp.send(null);}}else{if(obj.value){var url="/adsTheme/"+businessId+"?&adType="+obj.value;document.businessAdThemeForm.method="post";document.businessAdThemeForm.action=url;document.businessAdThemeForm.submit();}}}}function generateAdsIFrame(srvUrl,adType,businessAdId,obj,businessId){if(obj.value!="0"){document.getElementById("adIFrame").style.display="block";document.getElementById("adIFrame").innerHTML="&lt;iframe src ='http://"+srvUrl+"/adWidget/"+adType+"/"+businessAdId+"/"+obj.value+"/"+businessId+"?source=External&from=bannerAd' frameborder='0' scrolling='no' allowTransparency='true' height='100%' width='100%' &gt;&lt;/iframe&gt;";document.getElementById("noteText").innerHTML="Copy the above html and embed in the destination web pages.";document.getElementById("closebutton").style.display="block";}else{document.getElementById("adIFrame").innerHTML="";document.getElementById("noteText").innerHTML="";}}function hidePopUpIfExist(id){if(id){document.getElementById("adIFrame").innerHTML="";document.getElementById("noteText").innerHTML="";document.getElementById("adIFrame").style.display="none";document.getElementById("closebutton").style.display="none";}}function changeAdProperties(){if(document.getElementById("headline").value){document.getElementById("adHeadline").innerHTML=document.getElementById("headline").value;}if(document.getElementById("headlineColor").value||document.getElementById("headlineFontStyle").value){document.getElementById("adHeadline").style.color=document.getElementById("headlineColor").value;document.getElementById("adHeadline").style.fontFamily=document.getElementById("headlineFontStyle").value;}if(document.getElementById("description")){if(document.getElementById("description").value){document.getElementById("adDescription").innerHTML=document.getElementById("description").value;}}if(document.getElementById("descriptionColor")||document.getElementById("DescriptionFontStyle")){if(document.getElementById("descriptionColor").value||document.getElementById("DescriptionFontStyle").value){document.getElementById("adDescription").style.color=document.getElementById("descriptionColor").value;document.getElementById("adDescription").style.fontFamily=document.getElementById("DescriptionFontStyle").value;}}if(document.getElementById("displayUrl").value){document.getElementById("adsdisplayUrl").innerHTML=document.getElementById("displayUrl").value;document.getElementById("adsdisplayUrl").style.color=document.getElementById("displayUrlColor").value;}if(document.getElementById("backgroundColor").value){document.getElementById("dimensions").style.backgroundColor=document.getElementById("backgroundColor").value;}if(document.getElementById("destinationUrl").value){var hostUrl=document.getElementById("hostUrl").value;document.getElementById("adsdisplayUrl").href=hostUrl+document.getElementById("destinationUrl").value;}}function changeBannarAdsImage(){var picture=document.getElementById("picture");var imageWidth=document.getElementById("imageWidth").value;var imageHeight=document.getElementById("imageHeight").value;var bannerAdType=document.getElementById("bannerAdType").value;if(bannerAdType=="enquiryForm"){if(!imageWidth){imageWidth=188;}if(!imageHeight){imageHeight=52;}}else{if(!imageWidth){imageWidth=150;}if(!imageHeight){imageHeight=150;}}if(document.getElementById("adsPicture")){var defaultPicture=document.getElementById("adsPicture").src;}else{var defaultPicture=parent.document.getElementById("adsPicture").src;}if(document.getElementById("bannerAdType")){var bannerAdType=document.getElementById("bannerAdType").value;}else{var bannerAdType=parent.document.getElementById("bannerAdType").value;}if(document.getElementById("uploadedImage")){var uploadedImage=document.getElementById("uploadedImage").value;}else{var uploadedImage=parent.document.getElementById("uploadedImage").value;}if(document.getElementById("adImage")){document.getElementById("adImage").innerHTML="<img src='"+uploadedImage+"' id='ads_image'>";}else{parent.document.getElementById("adImage").innerHTML="<img src='"+uploadedImage+"' id='ads_image'>";}if(uploadedImage==""){document.getElementById("adImage").innerHTML="<img src='"+defaultPicture+"' id='ads_image'>";}var oElement=document.getElementById("adImage");if(window.getComputedStyle){originalWidth=window.getComputedStyle(oElement,null).width;originalHeight=window.getComputedStyle(oElement,null).height;var divHeight=originalHeight.split("px");}else{if(oElement.currentStyle){originalWidth=oElement.currentStyle.width;originalHeight=oElement.currentStyle.height;var divHeight=originalHeight.split("px");}}if(parseInt(imageWidth)>=parseInt(originalWidth)){document.getElementById("ads_image").style.width=originalWidth;var originalWidthSplit=originalWidth.split("px");var compressionWidth=(originalWidthSplit[0]/imageWidth)*100;var compressionHeight=(imageHeight/100)*compressionWidth;}if(compressionHeight==""||compressionHeight=="undefined"||compressionHeight=="null"){compressionHeight="0";}var originalHeightSplit=originalHeight.split("px");if(parseInt(compressionHeight)&&(parseInt(compressionHeight)>=parseInt(originalHeightSplit[0]))){document.getElementById("ads_image").style.height=originalHeight;var compressionHeight=(originalHeightSplit[0]/imageHeight)*100;var reCompressionWidth=(imageWidth/100)*compressionHeight;document.getElementById("ads_image").style.width=parseInt(reCompressionWidth)+"px";}else{if(parseInt(imageHeight)>=parseInt(divHeight[0])){document.getElementById("ads_image").style.height=divHeight[0];}}}function changePreview(templateName){var previewSize=document.getElementById("previewSize").value;var micrositeTemplateName=document.getElementById("micrositeTemplateName").value;var bannerAdType=document.getElementById("bannerAdType").value;var businessId=document.getElementById("businessId").value;var vendorPhoneNum=document.getElementById("vendorPhoneNum").value;var widgetId=document.getElementById("widgetId").value;var VENDOR_HOST=document.getElementById("VENDOR_HOST").value;if(bannerAdType=="enquiryForm"){document.getElementById("previewImage").innerHTML="<link rel='stylesheet' type='text/css' media='screen' href='http://"+VENDOR_HOST+"/bannarAdTemplates/"+templateName+"/css/style-"+previewSize+".css'><div class='enquiry_dimensions' id='dimensions'><div class='enquiry_ad_heading' id='adHeadline' name='adHeadline'></div><div class='enquiry_ad_content' id='adDescription' name='adDescription'><div style='width:249px;float:left;position:relative;'><div style='float:left;width:249px;position:absolute;left:0px;'><iframe src ='http://"+VENDOR_HOST+"/enquiryFormWidget/"+micrositeTemplateName+"/"+businessId+"?source=Microsite&from=bannerAd' frameborder='0' scrolling='no' width='100%;' height='100%' allowTransparency='true' name='enquiryWidgetIframe'></iframe></div></div></div><div class='enquiry_ad_img' id='adImage' name='adImage'><img src='/bannarAdTemplates/"+templateName+"/images/logo.png'/></div><div class='enquiry_ad_url'><a href='' id='adsdisplayUrl' name='adsdisplayUrl' target='_blank'>www.lanarrealtors.com</a></div></div>";}else{var previewImageCode="<link rel='stylesheet' type='text/css' media='screen' href='http://"+VENDOR_HOST+"/bannarAdTemplates/"+templateName+"/css/deal-"+previewSize+".css'><div class='dimensions' id='dimensions'><div class='ad_heading' id='adHeadline' name='adHeadline'></div><div class='ad_img' id='adImage' name='adImage'> <img src='/bannarAdTemplates/"+templateName+"/images/c2c-image.png'/> </div><div class='ad_content' id='adDescription' name='adDescription'></div><div class='ad_url'><a href='' id='adsdisplayUrl' name='adsdisplayUrl' target='_blank'></a></div><div class='ad_form'><div style='width:221px;height:170px;float:left;position:relative;'><div style='float:left;width:221px;position:absolute;left:0px;'>";if(bannerAdType=="click2call"){previewImageCode+="<iframe src ='http://"+VENDOR_HOST+"/click2callWidget/"+micrositeTemplateName+"/"+businessId+"/"+vendorPhoneNum+"?source=Microsite&from=bannerAd&adSize="+previewSize+"' frameborder='0' scrolling='no' width='100%;' height='100%' allowTransparency='true' name='click2CallIframe' ></iframe></div></div></div></div>";}else{if(bannerAdType=="couponDownload"){previewImageCode+="<iframe src='http://"+VENDOR_HOST+"/click2dealWidget/"+micrositeTemplateName+"/"+businessId+"/"+widgetId+"?source=Microsite&from=bannerAd&adSize="+previewSize+"' frameborder='0' scrolling='no' width='100%' height='100%' allowTransparency='true' name='dealWidgetIframe'></iframe></div></div></div></div>";}}document.getElementById("previewImage").innerHTML=previewImageCode;}changeAdProperties();changeBannarAdsImage();}function saveBannarAdDetails(mode){if(!document.getElementById("adName").value){alert("Please enter Ad Name.");document.getElementById("adName").focus();return false;}if(document.getElementById("campaignId").value=="0"){alert("Please select a campaign.");document.getElementById("campaignId").focus();return false;}if(!document.getElementById("displayUrl").value){alert("Please enter Display URL.");document.getElementById("displayUrl").focus();return false;}if(!document.getElementById("destinationUrl").value){alert("Please enter Destination URL.");document.getElementById("destinationUrl").focus();return false;}if(document.getElementById("phoneNumber")){if(!document.getElementById("phoneNumber").value){alert("Please enter Click2Call Number");document.getElementById("phoneNumber").focus();return false;}else{if(!isPhoneNumber("phoneNumber")){return false;}}}createComaSeperatedList("pictureSizes","selectedSizesList",false);var pictureSizes=document.getElementById("selectedSizesList").value;pictureSizes=pictureSizes.replace(/,/g,"*");var templateName=document.getElementById("templateName").value;var businessId=document.getElementById("businessId").value;var bannerAdType=document.getElementById("bannerAdType").value;document.createBannarAdsForm.method="post";document.createBannarAdsForm.action="/createAds/"+businessId+"/"+templateName+"/"+bannerAdType+"?mode="+mode+"&selectedSizes="+pictureSizes;document.createBannarAdsForm.submit();}function editBannarAdDetails(mode){if(!document.getElementById("adName").value){alert("Please enter Ad Name.");document.getElementById("adName").focus();return false;}if(!document.getElementById("displayUrl").value){alert("Please enter Display URL.");document.getElementById("displayUrl").focus();return false;}if(!document.getElementById("destinationUrl").value){alert("Please enter Destination URL.");document.getElementById("destinationUrl").focus();return false;}createComaSeperatedList("pictureSizes","selectedSizesList",false);var pictureSizes=document.getElementById("selectedSizesList").value;pictureSizes=pictureSizes.replace(/,/g,"*");var templateName=document.getElementById("templateName").value;var businessId=document.getElementById("businessId").value;var campaignId=document.getElementById("campaignId").value;var bannerAdType=document.getElementById("bannerAdType").value;var bannerAdId=document.getElementById("bannerAdId").value;document.editBannarAdsForm.method="post";document.editBannarAdsForm.action="/editAds/"+businessId+"/"+bannerAdId+"/"+campaignId+"?mode="+mode+"&selectedSizes="+pictureSizes;document.editBannarAdsForm.submit();}function uploadImageFile(){var businessId=document.getElementById("businessId").value;var bannerAdType=document.getElementById("bannerAdType").value;var adTemplateName=document.getElementById("adTemplateName").value;document.getElementById("defaultImage").value=parent.document.getElementById("adsPicture").src;document.uploadImageform.method="post";document.uploadImageform.action="/getUploadedImage/"+businessId+"/"+bannerAdType+"/"+adTemplateName+"?mode=uploadImage";document.uploadImageform.submit();}function getImagePath(){var uploadImage=document.getElementById("uploadImage").value;var VENDOR_HOST=parent.document.getElementById("VENDOR_HOST").value;var addImageWidth=document.getElementById("addImageWidth").value;var addImageHeight=document.getElementById("addImageHeight").value;parent.document.getElementById("adsPicture").src="http://"+VENDOR_HOST+"/"+uploadImage;parent.document.getElementById("adImage").innerHTML="<img src='http://"+VENDOR_HOST+"/"+uploadImage+"' style='height:"+addImageHeight+";width:"+addImageWidth+"'>";parent.document.getElementById("uploadedImage").value="http://"+VENDOR_HOST+"/"+uploadImage;parent.document.getElementById("imageWidth").value=addImageWidth;parent.document.getElementById("imageHeight").value=addImageHeight;}function moveCreateBannerAd(url){var campaignId=document.getElementById("campaignId").value;if(document.getElementById("campaignId").value==0){alert("Please select campaign");document.getElementById("campaignId").focus();return false;}if(document.getElementById("selectedDealId")){if(document.getElementById("selectedDealId").value==0){alert("Please select Deal Title");document.getElementById("selectedDealId").focus();return false;}}document.businessAdThemeForm.method="post";document.businessAdThemeForm.action=url+"&campaignId="+campaignId;document.businessAdThemeForm.submit();}function showAdsGraphOrTableFormat(show){if(show=="Table"){document.getElementById("tableFormat").style.display="none";document.getElementById("graphFormat").style.display="block";document.getElementById("leadDetailsTable").style.display="none";document.getElementById("showLeadsGraphDiv").style.display="block";}else{if(show=="Graph"){document.getElementById("tableFormat").style.display="block";document.getElementById("graphFormat").style.display="none";document.getElementById("leadDetailsTable").style.display="block";document.getElementById("showLeadsGraphDiv").style.display="none";}}}
