﻿/*main scripts*/

function submitSiteSearch() {
	var sterm = document.getElementById("dmcSearchInput").value;
	window.location.href = "http://saveoursector.com/Search.aspx?process=search_content_files&searchText="+sterm;
}

function pdfSitePage() {
	var baseUrl = "http://saveoursector.com";
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
		
	//clean dataUrl
	var dataPage = sPage.replace(".aspx",".txt");
	var dataUrl = "http://saveoursector.com/dmc_main/content/site/pages/" + dataPage;
	
	setTimeout("dmcHtmlToPdf('"+dataUrl+"', '"+baseUrl+"');",0000);
}

function printSitePage() {
	var baseUrl = "http://saveoursector.com/dmc_main/";
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
		
	//clean dataUrl
	var dataPage = sPage.replace(".aspx",".txt");
	var dataUrl = "d:/hosting/saveoursector/dmc_main/content/site/pages/" + dataPage;
	
	setTimeout("openPrintText_pop('Save Our Selves', '"+dataUrl+"', '"+baseUrl+"');",0000);
}

function blogHtmlToPdf(dataUrl, baseUrl, rid) {
/**
this function uses the dmc php pdf convertor provided by PHP Classes
**/
	var filePath = "http://saveoursector.com/dmc_main/server.aspx";
	var queryString = "pi=dmcblog&ui=ui&process=save_record_temp_file&rid="+rid;
	
	/*first save the file to temp dir*/
	$.get(filePath, queryString ,
	function(data){
		if(sanitizeServerAjaxCall(data) == "success") {
			window.open(eppHtmlToPdfUrl+"?urlPath="+escape(dataUrl)+"&urlBase="+baseUrl);
		} else {
			alert("Failed to create PDF file");
		}
	});
}