

function show(id) {
	document.getElementById(id).style.display='block';
}

function hide(id) {
	document.getElementById(id).style.display='none';
	document.getElementById(id).innerHTML = "";
}

 function ValSearch() {
  var errorflag;
   var errormsg;
  if (document.forms['search'].product.value =="" && document.forms['search'].company.value =="") {
 errorflag = 1;
 errormsg ="please enter a product or company name to search.\n";
  }
 if (errorflag == 1) {
 alert(errormsg);
  return false;
 } 
 }

function clearvalue(v,f) {
	
	// search field
	if (v == "Search Categories..." && f == "search") {	document.forms['csearch'].search.value = "";	}
	if (v == "" && f == "search") {	document.forms['csearch'].search.value = "Search Categories...";	}
	// search field
	if (v == "e.g postcode" && f == "proxform") {	document.forms['proxform'].psc.value = "";	}
	if (v == "" && f == "proxform") {	document.forms['proxform'].psc.value = "e.g postcode";	}

}

var xmlHttp;
function createXMLHttpRequest() {
	if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
}

function emailAdd(id) {

	var url = "redirect_email.php?cid=" + id + "&ts="+ new Date().getTime();
	window.top.frames['email' + id].location.href = url;
	
}

function trackLink(CID) {

	createXMLHttpRequest();
	var url = "./trackLink.php?wcid=" + CID + "&ts="+ new Date().getTime();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = callbackLink;
	xmlHttp.send(null);
	 
}

function callbackLink() {
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
		
		}
	}
}

var tid = "";
var http_text = false;
function makeTextRequest(url, parameters) {
     http_text = false;
     if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_text = new XMLHttpRequest();
        if (http_text.overrideMimeType) {
           //http_request.overrideMimeType('text/xml');
           http_text.overrideMimeType('text/html');
        }
     } else if (window.ActiveXObject) { // IE
        try {
           http_text = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
           try {
              http_text = new ActiveXObject("Microsoft.XMLHTTP");
           } catch (e) {}
        }
     }
     if (!http_text) {
        alert('Cannot create XMLHTTP instance');
        return false;
     }
     
     http_text.onreadystatechange = DisplayTextContents;
     http_text.open('POST', url, true);
     http_text.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     http_text.setRequestHeader("Content-length", parameters.length);
     http_text.setRequestHeader("Connection", "close");
     http_text.send(parameters);
	 
  }
  
  function DisplayTextContents() {
 	if (http_text.readyState == 4) {
        if (http_text.status == 200) {
           //alert(http_text.responseText);
           result = http_text.responseText;
           document.getElementById('txt' + tid).innerHTML = result;      
		} else {
           alert('There was a problem with the request.');
        }
     }
    
  }
  
function showText(id) {

  tid = id;
  document.getElementById('txt' + id).style.display='block';
  var poststr = "action=form&cid=" + id + "&ts="+ new Date().getTime();
  makeTextRequest('text_display.php', poststr);

}

function sendText(formn,id) {

  tid = id;
  var mob = document.forms['textform'+id].mobile.value;
  if (mob) {
  document.getElementById('txt' + id).style.display='block';
  var poststr = "action=send&cid=" + id + "&mobile=" + mob + "&ts="+ new Date().getTime();
  makeTextRequest('text_display.php', poststr);
  } else {
  alert("Please enter your mobile number in the box provided");
  }
  
}

function hideText(id) {
	document.getElementById('txt' + id).style.display='none';
	document.getElementById('txt' + id).innerHTML = "";
}





