
function showBox(chkObj,id)
{
/*	Function is called on, onChange for Mozilla and onClick for IE*/
	var show;
	if(chkObj.checked)
		show="block";
	else
		show="none";	
	document.getElementById(id).style.display = show;
	document.getElementById('counterDiv').style.display = show;
	
}

function alertMsgLength1(element, number){
	
	var val=element.value;
	var str=parseInt(val.length);
	if(number==undefined){
		document.getElementById('countTextspan').innerHTML=160-str;
	}
	else{
		var tweetSpan=document.getElementById('countTweetTextspan-'+number);
		tweetSpan.innerHTML=160-str;
		
		var textSpan=document.getElementById('countTextspan-'+number);
		textSpan.innerHTML=160-str;
	}
	
	val =  val.replace(/[^a-zA-Z 0-9]+/g,'');
	if(str>160){
		element.value=val.substring(0,160);
	}
	else{
		element.value=val;
	}
}

function alertMsgLength(element, number, spanName){
	
	var val=element.value;
	var str=parseInt(val.length);
	if(number==undefined){
		if(str<=160)
		document.getElementById('countTextspan').innerHTML=160-str;
	}else{
		
		if(spanName!=undefined){
			var tweetSpan=document.getElementById('countTweetTextspan-'+number);
			if(str<=140)
				tweetSpan.innerHTML=140-str;
		}
		else{
			if(str<=160)
				document.getElementById('countTextspan-'+number).innerHTML=160-str;
		}
	}
	val =  val.replace(/[^a-zA-Z 0-9~!@#$%^&*()_=+\\|/?.,<>:;'"\n-]+/g,'');
	if(str>160){
		element.value=val.substring(0,160);
	}
	else{
		element.value=val;
	}
	
	
	
}

function searchTypeSelect(obj,option,id)
{
	document.getElementById('pollId').value = id;
	currentObj=document.getElementsByTagName("div");
	var i=0;
	while (element = currentObj[i++]) 
	{
		if (element.className == "mark")
			element.className="";	
	}
	elementId = option+"_search";
	document.getElementById(elementId).className="mark";
	document.getElementById('menudiv').style.display = "none";
	document.getElementById('selectedPoll').innerHTML="Selected Poll : "+obj.title;
	/*document.getElementById('LeadPollId').innerHTML=id;*/
	 
	
}
function hideShow()
{
	var currentStyle=document.getElementById('menudiv').style.display;
	if(currentStyle=='none')
		currentStyle='block';
	else
		currentStyle='none';
	document.getElementById('menudiv').style.display=currentStyle;
}

function addRow(tableID) 
{

	var table = document.getElementById(tableID);

	var rowCount = table.rows.length;
	if(rowCount >10)
	{
		alert("You reached maximum allowed perameters.");
		return;
	}
	var row = table.insertRow(rowCount);
	row.align="center";
	if(rowCount%2==0)
		row.className="evenRow";

	var cell1 = row.insertCell(0);
	cell1.innerHTML = rowCount;

	var cell2 = row.insertCell(1);
	var element1 = document.createElement("input");
	element1.type = "text";	
	element1.style.width="200px";
	cell2.appendChild(element1);	

	var cell3 = row.insertCell(2);
	var element2 = document.createElement("input");
	element2.type = "text";
	element2.style.width="60px";
	element2.id="value"+rowCount;
	element2.setAttribute("onKeyUp", "disableCombo(this,'select"+rowCount+"');");

	
	var select = document.createElement("select");
	var option0 = document.createElement("option");
	var option1 = document.createElement("option");
	var option2 = document.createElement("option");
	var option3 = document.createElement("option");
	
	select.id="select"+rowCount;
	select.setAttribute("onchange", "disableTextBox(this,'value"+rowCount+"');");
	
	option0.text = "Select";
	option0.value = "default";
	
	option1.text = "User Phone Nbr";
	option1.value = "phone";
	
	option2.text = "ZipDial Nbr";
	option2.value = "zipdial";
	
	option3.text = "Request Time";
	option3.value = "reqtime";
	
	try {
		select.add(option0, null); //Standard
		select.add(option1, null);
		select.add(option2, null);
		select.add(option3, null);
	}catch(error) {
		select.add(option0); // IE only
		select.add(option1);
		select.add(option2);
		select.add(option3);
	}
	
	cell3.appendChild(element2);
	cell3.innerHTML+="&nbsp;&nbsp;";
	cell3.appendChild(select);

}

function disableCombo(currentObj,id)
{
	if((currentObj.value.length)> 0)
		document.getElementById(id).disabled=true;
	else
		document.getElementById(id).disabled=false;
}
function disableTextBox(currentObj,id)
{
	if(currentObj.value != "default")
		document.getElementById(id).disabled=true;
	else
		document.getElementById(id).disabled=false;
}

function showCallRow(tableID) 
{   
    
        
    var table = document.getElementById(tableID);
    var rowCount = (table.rows.length-1); // Do not include Header ...
    var newRowCount = 0;
    for(var i=1;i<=rowCount;i++)
    {
        id="option"+i;
        if(document.getElementById(id).style.display!="none")
            newRowCount++;
    }
    var displayRow=(newRowCount+1);
    if(displayRow >5)
    {
        alert("You reached maximum allowed options.");
        return;
    }
    var rowsNeedToRemove = rowCount - displayRow;   

    var removerRows=0;  
    var showRows=1;
    var id="";

    for(;showRows<=(rowCount-rowsNeedToRemove);showRows++)
    {
        id="option"+showRows;
        document.getElementById(id).style.display="";
    }
    removerRows = showRows;
    for(;removerRows<=(rowCount);removerRows++)
    {
        id="option"+removerRows;
        document.getElementById(id).style.display="none";
    }
}


