﻿function CleanText(control)
{
 	var re = /<\??\x2f?((?!p\b)(?!br\b)[\w\:]+)[^>]*>/gi;
 	var at = /(?:\s+(\w+)\s*=\s*(?:(\w+)|"([^"]*)"|'([^']*)'))*/gi;
 	var textbox = document.getElementById(control);
 	var text = textbox.value;
 	text = text.replace(re,'');
	textbox.value = text;			
}

var list
function ParentCheckBoxCheck(currId, type)
{
    list = GetType(type);
    var parentCheckBox = document.getElementById(currId);
    
    for(i=0;i<list.length; i++)
    {
        var currCheckBox = document.getElementById(list[i].Id);
        currCheckBox.checked = parentCheckBox.checked;      
    }     
}

function CurrentCheckBoxCheck(parent, current, type)
{
    list = GetType(type);
    var parentCheckBox = document.getElementById(parent);
    var currentCheckBox = document.getElementById(current);
    var flag = true;
    for(i=0;i<list.length; i++)
    {
        var currCheckBox = document.getElementById(list[i].Id);
        if (!currCheckBox.checked)
        {
            flag = false;
            break;
        }
    }
    parentCheckBox.checked = flag;
    
}

function GetType(type)
{
    if (type == 1)
        return boardList;
    if (type ==2)
        return hotelList;
    return transportList;
}

function PopulateTransport()
{
    var ids = document.getElementById(idtr);
    ids.value = "";
    var flag = true;
    if (list == null)
    {
		ids.value = ""
		return;
    }
    for(i=0; i<list.length;i++)
    {
        var currControl = document.getElementById(list[i].Id);
        if (currControl.checked == true)
        {	
			ids.value  = ids.value == "" ? currControl.value : ids.value + "," + currControl.value;
        }
        else
        {
			flag = false;
        }
    }
    if (flag) ids.value = "";
}

function Populate()
{
	 PopulateTransport();
}


