// Get home improvement articles & 3 images - 
function call_articleimage_ldr(_cfld, _tkfld, _related, _main, _mode, _def){
	var type="";
	var filter="";
	var mid="";
	var rid="";
	var headline="";
	var _p ="1";

	if (_mode=='i'){
		type=_cfld;
		if (isObject(_related)) rid=_related.value;
		if (isObject(_main)) mid=_main.value;
	}
	if (_def +""!="") mid= random(1,10);
	if (_mode=='c')	type=_cfld.options[_cfld.selectedIndex].text;
	if (_tkfld!=null && _tkfld!="" && isObject(_tkfld)){
		if (_tkfld.options.length){
			if (_tkfld.options[_tkfld.selectedIndex].text.toLowerCase().indexOf("select")!=0)
				filter = _tkfld.options[_tkfld.selectedIndex].text;
		}
	}
	
	if (isObject(document.forms[0].headline)) headline=document.forms[0].headline.value;
	var ngf=null;
	var ng="";
	eval("ngf = document.forms[0].ng");
	if (ngf != null) ng= ngf.value;
	if(ng+""=="125") _p = "3";
	if(ng+""=="21") _p = "2";

	if(ng+""=="125" && headline+""!="")
		document.getElementById('headerline').innerHTML = "<div class=\"headlineCenter\">" + headline +"</div>";
	else if (ng+""=="125" && headline+""=="")
		document.getElementById('headerline').innerHTML ="<div class=\"headlineCenter_sell\" >Compare<br/>Contractor Prices<br/></div><div class=\"headlineCenter_sell\" style=\"font-size: 14px;\">Instantly Find the Lowest Price!</div>";
	else if (ng+""=="21" && headline+""=="")
		document.getElementById('headerline').innerHTML ="Free Contractor Estimates<br/><span class=\"style23\">Up to 3 Estimates in 20 Seconds!</span>";
	else if (headline+""!="")
		document.getElementById('headerline').innerHTML = headline;
	else
		document.getElementById('headerline').innerHTML ="Compare Contractor Prices<br/><span class=\"style23\">Compare Up to 3 Local Estimates!</span>";

	var homeImp = null;
	eval("homeImp = document.getElementById('home_ldr');");
	if (homeImp == null) return;
	homeImp.src="/portal/add-ons/datasource/hi_articledata_ldr.asp?ng="+ ng +"&p="+ _p +"&type="+ escape(type) +"&filter="+ escape(filter) +"&rid="+ rid +"&mid="+ mid;
}

// Get home improvement articles & 2 images - 
function call_articleimage_ldr2(_cfld, _tkfld, _related, _main, _mode, _def){
	var type="";
	var filter="";
	var mid="";
	var rid="";
	var headline="";
	var _p ="1";

	if (_mode=='i'){
		type=_cfld;
		if (isObject(_related))	rid=_related.value;
		if (isObject(_main)) mid=_main.value;
	}

	if (_def +""!="") mid= random(1,10);
	if (_mode=='c')	type=_cfld.options[_cfld.selectedIndex].text;
	if (_tkfld!=null && _tkfld!="" && isObject(_tkfld)){
		if (_tkfld.options.length){
			if (_tkfld.options[_tkfld.selectedIndex].text.toLowerCase().indexOf("select")!=0)
				filter = _tkfld.options[_tkfld.selectedIndex].text;
		}
	}
	if (isObject(document.forms[0].headline)) headline=document.forms[0].headline.value;
	var ngf=null;
	var ng="";
	eval("ngf = document.forms[0].ng");
	if (ngf != null) ng= ngf.value;
	if(ng+""=="125") _p = "3";
	if(ng+""=="21") _p = "2";
	if(headline+""!="")
		document.getElementById('headerline').innerHTML = headline;
	else if (ng+""=="149")
		document.getElementById('headerline').innerHTML ="Free Contractor Estimates";

	var homeImp = null;
	eval("homeImp = document.getElementById('home_ldr');");
	if (homeImp == null) return;
	homeImp.src="/portal/add-ons/datasource/hi_articledata_ldr2.asp?ng="+ ng +"&p="+ _p +"&type="+ escape(type) +"&filter="+ escape(filter) +"&rid="+ rid +"&mid="+ mid;
}

// Get home improvement articles & no images - 
function call_articleimage_ldr3(_cfld, _tkfld, _related, _main, _mode, _def){
	var type="";
	var filter="";
	var mid="";
	var rid="";
	var headline="";
	var _p ="1";

	if (_mode=='i'){
		type=_cfld;
		if (isObject(_related))	rid=_related.value;
		if (isObject(_main)) mid=_main.value;
	}

	if (_def +""!="") mid= random(1,10);
	if (_mode=='c')	type=_cfld.options[_cfld.selectedIndex].text;
	if (_tkfld!=null && _tkfld!="" && isObject(_tkfld)){
		if (_tkfld.options.length){
			if (_tkfld.options[_tkfld.selectedIndex].text.toLowerCase().indexOf("select")!=0)
				filter = _tkfld.options[_tkfld.selectedIndex].text;
		}
	}
	
	var ngf=null;
	var ng="";
	eval("ngf = document.forms[0].ng");
	if (ngf != null) ng= ngf.value;
	if(ng+""=="125") _p = "3";
	if(ng+""=="21")	_p = "2";
	
	var homeImp = null;
	eval("homeImp = document.getElementById('home_ldr');");
	if (homeImp == null) return;
	homeImp.src="/portal/add-ons/datasource/hi_articledata_ldr3.asp?ng="+ ng +"&p="+ _p +"&type="+ escape(type) +"&filter="+ escape(filter) +"&rid="+ rid +"&mid="+ mid;
}

// Get home improvement Branded articles With HL -
function call_articlehl_ldr(_type, _hl, _projectid, _ng) {
    var homeImp = null;
    eval("homeImp = document.getElementById('home_ldr');");
    if (homeImp == null) return;
    homeImp.src = "/portal/add-ons/datasource/hi_articlehl_ldr.asp?ng=" + _ng + "&p=" + _projectid + "&type=" + escape(_type) + "&hl=" + escape(_hl);
}

// Get home improvement realted projects - 
function call_related_ldr(_cfld, _mode, _main)
{
	var adid="";
	var lsid="";
	var mkwid="";
	var	cid="";
	var type="";
	var main="";
	var headline="";
	var _p="";

	if (_mode=='i'){
		type=_cfld;
		if (isObject(document.forms[0].headline))
		headline=document.forms[0].headline.value;
	}

	if (_mode=='c')
		type=_cfld.options[_cfld.selectedIndex].text;
	if (_main+""!="") main= _main;
	
	if (isObject(document.forms[0].s_adid))
		adid=document.forms[0].s_adid.value;
	if (isObject(document.forms[0].s_lsid))
		lsid=document.forms[0].s_lsid.value;
	if (isObject(document.forms[0].s_mkwid))
		mkwid=document.forms[0].s_mkwid.value;
	if (isObject(document.forms[0].s_cid))
		cid=document.forms[0].s_cid.value;
	if (!isObject(lsid) && isObject(adid))
		lsid="2";
	
	var ngf=null;
	var ng="";
	eval("ngf = document.forms[0].ng");
	if (ngf != null) ng= ngf.value;
	if(ng+""=="125") _p = "3";
	if(ng+""=="21")	_p = "2";
	var homeImp = null;
	eval("homeImp = document.getElementById('home_ldr_v1');");
	if (homeImp == null) return;
	homeImp.src="/portal/add-ons/datasource/hi_relateddata_ldr.asp?ng="+ ng +"&p="+ _p +"&type="+ escape(type)+"&adid="+ adid +"&mkwid="+ mkwid +"&cid="+ cid +"&lsid="+ lsid +"&main="+ main +"&hl="+ headline;
}

// Get home improvement realted with ul list - 
function call_related_ldr2(_cfld, _mode, _main)
{
	var adid="";
	var lsid="";
	var mkwid="";
	var	cid="";
	var type="";
	var main="";
	var headline="";
	var _p="";

	if (_mode=='i'){
		type=_cfld;
		if (isObject(document.forms[0].headline))
		headline=document.forms[0].headline.value;
	}
	if (_mode=='c') type=_cfld.options[_cfld.selectedIndex].text;
	if (_main+""!="") main= _main;
	if (isObject(document.forms[0].s_adid))
		adid=document.forms[0].s_adid.value;
	if (isObject(document.forms[0].s_lsid))
		lsid=document.forms[0].s_lsid.value;
	if (isObject(document.forms[0].s_mkwid))
		mkwid=document.forms[0].s_mkwid.value;
	if (isObject(document.forms[0].s_cid))
		cid=document.forms[0].s_cid.value;
	if (!isObject(lsid) && isObject(adid)) lsid="2";
	
	var ngf=null;
	var ng="";
	eval("ngf = document.forms[0].ng");
	if (ngf != null) ng= ngf.value;
	if(ng+""=="125") _p = "3";
	if(ng+""=="21")	_p = "2";
	var homeImp = null;
	eval("homeImp = document.getElementById('home_ldr_v1');");
	if (homeImp == null) return;
	homeImp.src="/portal/add-ons/datasource/hi_relateddata_ldr2.asp?ng="+ ng +"&p="+ _p +"&type="+ escape(type)+"&adid="+ adid +"&mkwid="+ mkwid +"&cid="+ cid +"&lsid="+ lsid +"&main="+ main +"&hl="+ headline;
}

//Get articles for filter pages by subcategory id.
function call_filter_article_ldr(id, cid, sid){
	var artframe = null;
	eval("artframe = document.getElementById('art_ldr');");
	if (artframe == null) return;
	artframe.src="/portal/add-ons/datasource/hi_filter_articledata_ldr.asp?p="+ id +"&cid="+ cid +"&sid="+ sid;
}

function isObject(objToTest) {
	if (objToTest == null || objToTest == undefined || objToTest == "")
		return false;
	else 
		return true;
}

function random(l,u) {     
	return Math.floor((Math.random() * (u-l+1))+l); 
} 
