function changelay(layid)
{
        var ll=layid.length;
        var action=layid.substring(ll-1,ll);
        var la=layid.substring(0,ll-1);

        var laQues=layid.substring(0,ll-2);
        var layer=la.substring(la.length-1,la.length);

        if(document.getElementById(la))
        {
        if(action=="S")
                {
                        document.getElementById(la).style.display="block";

                 }
        else if(action=="H")
                 {
                        var i =la.substring(la.length-1,la.length);
                        var x=la.substring(la.length-1,la.length);
                        for(i;i<10;i++)
                        { x++;
                                if(document.getElementById(la))
                                {
                                 document.getElementById(la).style.display="none";

                                }
                                 la=la.substring(0,ll-2)+(x);
                        }
                }
        }
}

// return the checked value for document.formname.elementname
// if no radio buttons have been checked, returns null
function get_radio_value(f)
{
	if(f.type == "checkbox") {
		if(f.checked) {
			return f.value;
		}
	} else {
	  for (var i=0; i < f.length; i++)
          {
                if (f[i].checked)
                {
                     return rad_val = f[i].value;
                }
          }
	}
        return null;
}

function isEmpty(strng) {
        if (strng == null || strng == "") {
                return true;
        }
        for (i=0;i<strng.length;i++) {
                if (strng.charAt(i) != ' ')
                        return false;
        }
        return true;
}

// ===================================
// desc: display image or hide 'em
// param: 
//	id - in the form oidXX_720x250 
//		which is the image name
//	hide - set to 1 to hide the image
//		0 to show image
//	fileType - the image extension.
//		0 - no image
//		1 - ".gif"
//		2 - ".jpg"
// ===================================
function switchImg(id,hide,fileType) {
        var o = document.getElementById(id);

	if(hide == 1 || fileType == 0) {
		o.src = "default_files/spacer.gif";
		o.width = 0;
		//o.height = 0;
	} else {
		o.width = 720;
		//o.height = 250;

		if(fileType == 1) {
			o.src = "default_files/" + id + ".gif";	
		} else {
			o.src = "default_files/" + id + ".jpg";
		}
	}
}

// =====================================
// desc: if user clicks on ad Copy or image 
// 	 then set radio to 'yes'
// param: id - campaign id
// =====================================
function offerInterest(id) 
{

	id = 'rb' + id;
	var o = document.getElementsByName(id);
	
	o[0].checked = true;
}

var prev_alert_id=0;
if(isEmpty(bgcolor1)) {
	var bgcolor1 = 'white';
}
if(isEmpty(bgcolor2)) {
	var bgcolor2 = '#ff9933';
}

// desc: highlight row 
// param: element ID
function swap_bg_color(id)
{
	if(prev_alert_id != 0) {
		document.getElementById(prev_alert_id).style.backgroundColor=bgcolor1;
	}
	document.getElementById(id).style.backgroundColor=bgcolor2;
        location.hash = "#"+id;
	prev_alert_id = id;
}

// param: edv - the edv name that will contain the aggregate values
//        cb_name - the checkbox's name
function cb_compile(edv, cb_name) {

        var obj = document.getElementsByName(cb_name);

        var edvobj = document.getElementsByName(edv)[0];
        edvobj.value = 's';  // added this to create a clean comma delimited list

        for(var i=0; i<obj.length; i++) {
                if(obj[i].checked == true)
                edvobj.value += ',' + obj[i].value;
        }
        edvobj.value = edvobj.value.substring(2);
}

function dhtmlLoadScript(url)
{
	var e = document.createElement("script");
   	e.src = url;
   	e.type="text/javascript";
   	document.getElementsByTagName("head")[0].appendChild(e);
}

function change_state(cc) {
	var ind = document.theform.state;

	if(cc == 'CA') {
		ind.selectedIndex = 52;
	} else if(cc == 'US') {
		ind.selectedIndex = 0;
	} else {
		ind.selectedIndex = 66;
	}
}

function change_country(sc_index) {
	cobj = document.theform.country;	

	if(sc_index == 0) {
		cobj.selectedIndex = 0;
		cobj.value = "";
	}
	else if(sc_index < 52 && sc_index > 0) {
		cobj.selectedIndex = 4;
		cobj.value = 'US';
	}
	else if(sc_index > 51 && sc_index < 66) {
		cobj.selectedIndex = 1;
		cobj.value = 'CA';
	} else {
		cobj.selectedIndex = 5;
		cobj.value = '0';
	}

	return true; 
}
