function setCommMode() {
   inv_mobile = document.getElementById( "inv_mobile_chkid" );
   inv_mobile_div = document.getElementById( "inv_mobile_divid" );
   inv_mobile_notf = document.getElementById( "inv_mobile_notfid" );
   inv_email = document.getElementById( "inv_email_chkid" );   
   inv_email_div = document.getElementById( "inv_email_divid" );
   inv_email_notf = document.getElementById( "inv_email_notfid" );
   //alert( inv_mobile.checked );
   if( inv_mobile.checked == true ) {      
       inv_mobile_div.style.display = "block";
       inv_email_div.style.display = "none";
       if( inv_mobile_notf != null ) {
          inv_mobile_notf.style.display = "block";
          inv_email_notf.style.display = "none";
       }
   } 
   if( inv_email.checked == true ) {      
          inv_email_div.style.display = "block";
          inv_mobile_div.style.display = "none";
          if( inv_email_notf != null ) {
              inv_email_notf.style.display = "block";
              inv_mobile_notf.style.display = "none";
          }
   } 
   //alert( inv_email.checked );    
}

function validateMandatoryEmailMobileFields() {
    inv_email = document.getElementById( "inv_email_id" );
    l_invemail = Trim( inv_email.value );
     
    inv_mobile = document.getElementById( "inv_mobile_id" );
    l_invmobile = Trim( inv_mobile.value );
    if(  l_invemail.length == 0 && l_invmobile.length == 0 )
    {
        alert( "Check one of the mandatory fields Mobile number or Email address and try again!" );
        return false;        
    }
    return true;
}
function Trim(a_value)
{
    if(a_value.length < 1)
    {
        return"";
    }
    a_value = RTrim(a_value);
    a_value = LTrim(a_value);
    if(a_value == "")
    {
        return "";
    }else
    {
        return a_value;
    }
} //End Function

function RTrim(a_value)
{
    var w_space = String.fromCharCode(32);
    var v_length = a_value.length;
    var strTemp = "";
    if(v_length < 0)
    {
        return"";
    }
    var iTemp = v_length -1;

    while(iTemp > -1)
    {
        if(a_value.charAt(iTemp) == w_space)
        {
        }else
        {
            strTemp = a_value.substring(0,iTemp +1);
            break;
        }
        iTemp = iTemp-1;
    } //End While
    return strTemp;
} //End Function

function LTrim(a_value)
{
    var w_space = String.fromCharCode(32);
    if(v_length < 1)
    {
         return"";
    }
    var v_length = a_value.length;
    var strTemp = "";
    var iTemp = 0;

    while(iTemp < v_length)
    {
        if(a_value.charAt(iTemp) == w_space)
        {
        }else
        {
            strTemp = a_value.substring(iTemp,v_length);
            break;
        }
        iTemp = iTemp + 1;
    } //End While
    return strTemp;
}
/**
 * DHTML textbox character counter script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
maxL=120;
var bName = navigator.appName;
function taLimit(taObj) {
	if (taObj.value.length==maxL) return false;
	return true;
}

function taCount(taObj,Cnt) { 
	objCnt=createObject(Cnt);
	objVal=taObj.value;
	if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
	if (objCnt) {
		if(bName == "Netscape"){	
			objCnt.textContent=maxL-objVal.length;}
		else{objCnt.innerText=maxL-objVal.length;}
	}
	return true;
}
function createObject(objId) {
	if (document.getElementById) return document.getElementById(objId);
	else if (document.layers) return eval("document." + objId);
	else if (document.all) return eval("document.all." + objId);
	else return eval("document." + objId);
}


$(function() {
	function runFEffect(){				
	    $("#funtext").toggle();
	};
	function runTEffect(){				
	    $("#twittext").toggle();
	};
	$("#bfunpiper").click(function() {
		runFEffect();
		return false;
	});
	$("#btwitter").click(function() {
			runTEffect();
			return false;
	});
	$("#funtext").hide();
	$("#twittext").hide();
});

function loadNewMessages(){
    loading_data();
    var l_id = $("#itnr_id").val();
    $.ajax({
	    url: "../event/b_messages.php",
	    cache: false,
	    type:"GET",
	    dataType: "html",
	    data:({ itnr_id:l_id}),
	    success: function( html ) {				
		$("#b_messages").empty().append( html ); 			
		unloading_data();
	    }
    });
}

$(function() {	
	$("#broadcast").click(function() {
	    loadNewMessages();
	    return false;
	});
});

function loadLiveMessages(){
    loading_data();
    $.ajax({
	    url: "../live_cast.php",
	    cache: false,
	    type:"GET",
	    dataType: "html",
	    success: function( html ) {				
		$("#b_livecast").empty().append( html ); 
		unloading_data();
	    }
    });
}

$(function() {
	$("#livecast").click(function() {	    
	    loadLiveMessages();
	    return false;
	});
});


function loading_data() {   
   document.getElementById('loading-data' ).style.display = 'inline';	   
}
function unloading_data() {
	document.getElementById('loading-data' ).style.display = 'none';	
}



