

function get_browser()
{
if(navigator.appName == "WebTV")
{
 return "WebTV";
}
 if(navigator.appName == "Netscape")
{
 return "NS";
}
 if(navigator.appName == "Microsoft Internet Explorer")
{
 return "IE";
}
return "IE";
}






function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


var path_before_change='';  
var old_id='';
var old_path='';


function getHTTPObject() {
    var page_request = false;
    if (window.XMLHttpRequest)
    page_request = new XMLHttpRequest();
    else if (window.ActiveXObject){ 
    try {
    page_request = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e){
    try{
    page_request = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e){}
    }
    }
return page_request;
}



function ajaxpage(url, containerid){
page_request=getHTTPObject(); 
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}

	if(containerid!='none' )
	{
	page_request.open('GET', url, true)
	page_request.send(null)
	}else
	{
	  page_request.onreadystatechange = alertContents;
	  arr_url=url.split('?'); 
      page_request.open('POST',arr_url[0], true);
      page_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      page_request.setRequestHeader("Content-length",arr_url[1].length);
      page_request.setRequestHeader("Connection", "close");
      page_request.send(arr_url[1]);
	}

}


function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
if(containerid!='none')
document.getElementById(containerid).innerHTML=page_request.responseText
}



   function alertContents() {
      if (page_request.readyState == 4) {
    	     if (page_request.status == 200) {
		
			success_msg='<img src="images/accept.png" style="margin-top:2px;"/><font color="#000000">&nbsp;&nbsp;<b>Thank you</b> for		 contacting us. Your enquiry has been submitted successfully</font>';
			if(document.getElementById('error_msg'))
			document.getElementById('error_msg').innerHTML=success_msg;
	         } else {
			if(document.getElementById('error_msg'))				 
            document.getElementById('error_msg').innerHTML='There was a problem with sending your enquiry request. Please try later';
        	 }
    	  }
	   }


/*
window.onload = function(){
MM_preloadImages('images/button_deactive.jpg');

}
*/

function change_btn(id,image_path,image_old)
{
  
  if(document.getElementById(id))
 path_before_change=image_path;

  if(document.getElementById(old_id))
  document.getElementById(old_id).src=old_path;
  
  document.getElementById(id).src=image_path;
  old_id=id;
  old_path=image_old;
}




//trim functions
function trim(str) {
	return ltrim(rtrim(str));
}
function ltrim(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
function rtrim(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}
//ends trim functions
//email validation

function checkEmail(email) {

  var str = new String(email);
  var isOK = true;
  rExp = /[!\"£$%\^&*()-+=<>,\'#?\\|¬`\/\[\]]/
  if( rExp.test(str) )
    isOK = false;
  if( str.indexOf('.') == -1 || str.indexOf('@') == -1 )
    isOK = false;
  if( str.slice(str.lastIndexOf('.')+1,str.length).length < 2 )
    isOK = false;
  if( str.slice(0,str.indexOf('@')).length < 1 )
    isOK = false;
  if( str.slice(str.indexOf('@')+1,str.lastIndexOf('.')).length < 1 )
    isOK = false;

  if( !isOK )
    return false;

  return isOK;
}




function send_details()
{

cust_name=trim(document.getElementById('enq_name').value);
cust_contact=trim(document.getElementById('enq_contact').value);
cust_email=trim(document.getElementById('enq_email').value);
cust_company=trim(document.getElementById('enq_company').value);
cust_details=trim(document.getElementById('enq_details').value);




var str;
var msg='Please enter ';


sts=0;
str = cust_name;
if(str=='' || str==null){
msg += 'Name, ';
sts++;
document.getElementById('enq_name').style.border='1px solid #FC8000';
}
str = cust_contact;
if(str=='' || str==null){
msg += 'Contact Number, ';
sts++;
document.getElementById('enq_contact').style.border='1px solid #FC8000';
}

str = cust_email;
if(str=='' || str==null || checkEmail(str)==false){
msg += 'Email id, ';
sts++;
document.getElementById('enq_email').style.border='1px solid #FC8000';
}

msg= msg.substring(0, msg.length-2);


if(sts==0)
{

document.getElementById('enq_name').value='';
document.getElementById('enq_contact').value='';
document.getElementById('enq_email').value='';
document.getElementById('enq_company').value='';
document.getElementById('enq_details').value='';

document.getElementById('error_msg').innerHTML='<img src="images/ajax-loader.gif" />';
  
pars="fname="+cust_name+"&contact="+cust_contact+"&email="+cust_email+"&company="+cust_company+"&details="+cust_details;
ajaxpage('src/mail.php?'+pars,'none');

}else
{
   
  temp=msg.substring(0,msg.lastIndexOf(","));
  if(sts>1)
  msg=temp+' and '+msg.substring(msg.lastIndexOf(",")+1,msg.length)
  
  document.getElementById('error_msg').innerHTML=msg; 

}
 
}



function release(id_textbox)
{
  elmnt=document.getElementById(id_textbox);
  if(elmnt.value!='')
  elmnt.style.border='1px solid #CCC';
  document.getElementById('error_msg').innerHTML='';   

}



