/*
    there is 5 readystate status :
    0=uninitialized
    1=loading
    2=loaded
    3=interactive
    4=complete
    you can modify the status state at your own
*/

var xmlHttp

function requestContent(content,type){
       xmlHttp=GetXmlHttpObject()
        //set variable
        if (xmlHttp==null)
        {
        alert ('Your browser doesn’t support HTTP Request. please use Firefox, Internet Explorer, or Safari');
        // if browser doesn’t support xmlHttp, show error message
        }
    
        var url= 'program-modules/lib/class/ajax_request.php'
        var selectedValue;

     switch(type){
         case 1:
		      url=url+'?content=' + content
              xmlHttp.onreadystatechange=FetchComplete01
         break
         case 2:
              url=url+'?content=' + content
              xmlHttp.onreadystatechange=FetchComplete02
         break;
         case 3:
              selectedValue = document.thisForm.generalLocation.options[document.thisForm.generalLocation.selectedIndex].value;
              url=url+'?content=' + content + '&selected=' + selectedValue
              xmlHttp.onreadystatechange=FetchComplete03
         break;
         case 4:
		      url=url+'?content=' + content 
              xmlHttp.onreadystatechange=FetchComplete04
         break;
         case 5:
              url=url+'?content=' + content
              xmlHttp.onreadystatechange=FetchComplete01
         break
         case 6:
			  var searchString = document.thisForm.searchString.value;
              url=url+'?content=' + content + '&searchString=' + searchString;
              xmlHttp.onreadystatechange=FetchComplete01
         break
		 case 7:
		      url=url+'?content=' + content 
              xmlHttp.onreadystatechange=FetchComplete05
         break;        
     }
        xmlHttp.open('GET',url,true)
        //use get method
        xmlHttp.send(null)
}

function FetchComplete01(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=='complete'){
         //if AJAX state is complete (4)
         document.getElementById('result').innerHTML=xmlHttp.responseText
	    	    $('#property_masterlist').tableHover();
                $('#property_masterlist').tablesorter(
                  { widgets: ['zebra']}
           );
    }

    if (xmlHttp.readyState==1 || xmlHttp.readyState=='loading')
        //if AJAX state is loading (loading)
    {
        // document.getElementById('result').innerHTML='<center><img src="img/loading.gif"/> searching...</center>'
    }
}


function FetchComplete02(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=='complete') {
         document.getElementById('interest_result').innerHTML=xmlHttp.responseText     
    }
}

function FetchComplete03(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=='complete'){
         document.getElementById('general-sub').innerHTML=xmlHttp.responseText
     }
}

function FetchComplete04(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=='complete'){
         document.getElementById('profile_here').innerHTML=xmlHttp.responseText
    }

    if (xmlHttp.readyState==1 || xmlHttp.readyState=='loading'){
    }
}

function FetchComplete05(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=='complete'){
         document.getElementById('test_ajax').innerHTML=xmlHttp.responseText
    }
}

function GetXmlHttpObject(){
    var xmlHttp=null;
    try{
        // check browser firefox, opera 8.0+, safari
        xmlHttp=new XMLHttpRequest();
    }
	
    catch (e){
        // browser Internet Explorer
        try{
        // IE 6.0+
        xmlHttp=new ActiveXObject('Msxml2.XMLHTTP');
        }
         catch (e)
        {
        // IE 5.0
         xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
        }
    }
        return xmlHttp;
        //return the value
}

function viewErrors(msg){
   $(document).ready(function () {
	$.alerts.okButton = 'CLOSE';
	jAlert(msg, '41EightySeven Location Services');
   });
}

function msgbox(msg){
    $(document).ready(function () {
    $.alerts.okButton = 'OK ';
    jPrompt(msg, '41EightySeven Location Services'); //41EightySeven Location Services
    });
}

function viewConfirm(msg){
    $(document).ready(function () {
	$.alerts.okButton = 'Ok';
	jAlert(msg, '41EightySeven Location Services');
    });
}

function clearText(field){
	if (field.defaultValue == field.value) field.value = '';
	else if (field.value == '') field.value = field.defaultValue;
}

function cart_msgbox(msg){
       $(document).ready(function () {
        $.alerts.okButton = 'OK ';
        jPrompt(msg, '41EightySeven Location Services'); //41EightySeven Location Services
       });
}

function displayIntro(type){
	switch(type){
		case 1:
			window.location="http://www.41eightyseven.com/?page=industry-prof&class=d2_1%20d1_0";
		break;
		case 2:			
			window.location="http://www.41eightyseven.com/?page=prop-owner&class=d2_2%20d1_0";
		break;
	}
}

function submitForm(){
	document.login.submit();
}

function checkMe(id){

	if(id==0){
		
		if(document.thisForm.insCheck1.checked){
			
				document.thisForm.insCheck2.checked = false;
				document.thisForm.fin_pInsurance.value = "";
				document.thisForm.fin_pConverage.value = "";
				
				document.thisForm.fin_pInsurance.disabled = false;
				document.thisForm.fin_pConverage.disabled = false;
				
				document.thisForm.fin_pInsurance.style.backgroundColor = "black";
				document.thisForm.fin_pConverage.style.backgroundColor = "black";		
				
		}
		
	}
	
	if(id==1){
	
		if(document.thisForm.insCheck2.checked){
		
			document.thisForm.insCheck1.checked = false
		    document.thisForm.fin_pInsurance.value = "";
			document.thisForm.fin_pConverage.value = "";
				
			document.thisForm.fin_pInsurance.disabled = true;
			document.thisForm.fin_pConverage.disabled = true;
			
			document.thisForm.fin_pInsurance.style.backgroundColor = "gray";
			document.thisForm.fin_pConverage.style.backgroundColor = "gray";	
		}
	}
}


$(function(){ // wait for document to load 
	$('#idc').MultiFile({ 
		list: '#idc-list' 
	}); 
});


function checkIndustry(){

        var industry = document.getElementById("regindustry");
	industry= industry.options[industry.selectedIndex].value;

	if(industry=="Other"){
	
		document.regForm.industry_other.style.backgroundColor = "black";
		document.regForm.industry_other.disabled = false;

	}else{

		document.regForm.industry_other.style.backgroundColor = "gray";
		document.regForm.industry_other.disabled  = true;
		document.regForm.industry_other.value = "";
	}

}


function checkPosition(){

        var position = document.getElementById("position_id");
	position= position.options[position.selectedIndex].value;

	if(position=="Other"){
	
		document.regForm.position_other.style.backgroundColor = "black";
		document.regForm.position_other.disabled = false;

	}else{

		document.regForm.position_other.style.backgroundColor = "gray";
		document.regForm.position_other.disabled  = true;
		document.regForm.position_other.value = "";
	}

}


function checkContactPosition(){

    var position = document.getElementById("ctp");
	position= position.options[position.selectedIndex].value;
    
	if(position=="Other"){
	
		document.thisForm.con_pTitle_other.style.backgroundColor = "black";
		document.thisForm.con_pTitle_other.disabled = false;

	}else{

		document.thisForm.con_pTitle_other.style.backgroundColor = "gray";
		document.thisForm.con_pTitle_other.disabled  = true;
		document.thisForm.con_pTitle_other.value = "";
	}
}

function checkProjectType(){

    var t = document.getElementById("info");
	t= t.options[t.selectedIndex].value;
    
	
	if(t=="Other"){
	
		document.thisForm.info_pNoType.style.backgroundColor = "black";
		document.thisForm.info_pNoType.disabled = false;

	}else{

		document.thisForm.info_pNoType.style.backgroundColor = "gray";
		document.thisForm.info_pNoType.disabled  = true;
		document.thisForm.info_pNoType.value = "";
	}

}