function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}


var xmlhttp4= createObject();
function showcity4()
{  
	
var con=document.getElementById('industry').value;
var city=document.getElementById('product').value;
xmlhttp4= createObject();
if (xmlhttp4==null)
{ alert ("Browser does not support HTTP Request"); return; }

var url="addservice.php";
url=url+"?con="+con+"&city="+city;
url=url+"&sid="+Math.random();
xmlhttp4.onreadystatechange=stateChanged4;
xmlhttp4.open("GET",url,true);
xmlhttp4.send(null);
}

function stateChanged4()
{
if (xmlhttp4.readyState==4)
{
document.getElementById("txtHint1").innerHTML=xmlhttp4.responseText;
document.getElementById('product').value="";
document.getElementById('product').focus();
}
}

function removeservice(g)
{  
	xmlhttp4= createObject();	
if (xmlhttp4==null)
{ alert ("Browser does not support HTTP Request"); return; }
var url="removeservice.php";
url=url+"?id="+g;
url=url+"&sid="+Math.random();
xmlhttp4.onreadystatechange=stateChanged4;
xmlhttp4.open("GET",url,true);
xmlhttp4.send(null);
}
var xmlhttp3;
function showcity3()
{  
	var con=document.getElementById('branchcountry').value;
	var city = document.getElementById('location').value; 
	xmlhttp3=GetXmlHttpObject3();
	
	if(con=="Select country")
	{
		document.getElementById('concity').innerHTML="Select your branch country";
	}
	
	else if(city =="Select city")
	{
		document.getElementById('concity').innerHTML="Select your branch city";
	}
	else
	{
		document.getElementById('concity').innerHTML="";
	}
if (xmlhttp3==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="getcity3.php";
url=url+"?con="+con+"&city="+city;
url=url+"&sid="+Math.random();
xmlhttp3.onreadystatechange=stateChanged3;
xmlhttp3.open("GET",url,true);
xmlhttp3.send(null);
}

function stateChanged3()
{
if (xmlhttp3.readyState==4)
{
document.getElementById("txtHint").innerHTML=xmlhttp3.responseText;
}
}
function GetXmlHttpObject3()
{
if (window.XMLHttpRequest)
{
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}

function removebranch(h)
{  
xmlhttp3=GetXmlHttpObject3();
if (xmlhttp3==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="removebranch.php";
url=url+"?con="+h;
url=url+"&sid="+Math.random();
xmlhttp3.onreadystatechange=stateChanged3;
xmlhttp3.open("GET",url,true);
xmlhttp3.send(null);
}


var xmlhttpi;
function showindustry()
{  
	var selectbox=document.getElementById('industry');
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
	selectbox.remove(i);
	}	
	
	
xmlhttpi=GetXmlHttpObjecti();
if (xmlhttpi==null)
{
alert ("Browser does not support HTTP Request");
return;
}
xmlhttpi.onreadystatechange=stateChangedi;
xmlhttpi.open("GET","getindus.php",true);
xmlhttpi.send(null);
}
function stateChangedi()
{
var le=0;
if (xmlhttpi.readyState==4)
{
var red=xmlhttpi.responseText;
var mytool_array=red.split(",");
var select2 = document.getElementById('industry'); 

for(var i=0;i<=mytool_array.length;i++)
{
	le=i;
}
if(le >=2 )
{
for(var i=0;i<=mytool_array.length;i++)
{
	if(mytool_array[i]!="")
	{
		select2.options[select2.options.length] = new Option(mytool_array[i],mytool_array[i],false,false); 
	}	
}
document.getElementById('industry').disabled=false;
}
else
{
	for(var i=0;i<=1;i++)
	{
		if(mytool_array[i]!="")
		{
			select2.options[select2.options.length] = new Option(mytool_array[i],mytool_array[i],false,false); 
		}	
	}
	document.getElementById('industry').disabled="disabled";
}
}
}
function GetXmlHttpObjecti()
{
if (window.XMLHttpRequest)
{
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}

/**
* Copy the value of an input field's title attribute to its value attribute.
* Clear the input field on focus if its value is the same as its title.
* Repopulate the input field on blur if it is empty.
* Hide the input field's associated label if it has one.
*/
var autoPopulate = {
	sInputClass:'populate', // Class name for input elements to autopopulate
	sHiddenClass:'structural', // Class name that gets assigned to hidden label elements
	bHideLabels:true, // If true, labels are hidden
	/**
	 * Main function
	 */
	init:function() {
		// Check for DOM support
		if (!document.getElementById || !document.createTextNode) {return;}
		// Find all input elements with the given className
		var arrInputs = autoPopulate.getElementsByClassName(document, 'input', autoPopulate.sInputClass);
		var iInputs = arrInputs.length;
		var oInput;
		for (var i=0; i<iInputs; i++) {
			oInput = arrInputs[i];
			// Make sure it's a text input
			if (oInput.type != 'text') { continue; }
			// Hide the input's label
			if (autoPopulate.bHideLabels) { autoPopulate.hideLabel(oInput.id); }
			// If value is empty and title is not, assign title to value
			if ((oInput.value == '') && (oInput.title != '')) { oInput.value = oInput.title; }
			// Add event handlers for focus and blur
			autoPopulate.addEvent(oInput, 'focus', function() {
				// If value and title are equal on focus, clear value
				if (this.value == this.title) {
					this.value = '';
					this.select(); // Make input caret visible in IE
				}
			});
			autoPopulate.addEvent(oInput, 'blur', function() {
				// If the field is empty on blur, assign title to value
				if (!this.value.length) { this.value = this.title; }
			});
		}
	},
	hideLabel:function(sId) {
		var arrLabels = document.getElementsByTagName('label');
		var iLabels = arrLabels.length;
		var oLabel;
		for (var i=0; i<iLabels; i++) {
			oLabel = arrLabels[i];
			if (oLabel.htmlFor == sId) {
				oLabel.className = oLabel.className + ' ' + autoPopulate.sHiddenClass;
			}
		}
	},
	/**
	 * getElementsByClassName function included here for portability.
	 * Remove if you are already using one.
	 * Written by Jonathan Snook, http://www.snook.ca/jonathan
	 * Add-ons by Robert Nyman, http://www.robertnyman.com
	 */
	getElementsByClassName:function(oElm, strTagName, strClassName) {
	    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
	    var arrReturnElements = new Array();
	    strClassName = strClassName.replace(/\-/g, "\\-");
	    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	    var oElement;
	    for(var i=0; i<arrElements.length; i++){
	        oElement = arrElements[i];      
	        if(oRegExp.test(oElement.className)){
	            arrReturnElements.push(oElement);
	        }   
	    }
	    return (arrReturnElements)
	},
	/**
	 * addEvent function included here for portability.
	 * Remove if you are already using an addEvent/DOMReady function.
	 * Found at http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
	 */
	addEvent:function(obj, type, fn) {
		if (obj.addEventListener)
			obj.addEventListener(type, fn, false);
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() {obj["e"+type+fn](window.event);}
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	}
};

/**
* Init on window load.
* Replace this with a call to your own addEvent/DOMReady function if you use one.
*/
autoPopulate.addEvent(window, 'load', autoPopulate.init);


