// Other Default / Nifty Functions
function checkedAll(id,checked){$("#" + id + " input:checkbox").prop("checked",checked);}
function getStyle(oElm, strCssRule){var strValue = "";if(document.defaultView && document.defaultView.getComputedStyle){strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);}else if(oElm.currentStyle){strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){return p1.toUpperCase();});strValue = oElm.currentStyle[strCssRule];}return strValue;}
function disp(div){GetElm(div).style.display="block";}
function hide(div){GetElm(div).style.display="none";}
function dispHide(ElementID){if(!GetElm(ElementID)){return;}else{if(GetElm(ElementID).style.display == "none"){disp(ElementID);GetElm('btnDispHide' + ElementID).innerHTML = "-";}else if(GetElm(ElementID).style.display == "block"){hide(ElementID);GetElm('btnDispHide' + ElementID).innerHTML = "+";}}}
function confirmAct(){var conf = confirm("Are you sure you want to take this action?");if(true == conf){return true;}else if(false == conf){return false;}}
function confirmDel(){var conf = confirm("Are you sure you want to delete the selected items?");if(true == conf){return true;}else if(false == conf){return false;}}
function fixForURL(val){return escape(encodeURI(val));}
function GetElm(fld){return document.getElementById(fld);}
function GetElmVal(fld){if(GetElm(fld)){return GetElm(fld).value;}}
function CreateElm(val){return document.createElement(val);}
function Trim(s) {while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')){ s = s.substring(1,s.length); }while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')){ s = s.substring(0,s.length-1); }return s;}
function Left(str, n){if (n <= 0){return "";} else if (n > String(str).length){return str;} else {return String(str).substring(0,n);}}
function Right(str, n){if (n <= 0){return "";} else if (n > String(str).length){return str;} else {var iLen = String(str).length;return String(str).substring(iLen, iLen - n);}}
function PopWindow(url,name,h,w,left,top) {var optiontxt;optiontxt = "height=" + h + ",width=" + w + ",left=" + left + ",top=" + top + ",status=0,location=0,scrollbars=1,toolbar=0,resizable=1";var w = window.open(url,name,optiontxt);w.focus();return false;}
function scrollToMark(mrk){$('html, body').animate({scrollTop: $("#" + mrk).offset().top}, 2000);}
function FollowMouse(ElmID){document.onmousemove = MoveElm;function MoveElm(){if(GetElm(ElmID)){if (!posx){mX = 10;} else {mX = posx + 5;}if (!posy){mY = 10;} else {mY = posy + 5;}GetElm(ElmID).style.left = mX + "px";GetElm(ElmID).style.top = mY + "px";}}}
function DoCheckedBox(id,tf){if(tf){if (tf=="t"){GetElm(id).checked = true;}if(tf=="f"){GetElm(id).checked = false;}} else {if(GetElm(id).checked == false){GetElm(id).checked = true;}else if(GetElm(id).checked == true){GetElm(id).checked = false;}}}
function doHighlight(Container, searchTerm, highlightStartTag, highlightEndTag){bodyText = GetElm(Container).innerHTML;if ((!highlightStartTag) || (!highlightEndTag)) {highlightStartTag = "<span style='color: blue; background-color: yellow;'>";highlightEndTag = "</span>";}var newText = "";var i = -1;var lcSearchTerm = searchTerm.toLowerCase();var lcBodyText = bodyText.toLowerCase();while (bodyText.length > 0) {i = lcBodyText.indexOf(lcSearchTerm, i+1);if (i < 0) {newText += bodyText;bodyText = "";} else {if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;bodyText = bodyText.substr(i + searchTerm.length);lcBodyText = bodyText.toLowerCase();i = -1;}}}}GetElm(Container).innerHTML = newText;}
function getPageScrollPosition(){var yScroll;if (self.pageYOffset) {yScroll = self.pageYOffset;} else if (document.documentElement && document.documentElement.scrollTop) {yScroll = document.documentElement.scrollTop;} else if (document.body) {yScroll = document.body.scrollTop;}return yScroll;}
function getInternetExplorerVersion(){var rv = -1;if(navigator.appName == 'Microsoft Internet Explorer'){var ua = navigator.userAgent;var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");if(re.exec(ua) != null){rv = parseFloat(RegExp.$1);}}return rv;}
var posx;var posy;$(document).ready(function(){$(document).mousemove(function(e){posx = e.pageX;posy = e.pageY;});});

// WEBSITE-SPECIFIC FUNCTIONS
function SendTestEmail(){
	var email_address = fixForURL(GetElm('email_address').value);
	var num = fixForURL(GetElm('num').value);
	divpopup('POST','email-templates-test.php','&email_address=' + email_address + '&num=' + num,'email_templates_test',false,true,true);
	if(email_address.length > 0 && num.length > 0){dispHide('div-email-templates-test');}
}
function getSites(cid,startnum,endnum){
	if (cid.length == 0){document.getElementById("portfolioList").innerHTML = "";return;}
	var xmlhttp=null;
	if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}
	if(window.ActiveXObject){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
	if(xmlhttp==null){return false;}
	theurl = "getsites.php?cid=" + cid + "&s=" + startnum + "&e=" + endnum;
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==1){
			GetElm('portfolioList').innerHTML = '<center><br /><b>Loading...</b><br /><br /><img src="images/loading.gif" border="0" /></center>';
		}
		if(xmlhttp.readyState==4){
			GetElm("portfolioList").innerHTML = xmlhttp.responseText;
			var cid = document.getElementById("cid").value;
			var ptitle = document.getElementById("ptitle").value;
			var startnum = document.getElementById("startnum").value;
			var endnum = document.getElementById("endnum").value;
			var prevstart = document.getElementById("prevstart").value;
			var prevend = document.getElementById("prevend").value;
			var nextstart = document.getElementById("nextstart").value;
			var nextend = document.getElementById("nextend").value;
			var tonum = document.getElementById("tonum").value;
			var ncount = document.getElementById("ncount").value;
			var pageTotal = Math.floor(ncount / 6);
			var siteRem = ncount % 6;
			if (siteRem > 0){pageTotal += 1;}
			var CurrPageNumber = endnum / 6;
			navtable = "";
			navtable += "<center><font color='#00357B' size='3'><b>" + ptitle + "</font></b></center>";
			navtable += "<center><table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" style=\"width: 500px;\">";
			navtable += "<tr>";
			navtable += "<td style=\"text-align: left;\">";
			if (parseInt(startnum) > 1){
				navtable += "<a href=\"javascript:void(0);\" onclick=\"javascript:getSites('" + cid + "'," + prevstart + "," + prevend + ");\"><< PREV</a>";
			} else {
				navtable += "<span style=\"color: #828282;\"><< PREV</span>";
			}
			navtable += "</td>";
			navtable += "<td style=\"text-align: center;\"><b>Page " + CurrPageNumber + " of " + pageTotal + "</b></td>";
			navtable += "<td style=\"text-align: right;\">";
			if (parseInt(endnum) < parseInt(ncount)){
				navtable += "<a href=\"javascript:void(0);\" onclick=\"javascript:getSites('" + cid + "'," + nextstart + "," + nextend + ");\">NEXT >></a>";
			} else {
				navtable += "<span style=\"color: #828282;\">NEXT >></span>";
			}
			navtable += "</td>";
			navtable += "</tr>";
			navtable += "</table></center>";
			GetElm("pagenav").innerHTML = navtable;
		}
	};
	xmlhttp.open('POST',theurl,true);
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.send();
}
function checkDomains(){var domains = GetElmVal('domains');var tlds = GetElmVal('tlds');var tld = new Array();var qStr = '&domains=' + fixForURL(domains);for(i=1;i<=tlds;i++){if(GetElm('tld' + i).checked){tld[i] = GetElmVal('tld' + i);}}for(i=1;i<=tlds;i++){if(tld[i]){qStr += "&tld" + i + "=" + tld[i];}}divpopup('POST','domain-results.php',qStr,'domain_results',false,true,true);}

function addRow(tableID){var table = document.getElementById(tableID);var rowCount = table.rows.length;if (rowCount < 11){var row = table.insertRow(rowCount);var cell1 = row.insertCell(0);var element1 = document.createElement("input");element1.type = "text";element1.setAttribute("name","fname"+rowCount);element1.setAttribute("id","fname"+rowCount);element1.style.width = "90px";element1.setAttribute("maxlength","150");cell1.appendChild(element1);var cell2 = row.insertCell(1);var element2 = document.createElement("input");element2.type = "text";element2.setAttribute("name","lname"+rowCount);element2.setAttribute("id","lname"+rowCount);element2.style.width = "90px";element2.setAttribute("maxlength","150");cell2.appendChild(element2);var cell3 = row.insertCell(2);var element3 = document.createElement("input");element3.type = "text";element3.setAttribute("name","cell"+rowCount);element3.setAttribute("id","cell"+rowCount);element3.style.width = "90px";element3.setAttribute("maxlength","150");cell3.appendChild(element3);var cell4 = row.insertCell(3);var element4 = document.createElement("input");element4.type = "text";element4.setAttribute("name","tel"+rowCount);element4.setAttribute("id","tel"+rowCount);element4.style.width = "90px";element4.setAttribute("maxlength","150");cell4.appendChild(element4);var cell5 = row.insertCell(4);var element5 = document.createElement("input");element5.type = "text";element5.setAttribute("name","fax"+rowCount);element5.setAttribute("id","fax"+rowCount);element5.style.width = "90px";element5.setAttribute("maxlength","150");cell5.appendChild(element5);var cell6 = row.insertCell(5);var element6 = document.createElement("input");element6.type = "text";element6.setAttribute("name","email"+rowCount);element6.setAttribute("id","email"+rowCount);element6.style.width = "90px";element6.setAttribute("maxlength","150");cell6.appendChild(element6);var cell7 = row.insertCell(6);var element7 = document.createElement("input");element7.type = "checkbox";element7.setAttribute("name","chk");element7.setAttribute("id","chk");element7.setAttribute("style","cursor: pointer;");cell7.appendChild(element7);}}
function deleteRow(tableID) {try {var table = document.getElementById(tableID);var rowCount = table.rows.length;for(var i=0; i<rowCount; i++) {var row = table.rows[i];var chkbox = row.cells[6].childNodes[0];if(null != chkbox && true == chkbox.checked) {table.deleteRow(i);rowCount--;i--;}}}catch(e) {alert(e);}}

// FAQs
function GetFAQentry(id){PopWindow('faq_view.php?id=' + id,'faq_view_' + id,'300px','900px',100,100);/*divpopup('GET','faq_view.php','&id=' + id,'faq_view_' + id,false,true);*/}
