/**
 * Author:	Mohamed Syed
 * Purpose:	Script to populate the Generic Search Widget - this version wont have FORM_LOAD related codes
 * since:	amw009_20111024
 * version:	2.0
 */
function $$$(id){
	return document.getElementById(id);
}
//
var IEFlag = "Microsoft Internet Explorer"
var siteDomain = ""
var defauttcoltext = ""
var defauttkeytext = ""
var widgetsiteurl = ""
var timerspeed = 10
var subjerr = ""
var counerr = "Oops! please select a country from list"
var ajaxloader = "";
var lineloader = "";
//
var vmore = ""
var vcmore = ""
var vweb = ""
//
var cur_css = 'inline'
var css_type = 'inline'
//
function backToResults(){
$$$("crsDivWrapper").style.display = 'none'
$$$("hcrs_div").style.display = 'block'
$$$("reshold").style.display='none'
$$$('backresult').style.display = 'none'
$$$('hcns').style.display = 'block'
}
//
function noneblock(thisid,value){}
//
function hideblock(thisid,value){
	$$$(thisid).style.display = value
}
//
function replaceAll(replacetext,findstring,replacestring){
	var strReplaceAll=replacetext
	return strReplaceAll
}
//
function clearTextOfCurrentObj(o){
	if(o.value == $$$('defauttkeytext').value){o.value = ''}
}
//
function setTextOfCurrentObj(o){
	if(o.value == ''){o.value = $$$('defauttkeytext').value}
}
//
function replaceSpecialChar(inString){
	if(inString !=null){
		inString=replaceAll(inString,"&","")
		inString=replaceAll(inString,","," ")
		inString=replaceAll(inString,"  "," ")
		return inString
}	}
//
function showresultdiv(){
	var obj = $$$("hcrp")
	if(cur_css == css_type){hcRP(obj)}
	obj.style.display = 'block'
	$$$("reshold").style.display = 'none'
	$$$("crsDivWrapper").style.display = 'none'
	$$$("hcrs_div").style.display = 'block'
	cou = 1
	maxmizeDiv()
}
//
function showCourseDetails(){
	$$$("crsDivWrapper").style.display = 'block'
	$$$("hcrs_div").style.display = 'none'
	$$$("reshold").style.display='none'
	cou = 1
}
//
function hideresultdiv(){
	var containerobj = $$$("hcrp")
	$$$("reshold").style.display = ''
	cou = parseInt(containerobj.style.width)
	minmizeDiv()
}
//
function minmizeDiv(){
	var containerobj = $$$("hcrp")
	if(cou >= 0){
		timer = setTimeout("minmizeDiv()",timerspeed)
		cou = cou - 50
		if(cou > 0){}
	}else{
		clearTimeout(timer)
		with(document){
			if(getElementById("widgetformscript") == null && $$$("keyword") != null){
				$$$("keyword").value = $$$('defauttkeytext').value
			}
			getElementById("hcrp").style.display = 'none'
			$$$("crsDivWrapper").style.display = 'none'
			$$$("hcrs_div").style.display = 'none'
			if($$$("category")!=null){
                            if($$$("defaultsub")!=null){
                                $$$("category").selectedIndex = $$$("defaultsub").selectedIndex
                            }
                            else{
                                $$$("category").selectedIndex = 0
                            }
                        }
			if($$$("country")!=null){
				if($$$("defaultcountry")!=null){
					$$$("country").selectedIndex = $$$("defaultcountry").selectedIndex
				}
				else{
					$$$("country").selectedIndex = 0
				}
			}
			if($$$("smode")!=null){
				if($$$("defaultsmode")!=null){
					$$$("smode").selectedIndex = $$$("defaultsmode").selectedIndex
				}
				else{
					$$$("smode").selectedIndex = 0
				}
			}
			if($$$("qual")!=null){
				if($$$("defaultqual")!=null){
					$$$("qual").selectedIndex = $$$("defaultqual").selectedIndex
				}
				else{
					$$$("qual").selectedIndex = 0
				}
			}
		}
}	}
//
function maxmizeDiv(){
	var containerobj=$$$("hcrp")
	if(cou <= 450){
		timer = setTimeout("maxmizeDiv()",timerspeed)
		cou = cou + 18
	}else{
		clearTimeout(timer)
	}
}
//
function AddFormWidget(objectName){
	var current
	var data
	if(this.constructor == AddFormWidget){current = this
	}else{current = arguments[arguments.length-1]}
	// TODO assign these value from <Hidden>
	contextpath = "/hcwidget"
	current.siteDomain = ''
	current.objectName = objectName
	current.containingNode
	current.css = ''
	current.listeners = []
	current.pageName = ''
	widgetsiteurl = $$$('siteUrl').value;
	
	// ----- TODO - Form content related can be removed
	current.config = function(jsonData){
		this.siteDomain = current.siteUrl
		if(document.getElementById){
			if(! document.location.href.indexOf("file:///") > -1){
				var mappingpath = "/international-course-search/widget.html?dowhat=loadform"
				widgetsiteurl = $$$('siteUrl').value
				cur_css = current.css
				current.siteUrl = current.siteUrl + contextpath + mappingpath
				current.addScript(current.siteUrl + (current.siteUrl.indexOf('?') > -1 ? '&' : '?') + 'callback=' + objectName + '.loadResultData')
	}	}	}
	//  ----- TODO - Form content related can be removed
	current.loadResultData = function(jsonData){
		data = jsonData.wgstart
		var rootdiv = document.createElement('div')
		current.containingNode = rootdiv
		current.containingNode.id = 'wcrt'
		if($$$('affId') && $$$('affId').value == 90409){current.containingNode.style.direction = "rtl"}
		if(cur_css == css_type){hcWidget(rootdiv)}
		current.buildFormContent(data)
		var inserted = false
		if(!inserted){
			var scr = $$$('AddFormWidgetScript')
			scr.parentNode.insertBefore(current.containingNode,scr)
			$$$("country").selectedIndex = 0
		}
	}
	
	//-- <div> builder
	current.buildDIV = function(thisid,name,width,height,theclass,thistitle,content){
		var divcontainer = document.createElement('div')
		if(thisid != null && thisid != ''){divcontainer.setAttribute('id',thisid)}
		if(name != null && name != ''){divcontainer.setAttribute('name',name)}
		if(height != null && height != ''){divcontainer.setAttribute('height',height)}
		if(width != null && width != ''){divcontainer.setAttribute('width',width)}
		if(thistitle !=null && thistitle != ''){divcontainer.setAttribute('title',thistitle)}
		if(content != null && content != ''){divcontainer.appendChild(document.createTextNode(content))}
		if(theclass != null && typeof(theclass) != 'undefined' && theclass != ''){
			divcontainer.setAttribute('class',theclass)
			if(navigator.appName == IEFlag){divcontainer.className=theclass}
		}
		return divcontainer
	}
	//-- <img> builder
	current.buildIMAGE = function(src,thisid,name,width,height,theclass,thistitle){
		var imagetag = document.createElement('img')
		imagetag.setAttribute('src',src)
		if(thisid != null && thisid != ''){imagetag.setAttribute('id',thisid)}
		if(name != null && name != ''){imagetag.setAttribute('name',name)}
		if(height != null && height != ''){imagetag.setAttribute('height',height)}
		if(width != null && width != ''){imagetag.setAttribute('width',width)}
		if(thistitle != null && thistitle != ''){
			imagetag.setAttribute('title',thistitle);
			imagetag.setAttribute('alt',thistitle)
		}
		if(theclass != null && typeof(theclass) != 'undefined' && theclass != ''){
			imagetag.setAttribute('class',theclass)
			if(navigator.appName == IEFlag){imagetag.className=theclass}
		}
		return imagetag
	}
	//-- <option> builder
	current.buildOPTION = function(text,value,theclass){
		var option = document.createElement('option')
		option.setAttribute('value',value)
		option.appendChild(document.createTextNode(text))
		if(typeof(theclass) != 'undefined' && theclass != ''){option.className = theclass}
		return option
	}
	//-- <a> builder
	current.buildHREF = function(href,title,value,theclass,nofollow,target){
		var ahref = document.createElement('a')
		ahref.setAttribute('href',href)
		ahref.setAttribute('title',title)
		if(cur_css == css_type){
			ahref.setAttribute('style',"cursor:pointer; text-align:left; color:#333 !important;")
			if(navigator.appName==IEFlag){
				ahref.style.cursor="pointer"
				ahref.style.color="#333"
			}
		}
		if(cur_css == css_type && theclass == 'visit_web'){
			ahref.setAttribute('style',"color:"+($$$('linkcolor') && $$$('linkcolor').value!=''?$$$('linkcolor').value:"")+";")
		}
		if(cur_css == css_type && theclass == 'view'){
			ahref.setAttribute('style'," display:inline-block; cursor:pointer; color:#187ADB; text-decoration:none; margin-bottom:5px;")
			if(navigator.appName == IEFlag){
				ahref.style.display = "inline-block"
				ahref.style.marginBottom = "5px"
				ahref.style.cursor = "pointer"
				ahref.style.color = "#187ADB"
				ahref.style.textDecoration = "none"
			}
			ahref.setAttribute('style',("color:" + ($$$('linkcolor') && $$$('linkcolor').value != '' ? $$$('linkcolor').value : "") + ";"))
		}
		if(cur_css == css_type && theclass == 'c_link'){
			ahref.setAttribute('style'," color:#777; text-decoration:none;")
			if(navigator.appName == IEFlag){
				ahref.style.color = "#777"
				ahref.style.textDecoartion = "none"
			}
		}
		ahref.appendChild(document.createTextNode(value))
		if(typeof(theclass) != 'undefined' && theclass != ''){ahref.className = theclass}
		if(target != ''){
			ahref.setAttribute('target',target);
			ahref.setAttribute('style',("color:" + ($$$('linkcolor') && $$$('linkcolor').value != '' ? $$$('linkcolor').value : "") + ";"))
		}
		if(target != ''){ahref.setAttribute('rel',nofollow)}
		return ahref
	}
	// --- talken from "current.buildFormContent(data)"
		// translation values - this needs to be taken from <hidden> values
		/*
		vmore = data.FormLabels[0].searchmoore
		vcmore = data.FormLabels[0].vcoursemore
		defauttcoltext = data.FormLabels[0].ajaxdefault
		defauttkeytext = data.FormLabels[0].subjdefault
		subjerr = data.FormLabels[0].subjerr
		counerr = data.FormLabels[0].counerr
		vweb = data.FormLabels[0].vwebsite
		*/
		//
	// --- displaying provider-result-page
	current.buildCourseTitleItem = function(data,parentcoursediv){
		var coursetitle_ul = document.createElement('ul')
		var moreFlag = false;
		var result_pmore1;
		if(cur_css == css_type){ulStyle(coursetitle_ul)}
		for(var i=0;i<data.Results.length;i++){
			var coursedata = data.Results[i]
			var coursetitle_li = document.createElement('li')
			if($$$("courseradl").checked == true){
				var tmpBlank;
				if($$$("embedCrs1").checked == true){tmpBlank = ""}
				else{tmpBlank = "_blank"}
				coursetitle_li.appendChild(current.buildHREF(coursedata.url,coursedata.coursetitle,coursedata.coursetitle,"","",tmpBlank))
				coursetitle_ul.appendChild(coursetitle_li)
			}else{
				coursetitle_li.appendChild(document.createTextNode(coursedata.coursetitle))
				coursetitle_ul.appendChild(coursetitle_li)
			}
			if(cur_css == css_type){
				coursetitle_li.style.margin="0 0 5px"
				coursetitle_li.style.padding="0 0 0 15px"
				coursetitle_li.style.fontStyle="normal"
				coursetitle_li.style.fontWeight="normal"
				coursetitle_li.style.wordSpacing="normal"
				coursetitle_li.style.letterSpacing="normal"
				coursetitle_li.style.lineHeight="normal"
				coursetitle_li.style.textIndent="0"
				coursetitle_li.style.listStyle="none"
				coursetitle_li.style.border="0"
				coursetitle_li.style.backgroundColor="transparent"
				coursetitle_li.style.backgroundImage="url("+coursedata.arrowimg+")"
				coursetitle_li.style.backgroundRepeat="no-repeat"
				coursetitle_li.style.backgroundPosition="3px 4px"
				coursetitle_li.style.color="#187ADB"
			}
			if(i == data.Results.length-1 && coursedata.coursetcount > 10){
				result_pmore1 = document.createElement('p')
				//result_pmore1.setAttribute('class',"hccnt")
				if(cur_css == css_type){pStyle(result_pmore1)}
				//if(navigator.appName == IEFlag){result_pmore1.className = "hccnt"}
				var vmore_span = document.createElement('span')
				vmore_span.appendChild(current.buildHREF(coursedata.coursemoreurl,vcmore,vcmore,"","","_blank"))
				result_pmore1.appendChild(vmore_span)
				moreFlag = true;
		}	}
		parentcoursediv.innerHTML = ""
		parentcoursediv.appendChild(coursetitle_ul)
		if(moreFlag){
			parentcoursediv.appendChild(result_pmore1)
		}
	}
	// --- displaying money-page
	current.buildSearchItem = function(search,currentindex,parentresultdiv,selectedstudylevel,length,data,hcrh){
		if(search.PageName == 'SEARCH_RESULT'){
			if(currentindex == 0){
				var hctl_div = document.createElement('div')
				hctl_div.setAttribute('id',"hctl")
				//hctl_div.setAttribute('class',"hctl")
				if(cur_css == css_type){hcTL(hctl_div)}
				parentresultdiv.appendChild(hctl_div)
				var heading = document.createElement('h2')
				//heading.setAttribute('class',"head")
				if(cur_css == css_type){h2Style(heading)}
				//if(navigator.appName == IEFlag){heading.className = "head"}
				heading.appendChild(document.createTextNode(data.Head[0].head1))
				if($$$("h2color") != null){
					if($$$("h2color").value != ''){
					heading.style.color = ($$$("h2color").value != '' ? $$$("h2color").value : "")}}
				hctl_div.appendChild(heading)
				//
				if(data.Head[0].head2 != ""){
					var result_he1 = document.createElement('p')
					result_he1.setAttribute('id',"result_he1")
					//result_he1.setAttribute('class',"w1")
					if(cur_css == css_type){w1Style(result_he1)}
					//if(navigator.appName == IEFlag){result_he1.className="w1"}
					result_he1.appendChild(document.createTextNode(data.Head[0].head2))
					if($$$('bdycolor') != null){
						if($$$('bdycolor') && $$$('bdycolor').value != ''){result_he1.style.color = $$$('bdycolor').value}}
					hctl_div.appendChild(result_he1)
				}
				//
				if(data.Head[0].head3 != ""){
					var result_he2 = document.createElement('p')
					result_he2.setAttribute('class',"w2")
					if(cur_css == css_type){
					result_he2.setAttribute('style',"margin: 0; padding: 0 0 5px;margin:0;")
					w1Style(result_he2)}
					if(navigator.appName == IEFlag){result_he2.className = "w2"}
					result_he2.appendChild(document.createTextNode(data.Head[0].head3))
					hctl_div.appendChild(result_he2)
				}
				//
				if(data.Head[0].head4 != ""){
					var result_he3 = document.createElement('p')
					result_he3.setAttribute('class',"w3")
					if(navigator.appName == IEFlag){result_he3.className = "w3"}
					result_he3.appendChild(document.createTextNode(data.Head[0].head4))
					hctl_div.appendChild(result_he3)
				}
				//
				if(data.Head[0].head5 != ""){
					var result_he4 = document.createElement('p')
					result_he4.setAttribute('class',"w4")
					if(navigator.appName == IEFlag){result_he4.className = "w4"}
					result_he4.appendChild(document.createTextNode(data.Head[0].head5))
					hctl_div.appendChild(result_he4)
				}
			}
			//
			var child_div = current.buildDIV(null,null,null,null,null,null,null)
			if(cur_css == css_type){resultStyle(child_div)}
			var result_p1 = document.createElement('p')
			//result_p1.setAttribute('class',"ttl")
			if(cur_css == css_type){pStyle(result_p1);result_p1.style.fontWeight='bold'}
			//if(navigator.appName == IEFlag){result_p1.className = "hccnt"}
			result_p1.appendChild(document.createTextNode(search.collegename))
			if($$$('bdycolor') != null){
				if($$$('bdycolor').value != ''){result_p1.style.color = $$$('bdycolor').value}}
			var result_p11 = document.createElement('p')
			//result_p11.setAttribute('class',"clink")
			if(cur_css == css_type){pStyle(result_p11)}
			var ahref11 = document.createElement('a')
			ahref11.setAttribute('title',search.coursehead)
			//ahref11.setAttribute('class',"crs")
			if(cur_css == css_type){
				ahref11.setAttribute('style',"cursor:pointer;")
				if(navigator.appName == IEFlag){
					ahref11.style.color = "#187ADB"
					ahref11.style.cursor = "pointer"}
			}
			//if(navigator.appName == IEFlag){ahref11.className = "crs"}
			ahref11.style.color = ($$$('linkcolor') && $$$('linkcolor').value != '' ? $$$('linkcolor').value : "#187ADB")
			ahref11.onclick = function(){return CourseTitleWidget(search.collegeid,search.CourseCount)}
			ahref11.appendChild(document.createTextNode(search.coursehead))
			var spancrs = document.createElement('span')
			//spancrs.setAttribute('class',"link")
			//if(navigator.appName == IEFlag){spancrs.className = "link"}
			spancrs.appendChild(ahref11)
			result_p11.appendChild(spancrs)
			child_div.appendChild(result_p1)
			//
			if(search.visitweburl != ""){
				var buttons=document.createElement('span')
				//buttons.setAttribute('class',"wbutton")
				if(cur_css == css_type){
					if(navigator.appName == IEFlag){
						buttons.style.clear = "both"
						buttons.style.margin = "3px 0"
						buttons.style.padding = "3px 3px 4px";
						buttons.style.display = "inline-block";
						buttons.style.background = "#4A8BC7";
						buttons.style.color = "#fff";
						buttons.style.textDecoration = "none"
					}else{buttons.setAttribute('style',"clear:both; margin:3px 0; padding: 3px 3px 4px 3px;display: inline-block;background:#4a8bc7;font-size:1em;color:#fff !important;text-decoration:none;")}	}
				//if(navigator.appName == IEFlag){buttons.className = "wbutton"}
				var visitbutton = current.buildHREF(search.visitweburl,vweb,vweb,"","","_blank")
				visitbutton.style.color = "#fff";
				visitbutton.style.textDecoration = "none"
				visitbutton.onclick = function(){Logging(this,search);var a='s.tl(';}
				buttons.appendChild(visitbutton)
				var span_button = document.createElement('p')
				if(cur_css == css_type){pStyle(span_button)}
				span_button.appendChild(buttons)
				child_div.appendChild(span_button)
			}
			//
			child_div.appendChild(result_p11)
			var courselist_div = current.buildDIV(("course_"+search.collegeid),null,null,null,null,null,null)
			courselist_div.setAttribute('style',"display:block;")
			if(cur_css == css_type){
				courselist_div.setAttribute('style',"clear:both; display:block;overflow:hidden;")
				if(navigator.appName == IEFlag){
					courselist_div.style.clear = "both"
					courselist_div.style.overflow = "hidden"
				}
			}
			if(navigator.appName == IEFlag){courselist_div.style.display = "block";}
			child_div.appendChild(courselist_div)
			hcrh.appendChild(child_div)
			if(length == 10){
				if(currentindex == (length-1)){
					var result_p2 = document.createElement('p')
					//result_p2.setAttribute('class',"vmwrap")
					result_p2.setAttribute('id','viewmore')
					if(cur_css == css_type){pStyle(courselist_div)}
					//if(navigator.appName == IEFlag){result_p2.className = "vmwrap";}
					if(cur_css == css_type){
					if(navigator.appName == IEFlag){
						result_p2.style.margin = "0";
						result_p2.style.padding = "0";
					}else{result_p2.setAttribute("style","margin:0;padding:0 0 5px;")}
					}
					var ahref = document.createElement('a')
					ahref.setAttribute('href',search.searchurl)
					ahref.setAttribute('title',vmore)
					//ahref.setAttribute('class',"vm")
					ahref.setAttribute('target',"_blank")
					if(cur_css == css_type){
						ahref.setAttribute('style',"cursor:pointer; ")
						if(navigator.appName == IEFlag){
							ahref.style.cursor = "pointer"}
					}
					//if(navigator.appName == IEFlag){ahref.className = "vm"}
					ahref.appendChild(document.createTextNode(vmore))
					ahref.style.color = ($$$('linkcolor') && $$$('linkcolor') != '' ? $$$('linkcolor').value : "#187ADB")
					result_p2.appendChild(ahref)
					hcrh.appendChild(result_p2)
			}	}
			parentresultdiv.appendChild(hcrh)
		}
		//
		if(search.PageName == 'PROVIDER_SEARCH'){
			var child_div = current.buildDIV("results",null,null,null,null,null,null)
			if(cur_css == css_type){resultStyle(child_div)}
			if(currentindex == 0){
				var hctl_div = document.createElement('div')
				hctl_div.setAttribute('id',"hctl")
				//hctl_div.setAttribute('class',"hctl")
				parentresultdiv.appendChild(hctl_div)
				var heading = document.createElement('h2')
				//heading.setAttribute('class',"head")
				if(cur_css == css_type){
					if(navigator.appName==IEFlag){
						heading.style.fontFamily = "Arial, Verdana, Helvetica, Sans-Serif"
						heading.style.fontSize = "1.4em"
						heading.style.margin = "0"
						heading.style.width = "auto"
						heading.style.styleFloat = "none"
						heading.style.height = "auto"
						heading.style.paddingBottom = "4px"
						heading.style.clear = "both"
					}else{
					heading.setAttribute("style","font-family: Arial, Verdana, Helvetica, Sans-Serif; margin:0; width:auto; float:none; font-size:1.4em; height:auto; padding-bottom:4px; clear:both;");
				}	}
				//
				//if(navigator.appName == IEFlag){heading.className = "head"}
				heading.appendChild(document.createTextNode(search.collegename))
				hctl_div.appendChild(heading)
				//
				if(search.visitweburl != ""){
					var buttons = document.createElement('span')
					//buttons.setAttribute('class',"wbutton")
					if(cur_css == css_type){
						buttons.setAttribute('style',"clear:both; float:left; margin:0; padding:0 0 5px;")
						if(navigator.appName == IEFlag){
							buttons.style.clear = "both"
							buttons.style.styleFloat = "left"
							buttons.style.margin = "0"
							buttons.style.padding = "0 0 5px"}
					}
					//if(navigator.appName == IEFlag){buttons.className = "wbutton"}
					var visitbutton = current.buildHREF(search.visitweburl,vweb,vweb,"","","_blank")
					visitbutton.onclick = function(){Logging(this,search);var a='s.tl(';}
					buttons.appendChild(visitbutton)
					var button_span = document.createElement('p')
					if(cur_css == css_type){pStyle(button_span)}
					button_span.appendChild(buttons)
					parentresultdiv.appendChild(button_span)
				}
				//
				var result_hp1 = document.createElement('p')
				result_hp1.setAttribute('id',"result_hp1")
				//result_hp1.setAttribute('class',"w1")
				if(cur_css == css_type){
					result_hp1.setAttribute('style',"padding:0 0 15px; margin:0; color:#558F00; clear:both;")
					w1Style(result_hp1)
				}
				//if(navigator.appName == IEFlag){result_hp1.className="w1"}
				result_hp1.appendChild(document.createTextNode(search.headmessage))
				hctl_div.appendChild(result_hp1)
			}
			//
			var result_p1 = document.createElement('p')
			//result_p1.setAttribute('class',"hccnt")
			if(cur_css == css_type){pStyle(result_p1)}
			//if(navigator.appName == IEFlag){result_p1.className="hccnt"}
			result_p1.appendChild(document.createTextNode(search.coursedesc))
			var result_p2 = document.createElement('p')
			//result_p2.setAttribute('class',"ttl")
			if(cur_css == css_type){pStyle(result_p2);result_p1.style.fontWeight='bold'}
			//if(navigator.appName == IEFlag){result_p2.className="ttl"}
			var ahref = document.createElement('a')
			ahref.setAttribute('href',search.url)
			ahref.setAttribute('title',search.coursetitle+search.country)
			//ahref.setAttribute('class',"c_link")
			//if(navigator.appName == IEFlag){ahref.className="c_link"}
			ahref.appendChild(document.createTextNode(search.coursetitle))
			var spancrs = document.createElement('span')
			result_p2.appendChild(ahref)
			var courselist_div = current.buildDIV("course_"+search.collegeid,null,null,null,null,null,null)
			courselist_div.setAttribute('style',"display:none;")
			if(cur_css == css_type){
				courselist_div.setAttribute('style',"clear:both; display:none;")
				if(navigator.appName==IEFlag){courselist_div.style.clear = "both"}
			}
			if(navigator.appName == IEFlag){courselist_div.style.display="none"}
			child_div.appendChild(result_p2)
			child_div.appendChild(result_p1)
			child_div.appendChild(courselist_div)
			//
			if(currentindex == (length-1)){
				var result_p3 = document.createElement('p')
				//result_p3.setAttribute('class',"clink")
				if(cur_css == css_type){pStyle(result_p3)}
				var amorehref = document.createElement('a')
				amorehref.setAttribute('href',search.coursemoreurl)
				amorehref.setAttribute('title',vcmore)
				//amorehref.setAttribute('class',"c_link")
				amorehref.appendChild(document.createTextNode(vcmore))
				//if(navigator.appName == IEFlag){amorehref.className="c_link"}
				var more_span=document.createElement('span')
				//more_span.setAttribute('class',"link")
				//if(navigator.appName == IEFlag){more_span.className="link"}
				more_span.appendChild(amorehref)
				child_div.appendChild(more_span)
			}
			//
			hcrh.appendChild(child_div)
			parentresultdiv.appendChild(hcrh)
		}
	}
	//
	current.addScript = function(url,rand){
		newScript = document.createElement("script")
		newScript.setAttribute('id','tackerloadimg')
		newScript.setAttribute("type","text/javascript")
		newScript.setAttribute("charset","utf-8")
		/* if(url.indexOf('?') > -1){
			url += '&'
		}else{
			url += '?'
		}
		if(rand != null){
			url += 'rand=' + Math.random()
		} */
		newScript.setAttribute("src",url)
		document.getElementsByTagName('head')[0].appendChild(newScript)
		return newScript
	}
	//
	current.addEvent = function(elm,evType,fn,useCapture){
		if(elm.AddEventListener){
			elm.AddEventListener(evType,fn,useCapture)
			return true
		}else if(elm.attachEvent){
			var r = elm.attachEvent(('on'+evType),fn)
			current.listeners[current.listeners.length] = [ elm,evType,fn ]
			return r
		}else{
			var xEventFn = elm[('on'+evType)]
			if(typeof elm[('on'+evType)] != 'function'){elm[('on'+evType)] = fn}
			else{elm[('on'+evType)] = function(e){xEventFn(e);fn(e);}}
		}
	}
	//
	current.insertAfter = function(parent,node,referenceNode){parent.insertBefore(node,referenceNode.nextSibling)}
	current.addEvent(window,'load',current.config,false)
}
//
function AddCustomisedWidget(objectName){
	var current
	var data
	if(this.constructor == AddCustomisedWidget){current=this
	}else{current = arguments[arguments.length-1]}
	contextpath = "/hcwidget"
	current.siteDomain = ''
	current.objectName = objectName
	current.containingNode
	current.css = ''
	current.listeners = []
	current.pageName = ''
	//
	
	current.config = function(jsonData){
		this.siteDomain = current.siteUrl
		if(document.getElementById){
				if(! document.location.href.indexOf("file:///")>-1){
				var mappingpath="/international-course-search/widget.html?dowhat=loadform"
				if($$$('affId') && $$$('affId').value != null ){
				mappingpath = mappingpath+ "&affId="+$$$('affId').value;
				}
				widgetsiteurl = $$$('siteUrl').value
				cur_css=current.css
				current.siteUrl=current.siteUrl+contextpath+mappingpath
				current.addScript(current.siteUrl+(current.siteUrl.indexOf('?')>-1 ? '&' : '?')+'callback='+objectName+'.loadResultData')
		}	}
	}
	//
	current.loadResultData = function(jsonData){
		data = jsonData.wgstart
		var rootdiv = document.createElement('div')
		current.containingNode = rootdiv
		current.containingNode.id = 'wcrt'
		if($$$('affId') && $$$('affId').value == 90409){current.containingNode.style.direction = "rtl"}
		if(cur_css == css_type){hcWidget(rootdiv)}
		current.buildFormContent(data)
		var inserted = false
		if(!inserted){
			var scr = $$$('AddFormWidgetScript')
			scr.parentNode.insertBefore(current.containingNode,scr)
			$$$("country").selectedIndex = 0
		}
	}
	
	//
	// -- <div> builder
	current.buildDIV = function(thisid,name,width,height,theclass,thistitle,content){
		var divcontainer=document.createElement('div')
		if(thisid !=null&&thisid !=''){divcontainer.setAttribute('id',thisid)}
		if(name !=null&&name !=''){divcontainer.setAttribute('name',name)}
		if(height !=null&&height !=''){divcontainer.setAttribute('height',height)}
		if(width !=null&&width !=''){divcontainer.setAttribute('width',width)}
		if(thistitle !=null&&thistitle !=''){divcontainer.setAttribute('title',thistitle);}
		if(content !=null&&content !=''){divcontainer.appendChild(document.createTextNode(content));}
		if(theclass !=null&&typeof(theclass)!='undefined'&&theclass !=''){
			divcontainer.setAttribute('class',theclass)
			if(navigator.appName == IEFlag){divcontainer.className=theclass}
		}
		return divcontainer
	}
	// -- <img> builder
	current.buildIMAGE = function(src,thisid,name,width,height,theclass,thistitle){
		var imagetag = document.createElement('img')
		imagetag.setAttribute('src',src)
		if(thisid != null && thisid != ''){imagetag.setAttribute('id',thisid)}
		if(name != null && name != ''){imagetag.setAttribute('name',name)}
		if(height != null && height != ''){imagetag.setAttribute('height',height)}
		if(width != null && width != ''){imagetag.setAttribute('width',width)}
		if(thistitle != null && thistitle != ''){
			imagetag.setAttribute('title',thistitle);
			imagetag.setAttribute('alt',thistitle);
		}
		if(theclass != null && typeof(theclass) != 'undefined' && theclass != ''){
			imagetag.setAttribute('class',theclass)
			if(navigator.appName == IEFlag){imagetag.className = theclass}
		}
		return imagetag
	}
	// -- <option> builder
	current.buildOPTION = function(text,value,theclass){
		var option = document.createElement('option')
		option.setAttribute('value',value)
		option.appendChild(document.createTextNode(text))
		if(typeof(theclass) != 'undefined' && theclass != ''){option.className = theclass}
		return option
	}
	// -- <a> builder
	current.buildHREF = function(href,title,value,theclass,nofollow,target){
		var ahref = document.createElement('a')
		if($$$('widgetId').value != null && $$$('widgetId').value == '' && theclass == 'visit_web'){href = href + "&widgetId=" + $$$('widgetId').value}
		ahref.setAttribute('href',href)
		ahref.setAttribute('title',title)
		if(cur_css == css_type){
			ahref.style.cursor = "pointer"
			//ahref.style.color = "#187ADB"
			ahref.style.color = ($$$('linkcolor') && $$$('linkcolor') != '' ? $$$('linkcolor').value : "#187ADB")
		}
		if(cur_css == css_type && theclass == 'visit_web'){
			if(navigator.appName == IEFlag){
				ahref.style.color="#FFF";
				ahref.style.cursor="pointer";
				ahref.style.fontFamily="Arial, Verdana, Helvetica, Sans-Serif";
				ahref.style.textDecoration="none";
				ahref.style.margin="3px 0px";
			}else{ahref.setAttribute('style'," font-family:Arial, Verdana, Helvetica, Sans-Serif;cursor:pointer;color: #FFFFFF !important;text-decoration: none;margin:3px 0;")}
		}
		if(cur_css == css_type && theclass == 'view'){
			ahref.setAttribute('style'," display:inline-block; cursor:pointer; color:#187ADB; text-decoration:none; margin-bottom:5px;")
			if(navigator.appName == IEFlag){
				ahref.style.display = "inline-block"
				ahref.style.marginBottom = "5px"
				ahref.style.cursor = "pointer"
				ahref.style.color = "#187ADB"
				ahref.style.textDecoration = "none"
			}
		}
		if(cur_css == css_type && theclass == 'c_link'){
			ahref.setAttribute('style'," color:#777; text-decoration:none;")
			if(navigator.appName == IEFlag){
				ahref.style.color = "#777"
				ahref.style.textDecoartion = "none"
			}
		}
		ahref.appendChild(document.createTextNode(value))
		if(typeof(theclass) != 'undefined' && theclass != ''){ahref.className = theclass}
		if(target != ''){
			ahref.setAttribute('target',target);
			if($$$('linkColor') && $$$('linkColor').value != null && theclass != 'visit_web'){ahref.style.color = $$$('linkColor').value != '' ? $$$('linkColor').value : ""}
		}
		if(target != ''){ahref.setAttribute('rel',nofollow)}
		return ahref
	}
	//
	current.buildCourseTitleItem = function(data,parentcoursediv){
		var coursetitle_ul = document.createElement('ul')
		var moreFlag = false;
		var result_pmore1;
		if(cur_css == css_type){ulStyle(coursetitle_ul)}
		for(var i=0;i<data.Results.length;i++){
			var coursedata = data.Results[i]
			var coursetitle_li = document.createElement('li')
			if($$$('linkView') && $$$('linkView').value == "true"){
				var tmpBlank;
				if($$$('embedCrs') && $$$('embedCrs').value == 'true'){tmpBlank = ""
				}else{tmpBlank = "_blank"}
				coursetitle_li.appendChild(current.buildHREF(coursedata.url,coursedata.coursetitle,coursedata.coursetitle,"","",tmpBlank))
				coursetitle_ul.appendChild(coursetitle_li)
			}else{
				coursetitle_li.appendChild(document.createTextNode(coursedata.coursetitle))
				coursetitle_ul.appendChild(coursetitle_li)
				coursetitle_ul.style.fontFamily = "Arial, Verdana, Helvetica, Sans-Serif"
				coursetitle_ul.style.fontSize = "0.9em"
				if($$$('linkColor') && $$$('linkColor').value != null){coursetitle_ul.setAttribute('style',("color:"+($$$('linkColor').value != '' ? $$$('linkColor').value : "")+";"));}
			}
			if(cur_css == css_type){
				coursetitle_li.style.margin="0 0 5px"				
				coursetitle_li.style.fontStyle="normal"
				coursetitle_li.style.fontWeight="normal"
				coursetitle_li.style.wordSpacing="normal"
				coursetitle_li.style.letterSpacing="normal"
				coursetitle_li.style.lineHeight="normal"
				coursetitle_li.style.textIndent="0"
				coursetitle_li.style.listStyle="none"
				coursetitle_li.style.border="0"
				coursetitle_li.style.backgroundColor="transparent"
				coursetitle_li.style.backgroundImage="url("+coursedata.arrowimg+")"
				coursetitle_li.style.backgroundRepeat="no-repeat"
				if($$$('affId').value==90409){
					coursetitle_li.style.padding="0 15px 0 0"
					coursetitle_li.style.backgroundPosition="right 5px"
				} else {
					coursetitle_li.style.padding="0 0 0 15px"
					coursetitle_li.style.backgroundPosition="3px 4px"
				}
				coursetitle_li.style.color="#187ADB"
			}
			if(i == data.Results.length-1 && coursedata.coursetcount > 10){
				result_pmore1 = document.createElement('p')
				if(cur_css == css_type){pStyle(result_pmore1)}
				//if(navigator.appName == IEFlag){}else{result_pmore1.setAttribute('class',"hccnt")}
				var vmore_span = document.createElement('span')
				vmore_span.appendChild(current.buildHREF(coursedata.coursemoreurl,vcmore,vcmore,"","","_blank"))
				result_pmore1.appendChild(vmore_span)
				moreFlag = true;
			}
		}
		parentcoursediv.innerHTML = ""
		parentcoursediv.appendChild(coursetitle_ul)
		if(moreFlag){
			parentcoursediv.appendChild(result_pmore1)
		}
	}
	//
	current.buildSearchItem = function(search,currentindex,parentresultdiv,selectedstudylevel,length,data,hcrh){
		if(search.PageName == 'SEARCH_RESULT'){
			if(currentindex == 0){
				var hctl_div = document.createElement('div')
				hctl_div.setAttribute('id',"hctl")
				hctl_div.setAttribute('class',"hctl")
				if(cur_css == css_type){
					if(navigator.appName == IEFlag){hctl_div.style.margin = "5px 0"
					}else{hctl_div.setAttribute("style","margin:5px 0;")}
				}
				parentresultdiv.appendChild(hctl_div)
				var heading = document.createElement('h2')
				heading.setAttribute('class',"head")
				if(cur_css == css_type){
					if(navigator.appName == IEFlag){
						heading.style.fontFamily = "Arial, Verdana, Helvetica, Sans-Serif"
						heading.style.fontSize = "14px"
						heading.style.margin = "0"
						heading.style.width = "auto"
						heading.style.styleFloat = "none"
						heading.style.height = "auto"
						heading.style.paddingBottom = "4px"
						heading.style.clear = "both"
					}else{heading.setAttribute("style","font-family: Arial, Verdana, Helvetica, Sans-Serif;margin:0;width:auto;float:none;font-size:1.1em;height:auto;padding-bottom:4px;clear:both;")}
				}
				if(navigator.appName == IEFlag){heading.className = "head"}
				heading.appendChild(document.createTextNode(data.Head[0].head1))
				if($$$('h2Color') && $$$('h2Color').value != null){heading.style.color = ($$$('h2Color').value != '' ? $$$('h2Color').value : "")}
				if($$$('searchbgColor') && $$$('searchbgColor').value != null){heading.style.background = ($$$('searchbgColor').value != null ? $$$('searchbgColor').value : "")}
				hctl_div.appendChild(heading)
				if(data.Head[0].head2 != ""){
					var result_he1 = document.createElement('p')
					if(cur_css == css_type){
						if(navigator.appName == IEFlag){
							result_he1.style.paddingBottom = "5px";
							result_he1.style.margin = "0";
						}else{result_he1.setAttribute("style","padding-bottom:5px;margin:0;")}
						result_he1.setAttribute('id',"result_he1")
						//result_he1.setAttribute('class',"w1")
					}
					//if(navigator.appName == IEFlag){result_he1.className = "w1"}
					result_he1.appendChild(document.createTextNode(data.Head[0].head2))
					if($$$('textColor') && $$$('textColor').value != null)
					result_he1.style.color = $$$('textColor').value
					hctl_div.appendChild(result_he1)
				}
				if(data.Head[0].head3 != ""){
					var result_he2 = document.createElement('p')
					result_he2.setAttribute('class',"w2")
					if(cur_css == css_type){
						result_he2.setAttribute('style',"margin: 0; padding: 0 0 5px;margin:0;")
						w1Style(result_he2)
					}
					if(navigator.appName == IEFlag){result_he2.className = "w2"}
					result_he2.appendChild(document.createTextNode(data.Head[0].head3))
					hctl_div.appendChild(result_he2)
				}
				if(data.Head[0].head4 != ""){
					var result_he3 = document.createElement('p')
					result_he3.setAttribute('class',"w3")
					if(navigator.appName == IEFlag){result_he3.className = "w3"}
					result_he3.appendChild(document.createTextNode(data.Head[0].head4))
					hctl_div.appendChild(result_he3)
				}
				if(data.Head[0].head5 != ""){
				var result_he4 = document.createElement('p')
				result_he4.setAttribute('class',"w4")
				if(navigator.appName == IEFlag){result_he4.className = "w4"}
				result_he4.appendChild(document.createTextNode(data.Head[0].head5))
				hctl_div.appendChild(result_he4)}
			}
			var child_div = current.buildDIV(null,null,null,null,null,null,null)
			if(cur_css == css_type){
				if(navigator.appName == IEFlag){
					child_div.style.display = "block";
					child_div.style.margin = "5px 0 8px 0";
					child_div.style.padding = "3px";
					child_div.style.borderBottom = "1px solid #cccccc";
					child_div.style.width = "89%";
				}else{child_div.setAttribute("style","display:block;margin:5px 0 8px 0;padding:3px;border-bottom:1px solid #cccccc;width:98%;")}
			}
			var result_p1 = document.createElement('p')
			//result_p1.setAttribute('class',"ttl")
				if(navigator.appName == IEFlag){
					result_p1.style.fontWeight = "bold";
					result_p1.style.paddingBottom = "2px";
					result_p1.style.margin = "0";
				}else{result_p1.setAttribute("style","font-weight:bold;padding:0 0 2px 0;margin:0;")}
			
			//if(navigator.appName == IEFlag){result_p1.className = "hccnt"}
			result_p1.appendChild(document.createTextNode(search.collegename))
			if($$$('textColor') && $$$('textColor').value != null){result_p1.style.color = $$$('textColor').value}
			var result_p11 = document.createElement('p')
			//result_p11.setAttribute('class',"clink")
			if(cur_css == css_type){
				if(navigator.appName == IEFlag){
					result_p11.style.margin = "0";
					result_p11.style.padding = "0";
				}else{result_p11.setAttribute("style","margin:0;padding:0;")}
			}
			var ahref11 = document.createElement('a')
			if(cur_css == css_type){
				if(navigator.appName == IEFlag){
					ahref11.style.margin = "0";
					ahref11.style.paddingBottom = "0px";
					ahref11.style.color = "#187ADB";
					ahref11.style.cursor = "pointer";
				}else{ahref11.setAttribute("style","margin:0; padding:0; color:#187ADB; cursor:pointer;")}
			}
			ahref11.setAttribute('title',search.coursehead)
			//ahref11.setAttribute('class',"crs")
			//if(navigator.appName == IEFlag){ahref11.className = "crs"}
			ahref11.style.color=($$$('linkColor') && $$$('linkColor').value != null ? $$$('linkColor').value : "#187ADB")
			ahref11.onclick = function(){return CourseTitleWidget(search.collegeid,search.CourseCount)}
			ahref11.appendChild(document.createTextNode(search.coursehead))
			var spancrs = document.createElement('span')
			spancrs.setAttribute('class',"link")
			if(navigator.appName == IEFlag){spancrs.className = "link"}
			spancrs.appendChild(ahref11)
			result_p11.appendChild(spancrs)
			child_div.appendChild(result_p1)
			if(search.visitweburl != ""){
				var buttons = document.createElement('span')
				//buttons.setAttribute('class',"wbutton")
				if(cur_css == css_type){
					if(navigator.appName == IEFlag){
						buttons.style.clear = "both"
						buttons.style.margin = "0"
						buttons.style.padding = "3px 3px 4px 3px";
						buttons.style.display = "inline-block";
						buttons.style.background = "#4a8bc7";
						buttons.style.color = "#fff";
						buttons.style.textDecoration = "none"
					}else{buttons.setAttribute('style',"clear:both; margin:3px 0; padding: 3px 3px 4px 3px;display: inline-block;background:#4a8bc7;font-size:1em;color:#fff !important;text-decoration:none;")}
				}
				//if(navigator.appName == IEFlag){buttons.className = "wbutton"}
				var visitbutton = current.buildHREF(search.visitweburl,vweb,vweb,"","","_blank")
				visitbutton.onclick = function(){Logging(this,search);var a='s.tl(';}
				buttons.appendChild(visitbutton)
				var span_button = document.createElement('p')
				if(cur_css == css_type){
					if(navigator.appName == IEFlag){
						span_button.style.margin = "0";
						span_button.style.padding = "0";
					}else{span_button.setAttribute("style","margin:0;padding:0;")}
				}
				span_button.appendChild(buttons)
				child_div.appendChild(span_button)
			}
			child_div.appendChild(result_p11)
			var courselist_div = current.buildDIV(("course_"+search.collegeid),null,null,null,null,null,null)
			courselist_div.setAttribute('style',"display:block;")
			if(cur_css == css_type){
				courselist_div.setAttribute('style',"clear:both; display:block;")
				if(navigator.appName == IEFlag){courselist_div.style.clear = "both"}
			}
			if(navigator.appName == IEFlag){courselist_div.style.display = "block"}
			child_div.appendChild(courselist_div)
			hcrh.appendChild(child_div)
			if(currentindex == (length-1)){
				var result_p2 = document.createElement('p')
				//result_p2.setAttribute('class',"vmwrap")
				result_p2.setAttribute('id','viewmore')
				if(cur_css == css_type){
					if(navigator.appName == IEFlag){
						result_p2.style.margin = "0";
						result_p2.style.padding = "0";
					}else{result_p2.setAttribute("style","margin:0;padding:0 0 5px;")}
				}
				//if(navigator.appName == IEFlag){result_p2.className = "vmwrap"}
				var ahref = document.createElement('a')
				ahref.setAttribute('href',search.searchurl)
				ahref.setAttribute('title',vmore)
				//ahref.setAttribute('class',"vm")
				ahref.setAttribute('target',"_blank")
				if(cur_css == css_type){
					if(navigator.appName == IEFlag){
						ahref.style.color = "#187ADB";
						ahref.style.cursor = "pointer";
						ahref.style.fontFamily = "Arial, Verdana, Helvetica, Sans-Serif"
					}else{ahref.setAttribute('style',"font-family:Arial, Verdana, Helvetica, Sans-Serif;color:#187ADB; cursor:pointer; ")}
				}
				ahref.appendChild(document.createTextNode(vmore))
				ahref.style.color = ($$$('linkColor') && $$$('linkColor').value != null ? $$$('linkColor').value : "#187ADB")
				result_p2.appendChild(ahref)
				hcrh.appendChild(result_p2)
			}
			parentresultdiv.appendChild(hcrh)
		}
		if(search.PageName == 'PROVIDER_SEARCH'){
			var child_div = current.buildDIV("results",null,null,null,null,null,null)
			if(cur_css == css_type){resultStyle(child_div)}
			if(currentindex == 0){
				var hctl_div = document.createElement('div')
				hctl_div.setAttribute('id',"hctl")
				hctl_div.setAttribute('class',"hctl")
				parentresultdiv.appendChild(hctl_div)
				var heading = document.createElement('h2')
				heading.setAttribute('class',"head")
				if(cur_css == css_type){h2Style(heading)}
				if(navigator.appName == IEFlag){heading.className = "head"}
				heading.appendChild(document.createTextNode(search.collegename))
				hctl_div.appendChild(heading)
				if(search.visitweburl != ""){
					var buttons = document.createElement('span')
					//buttons.setAttribute('class',"wbutton")
					if(cur_css == css_type){
						buttons.setAttribute('style',"clear:both; float:left; margin:0; padding:0 0 5px;")
						if(navigator.appName == IEFlag){
							buttons.style.clear = "both"
							buttons.style.styleFloat = "left"
							buttons.style.margin = "0"
							buttons.style.padding = "0 0 5px"
						}
					}
					var visitbutton = current.buildHREF(search.visitweburl,vweb,vweb,"","","_blank")
					visitbutton.onclick = function(){Logging(this,search);var a='s.tl(';}
					buttons.appendChild(visitbutton)
					var button_span = document.createElement('p')
					if(cur_css == css_type){pStyle(button_span)}
					button_span.appendChild(buttons)
					parentresultdiv.appendChild(button_span)
				}
				var result_hp1 = document.createElement('p')
				result_hp1.setAttribute('id',"result_hp1")
				//result_hp1.setAttribute('class',"w1")
				if(cur_css == css_type){
					result_hp1.setAttribute('style',"padding:0 0 15px; margin:0; color:#558F00; clear:both;")
					w1Style(result_hp1)
				}
				//if(navigator.appName == IEFlag){result_hp1.className = "w1"}
				result_hp1.appendChild(document.createTextNode(search.headmessage))
				hctl_div.appendChild(result_hp1)
			}
			var result_p1 = document.createElement('p')
			//result_p1.setAttribute('class',"hccnt")
			if(cur_css == css_type){pStyle(result_p1)}
			//if(navigator.appName == IEFlag){result_p1.className = "hccnt"}
			result_p1.appendChild(document.createTextNode(search.coursedesc))
			var result_p2 = document.createElement('p')
			//result_p2.setAttribute('class',"ttl")
			if(cur_css == css_type){pStyle(result_p2);result_p1.style.fontWeight='bold'}
			//if(navigator.appName == IEFlag){result_p2.className = "ttl"}
			var ahref = document.createElement('a')
			ahref.setAttribute('href',search.url)
			ahref.setAttribute('title',search.coursetitle+search.country)
			ahref.setAttribute('class',"c_link")
			if(navigator.appName == IEFlag){ahref.className = "c_link"}
			ahref.appendChild(document.createTextNode(search.coursetitle))
			var spancrs = document.createElement('span')
			result_p2.appendChild(ahref)
			var courselist_div = current.buildDIV(("course_"+search.collegeid),null,null,null,null,null,null)
			courselist_div.setAttribute('style',"display:none;")
			if(cur_css == css_type){
				courselist_div.setAttribute('style',"clear:both; display:none;")
				if(navigator.appName == IEFlag){courselist_div.style.clear = "both"}
			}
			if(navigator.appName == IEFlag){courselist_div.style.display = "none"}
			child_div.appendChild(result_p2)
			child_div.appendChild(result_p1)
			child_div.appendChild(courselist_div)
			if(currentindex == (length-1)){
				var result_p3 = document.createElement('p')
				//result_p3.setAttribute('class',"clink")
				if(cur_css == css_type){pStyle(result_p3)}
				var amorehref = document.createElement('a')
				amorehref.setAttribute('href',search.coursemoreurl)
				amorehref.setAttribute('title',vcmore)
				amorehref.setAttribute('class',"c_link")
				amorehref.appendChild(document.createTextNode(vcmore))
				if(navigator.appName == IEFlag){amorehref.className = "c_link"}
				var more_span = document.createElement('span')
				more_span.setAttribute('class',"link")
				if(navigator.appName == IEFlag){more_span.className = "link"}
				more_span.appendChild(amorehref)
				child_div.appendChild(more_span)
			}
			hcrh.appendChild(child_div)
			parentresultdiv.appendChild(hcrh)
		}
	}
	//
	current.addScript = function(url, rand){
		newScript = document.createElement("script")
		newScript.setAttribute('id','tackerloadimg')
		newScript.setAttribute("type","text/javascript")
		newScript.setAttribute("charset","utf-8")
		/* if(url.indexOf('?') > -1){url += '&'
		}else{url += '?'}
		if(rand != null){url += 'rand=' + Math.random()} */
		newScript.setAttribute("src",url)
		document.getElementsByTagName('head')[0].appendChild(newScript)
		return newScript
	}
	//
	current.addEvent = function(elm,evType,fn,useCapture){
		if(elm.AddEventListener){
			elm.AddEventListener(evType,fn,useCapture)
			return true
		}else if(elm.attachEvent){
			var r = elm.attachEvent(('on'+evType),fn)
			current.listeners[current.listeners.length] = [ elm,evType,fn ]
			return r
		}else{
			var xEventFn = elm[('on'+evType)]
			if(typeof elm[('on'+evType)] != 'function'){elm[('on'+evType)] = fn
			}else{elm[('on'+evType)] = function(e){xEventFn(e);fn(e);}}
		}
	}
	current.insertAfter = function(parent,node,referenceNode){parent.insertBefore(node,referenceNode.nextSibling)}
	current.addEvent(window,'load',current.config,false)
}
//
function CourseTitleWidget(collegeId,displayresult){
	var subjectFilter = ''
	var keyobject = $$$("keyword")
	var subobject = $$$("category")
	var cidobject = $$$("collegeid_hidden")
	var studylevelobject = $$$("qual")
	var studymodeobject = $$$("smode")
	var locationobject = $$$("country")
        var widgetId = $$$("widgetId").value;
	var kwrd = keyobject != null ?(keyobject.value != defauttkeytext ? keyobject.value : "") : ""
	var kwrd_hidden = $$$("keyword_hidden")
	var sub = subobject != null ? (subobject.selectedIndex >= 0 ? replaceSpecialChar(subobject.options[subobject.selectedIndex].value): replaceSpecialChar(subjectFilter)) : replaceSpecialChar(subjectFilter)
	var kwrdhidden = (kwrd_hidden != null ? kwrd_hidden.value : "");
	if((sub == 'none' || sub=='')&& kwrdhidden!=""){
		sub = kwrdhidden;
		kwrd = "";
	}
	var studylevel = studylevelobject != null ? (studylevelobject.selectedIndex >= 0 ? studylevelobject.options[studylevelobject.selectedIndex].value : "") : ""
	var studymode = studymodeobject != null ? (studymodeobject.selectedIndex >= 0 ? studymodeobject.options[studymodeobject.selectedIndex].value : "") : ""
	var location = locationobject != null ? (locationobject.selectedIndex >= 0 ? locationobject.options[locationobject.selectedIndex].value : "") : ""
	//
	if(subobject == null ){
		sub = $$$('defaultsub') ? $$$('defaultsub').value : "";
	}
	if(studylevelobject == null ){
		studylevel = $$$('defaultqual') ? $$$('defaultqual').value : "";
	}
	if(studymodeobject == null ){
		studymode = $$$('defaultsmode') ? $$$('defaultsmode').value : "";
	}
	if(locationobject == null ){
		location = $$$('defaultcountry') ? $$$('defaultcountry').value : "";
	}
	//	
	var affId = ''
	if($$$("affId").value != ''){affId = $$$("affId").value;}
	else{affId = '290408';}
	
	if(affId == '130308'){ location = (location != '' ? "&location=" + location : "") }
	else{ location = (location != '' ? (location != 'none' ? "&location=" + location : "") : "") }
	
	var tmpEmbedCrs = ''
	if ($$$("embedCrs1") != null){tmpEmbedCrs = $$$("embedCrs1").checked
	}else if($$$("embedCrs")){tmpEmbedCrs = $$$("embedCrs").value
	}else {tmpEmbedCrs = 'false'}
	//
	var current = null;
	if($$$("custwidget") != null){current = new AddCustomisedWidget('hcwidget')
	}else{current = new AddFormWidget('hcwidget')}
	var siteUrl = widgetsiteurl
	if($$$(("course_"+collegeId)) != null){
		if($$$(("course_"+collegeId)).innerHTML != ''){
			if($$$(("course_"+collegeId)).style.display == 'block'){hideblock(("course_"+collegeId),"none")
			}else{hideblock(("course_"+collegeId),"block")}
			return false
		}else{
			if(affId==60307){
				lineloader = "http://images1.content-ug.com/widget-cont/img/ajax-line-loader.gif"
			}else if(affId==130308){
				lineloader = "http://images1.content-aus.com/widget-cont/img/ajax-line-loader.gif"
			}else if(affId==260109){
				lineloader = "http://images1.6student.cn/widget-cont/img/ajax-line-loader.gif"
			}else {
				lineloader = "http://images1.content-hca.com/widget-cont/img/ajax-line-loader.gif"
			}
			$$$(("course_"+collegeId)).innerHTML = "<div><img src='"+lineloader+"'/></div>"
		};
	}
	current.siteUrl = siteUrl
	//
	current.config = function(jsonData){
		if(document.getElementById){
			if(! document.location.href.indexOf("file:///") >- 1){

				var mappingpath = "/widget/search-result.html?dowhat=exapndcourse"
				current.siteUrl = $$$('siteUrl').value + contextpath + mappingpath									
									+ (kwrd != '' && $$$('defauttkeytext') && kwrd != $$$('defauttkeytext').value ? "&kwrd=" + replaceAll(kwrd," ","+") : "")									
									+ (sub!='' ? "&sub=" + replaceAll(sub," ","+") : "")
									+ (collegeId != '' ? "&cid=" + collegeId : "")
									+ (studylevel != '' ? (studylevel != '-999' ? "&studylevel=" + replaceAll(studylevel," ","+") : "&studylevel=-999") : "&studylevel=-999")
									+ (studymode != '' ? "&studymode=" + studymode : "")
									//+ (location != '' ? "&location=" + location : "")
									//+ (location != '' ? (location != 'none' ? "&location=" + location : "") : "")
									+ location
									+ (displayresult != '' ? "&displayresult=" + displayresult : "100")
									+ ("&affId=" + affId)
									+ "&embedCrs=" + tmpEmbedCrs
                                                                        + "&widgetId=" + widgetId;
									
				//alert((current.siteUrl+(current.siteUrl.indexOf('?')>-1?'&':'?')+'callback=CourseTitleWidget.loadSearchData'));
				current.addScript((current.siteUrl+(current.siteUrl.indexOf('?')>-1?'&':'?')+'callback=CourseTitleWidget.loadSearchData'),'rand')
	}	}	}
	//
	current.config()
	CourseTitleWidget.loadSearchData = function(jsonData){
		data = jsonData.SearchResults
		current.buildCourseTitle()
	}
	current.buildCourseTitle = function(){
		var parentautodiv = $$$("course_"+collegeId)
		current.buildCourseTitleItem(data,parentautodiv)
	}
	return false
}
//
//amw007_20111011_Syed: adding EmbedCourseDetailsWidget to build course details
//
function EmbedCourseDetailsWidget(courseId,affId,collegeId,suborderItemId,cpeQuallevel,categoryCode,keyword,countryId){
	showCourseDetails();
	var current = null;
	if($$$("custwidget") && $$$("custwidget").value != null){
		current = new AddCustomisedWidget('hcwidget')
	} else {
		current = new AddFormWidget('hcwidget')
	}
	var siteUrl = widgetsiteurl
	current.siteUrl = siteUrl
	//
	current.config = function(jsonData){
		if(document.getElementById){
			if(! document.location.href.indexOf("file:///") > -1){
				var mappingpath = "/widget/embed/course-details.html?"
									+ "affId=" + affId
									+ "&courseId=" + courseId
									+ "&collegeId=" + collegeId
									+ "&suborderItemId=" + suborderItemId
									+ "&cpeQuallevel=" + cpeQuallevel
									+ "&categoryCode=" + categoryCode
									+ "&keyword=" + keyword
									+ "&countryId=" + countryId;
				current.siteUrl = $$$('siteUrl').value + contextpath + mappingpath;
				$$$("crsLoader").style.display = "block";
				$$$("crsDiv").style.display = "none";
				current.addScript(current.siteUrl + '&callback=EmbedCourseDetailsWidget.loadSearchData','rand')
	}	}	}
	current.config()
	//
	EmbedCourseDetailsWidget.loadSearchData = function(jsonData){
		data = jsonData.CourseDetailsInfo
		current.embedCourseDetails()
	}
	//
	current.embedCourseDetails = function(){
		var embCrsDIV = $$$("crsDiv")
		embCrsDIV.innerHTML = "";
		current.embedCourseDetailsItem(data, embCrsDIV)
	}
	//
	current.embedCourseDetailsItem = function(data, embCrsDIV){
		$$$("hcns").style.display = 'none';
		$$$("backresult").style.display = 'block';
		$$$("back").style.display = 'block';
		for(var i=0;i<data.CourseDetails.length;i++){
			var crsDetailsJSON = data.CourseDetails[i];
			//
			if(crsDetailsJSON.COURSE_TITLE != null){
				var crsTitle = document.createElement('span');
				crsTle(crsTitle)
				crsTitle.appendChild(document.createTextNode(crsDetailsJSON.COURSE_TITLE));
				embCrsDIV.appendChild(crsTitle);
			}
			//
			if(crsDetailsJSON.INSTITUTION_NAME != null){
				var colName = document.createElement('span');
				crsInst(colName)
				colName.appendChild(document.createTextNode(crsDetailsJSON.INSTITUTION_NAME));
				embCrsDIV.appendChild(colName);
			}
			//
			if(data.ButtonDetails[0].VIST_WEBSITE_LINK != null && data.ButtonDetails[0].VIST_WEBSITE_LINK != ""){				
                var webBtn = current.buildHREF(data.ButtonDetails[0].VIST_WEBSITE_LINK,vweb,vweb,"","","_blank")
				crsWeb(webBtn)
				webBtn.onclick=function(){Logging(this,data.ButtonDetails[0]);var a='s.tl(';}
				embCrsDIV.appendChild(webBtn)
			}
			//
			var divLine = document.createElement('span');
			crsLine(divLine)
			embCrsDIV.appendChild(divLine);
			//
			if(crsDetailsJSON.COURSE_SUMMARY != null){
				var crsSumKey = document.createElement('span');
				crsSpan(crsSumKey)
				crsSumKey.style.paddingTop = "3px"
				crsSumKey.appendChild(document.createTextNode('Course summary'));
				embCrsDIV.appendChild(crsSumKey);
				var crsSumVal = document.createElement('span');
				crsText(crsSumVal)
				//crsSumVal.appendChild(document.createTextNode(crsDetailsJSON.COURSE_SUMMARY));
				crsSumVal.innerHTML = crsDetailsJSON.COURSE_SUMMARY;
				embCrsDIV.appendChild(crsSumVal);
			}
			//
			if(crsDetailsJSON.MODULES != null){
				var prgModuKey = document.createElement('span');
				crsSpan(prgModuKey)
				prgModuKey.appendChild(document.createTextNode('Program modules'));
				embCrsDIV.appendChild(prgModuKey);
				var prgModuVal = document.createElement('span');
				crsText(prgModuVal)
				prgModuVal.appendChild(document.createTextNode(crsDetailsJSON.MODULES));
				embCrsDIV.appendChild(prgModuVal);
			}
			//
			if(crsDetailsJSON.QUAL != null){
				var qualKey = document.createElement('span');
				crsSpan(qualKey)
				qualKey.appendChild(document.createTextNode('Qualification'));
				embCrsDIV.appendChild(qualKey);
				var qualVal = document.createElement('span');
				crsText(qualVal)
				qualVal.appendChild(document.createTextNode(crsDetailsJSON.QUAL));
				embCrsDIV.appendChild(qualVal);
			}
			//
			if(crsDetailsJSON.AWARDING_BODY != null){
				var awardKey = document.createElement('span');
				crsSpan(awardKey)
				awardKey.appendChild(document.createTextNode('Awarding body'));
				embCrsDIV.appendChild(awardKey);
				var awardVal = document.createElement('span');
				crsText(awardVal)
				awardVal.appendChild(document.createTextNode(crsDetailsJSON.AWARDING_BODY));
				embCrsDIV.appendChild(awardVal);
			}
			//
			if(crsDetailsJSON.TAUGHT_RESEARCH_PG != null){
				var tatResPgKey = document.createElement('span');
				crsSpan(tatResPgKey)
				tatResPgKey.appendChild(document.createTextNode('Taught research PG'));
				embCrsDIV.appendChild(tatResPgKey);
				var tatResPgVal = document.createElement('span');
				crsText(tatResPgVal)
				tatResPgVal.appendChild(document.createTextNode(crsDetailsJSON.TAUGHT_RESEARCH_PG));
				embCrsDIV.appendChild(tatResPgVal);
			}
			//
			if(crsDetailsJSON.TARGET_AUDIENCE_FE != null){
				var tarAudKey = document.createElement('span');
				crsSpan(tarAudKey)
				tarAudKey.appendChild(document.createTextNode('Target audience FE'));
				embCrsDIV.appendChild(tarAudKey);
				var tarAudVal = document.createElement('span');
				crsText(tarAudVal)
				tarAudVal.appendChild(document.createTextNode(crsDetailsJSON.TARGET_AUDIENCE_FE));
				embCrsDIV.appendChild(tarAudVal);
			}
			//
			if(crsDetailsJSON.COURSE_LEVEL_FE != null){
				var crsLevFeKey = document.createElement('span');
				crsSpan(crsLevFeKey)
				crsLevFeKey.appendChild(document.createTextNode('Course level FE'));
				embCrsDIV.appendChild(crsLevFeKey);
				var crsLevFeVal = document.createElement('span');
				crsText(crsLevFeVal)
				crsLevFeVal.appendChild(document.createTextNode(crsDetailsJSON.COURSE_LEVEL_FE));
				embCrsDIV.appendChild(crsLevFeVal);
			}
			//
			if(crsDetailsJSON.DOM_ADMISSION_REQ != null){
				var domAdmReqKey = document.createElement('span');
				crsSpan(domAdmReqKey)
				domAdmReqKey.appendChild(document.createTextNode('Domestic admission requirement'));
				embCrsDIV.appendChild(domAdmReqKey);
				var domAdmReqVal = document.createElement('span');
				domAdmReqVal.setAttribute('style', 'padding:0px 3px 8px 3px; font-size:11px;font-weight:normal;display:block;');
				domAdmReqVal.appendChild(document.createTextNode(crsDetailsJSON.DOM_ADMISSION_REQ));
				embCrsDIV.appendChild(domAdmReqVal);
			}
			//
			if(crsDetailsJSON.ADMISSION_REQ_DEGREES != null){
				var admReqDegKey = document.createElement('span');
				crsSpan(admReqDegKey)
				admReqDegKey.appendChild(document.createTextNode('Admission requirement (degrees)'));
				embCrsDIV.appendChild(admReqDegKey);
				var admReqDegVal = document.createElement('span');
				crsText(admReqDegVal)
				admReqDegVal.appendChild(document.createTextNode(crsDetailsJSON.ADMISSION_REQ_DEGREES));
				embCrsDIV.appendChild(admReqDegVal);
			}
			//
			if(crsDetailsJSON.DEPT_NAME != null){
				var deptNamKey = document.createElement('span');
				crsSpan(deptNamKey)
				deptNamKey.appendChild(document.createTextNode('Department name'));
				embCrsDIV.appendChild(deptNamKey);
				var deptNamVal = document.createElement('span');
				crsText(deptNamVal)
				deptNamVal.appendChild(document.createTextNode(crsDetailsJSON.DEPT_NAME));
				embCrsDIV.appendChild(deptNamVal);
			}
		}
		// display crs-oppertunities
		var oppKey = document.createElement('span');
		crsSpan(oppKey)
		oppKey.appendChild(document.createTextNode("Course variations"));
		embCrsDIV.appendChild(oppKey);
		//
		for(var i=0;i<data.CourseOppertunities.length;i++){
			var oppJSON = data.CourseOppertunities[i];
			var opp = "";//[ duration ] [ study mode ] course starting [ date ] - [ price, pri	ce desc ]
			if(oppJSON.DURATION != null){
				opp	= opp + oppJSON.DURATION + " "
			}if(oppJSON.STUDY_MODE != null){
				opp = opp + oppJSON.STUDY_MODE + " "
			}if(oppJSON.START_DATE != null){
				opp = opp + "course starting " + oppJSON.START_DATE + " "
			}if(oppJSON.INTL_CRS_COST != null){
				opp	= opp + "- " + oppJSON.INTL_CRS_COST + " "
			}if(oppJSON.INTL_COST_FURTHER_DETAILS != null){
				opp	= opp + oppJSON.INTL_COST_FURTHER_DETAILS + " "
			}
			var oppVal = document.createElement('span');
			crsText(oppVal)
			oppVal.appendChild(document.createTextNode(opp));
			embCrsDIV.appendChild(oppVal);
		}
		if(data.ButtonDetails[0].VIST_WEBSITE_LINK != null && data.ButtonDetails[0].VIST_WEBSITE_LINK != ""){			
            var webBtn = current.buildHREF(data.ButtonDetails[0].VIST_WEBSITE_LINK,vweb,vweb,"","","_blank")
			crsWeb(webBtn)
			webBtn.onclick=function(){Logging(this,data.ButtonDetails[0]);var a='s.tl(';}
			embCrsDIV.appendChild(webBtn)
		}
		//
		$$$("crsLoader").style.display = "none";
		$$$("crsDiv").style.display = "block";
	}
	// CD styles
	function crsTle(o){
		o.style.padding = "2px"
		o.style.fontSize = "13px"
		o.style.display = "block"
		o.style.fontWeight = "bold"
		o.style.clear = "both"
	}
	function crsInst(o){
		o.style.padding = "3px 3px 0"
		o.style.fontSize = "12px"
		o.style.display = "block"
		o.style.fontWeight = "bold"
	}
	function crsLine(o){
		o.style.padding = "0px 3px 5px 0px"
		o.style.borderBottom = "1px solid #ccc"
		o.style.display = "block"
		o.style.margin = "2px 0 1px"
	}
	function crsSpan(o){
		o.style.padding = "0px 3px 3px 3px"
		o.style.fontSize = "12px"
		o.style.display = "block"
		o.style.fontWeight = "bold"
	}
	function crsText(o){
		o.style.padding = "0px 3px 8px 3px"
		o.style.fontSize = "11px"
		o.style.fontWeight = "normal"
		o.style.display = "block"
	}
	function crsBack(o){
		o.style.styleFloat = "right"
		o.style.textDecoration = "underline"
		o.style.cursor = "pointer"
		o.style.padding = "0 15px"
	}
	function crsWeb(o){
		o.style.background ="#4A8BC7"
		o.style.display = "inline-block"
		o.style.margin = "5px 0 0"
		o.style.padding = "3px 3px 4px"
		o.style.color = "#FFFFFF"
		o.style.fontSize = "1em"
	}
	//
	//return false
}
Inherit(AddFormWidget,EmbedCourseDetailsWidget);
//
function SubmitWidget(objectName){
	var resPadHeight = $$$("wdres").offsetHeight + 'px';
	$$$("w_row").style.height = resPadHeight;
	var subjectFilter = ''
	subjerr = $$$('subjecterror').value
	vmore = $$$('viewmoreinstitution').value
	vcmore = $$$('viewmorecourses').value
	vweb = $$$('viewwebsite').value
        var widgetId = $$$("widgetId").value;
	var keyobject = $$$("keyword")
	var subobject = $$$("category")
	var studylevelobject = $$$("qual")
	var studymodeobject = $$$("smode")
	var locationobject = $$$("country")
	var kwrd_hidden = $$$("keyword_hidden")
	var kwrd = keyobject != null ? (keyobject.value != defauttkeytext ? keyobject.value : "") : ""
	var sub = subobject != null ? (subobject.selectedIndex >= 0 ? replaceSpecialChar(subobject.options[subobject.selectedIndex].value) :  replaceSpecialChar(subjectFilter)) : "none"
	var kwrdhidden = (kwrd_hidden != null ? kwrd_hidden.value : "");
	if((sub == 'none' || sub == '') && kwrdhidden != ""){
		sub = kwrdhidden;
		kwrd = "";
	}
	var studylevel = studylevelobject != null ? (studylevelobject.selectedIndex >= 0 ? studylevelobject.options[studylevelobject.selectedIndex].value : "") : ""
	var studymode = studymodeobject != null ? (studymodeobject.selectedIndex >= 0 ? studymodeobject.options[studymodeobject.selectedIndex].value : "") : ""
	var location = locationobject != null ? (locationobject.selectedIndex >= 0 ? locationobject.options[locationobject.selectedIndex].value : "") : ""
	//
	if(subobject == null ){
		sub = $$$('defaultsub') ? $$$('defaultsub').value : "";
	}
	if(studylevelobject == null ){
		studylevel = $$$('defaultqual') ? $$$('defaultqual').value : "";
	}
	if(studymodeobject == null ){
		studymode = $$$('defaultsmode') ? $$$('defaultsmode').value : "";
	}
	if(locationobject == null ){
		location = $$$('defaultcountry') ? $$$('defaultcountry').value : "";
	}
	//
	var affId = ''
	if ($$$("affId") != null){if($$$("affId").value != ''){affId = $$$("affId").value}
	}else{affId = 290408}
	//	
	// ---<validate form>---
	
	//alert("kwrd:->"+kwrd+ "<-\n sub:->"+sub+"<-")
	if(affId == 130308){
		if(studylevel == 'null' || studylevel == ""){
			alert("Oops! please select a qualification level");
			return false
		}
	}else{
		if((kwrd == '' || kwrd == $$$('defauttkeytext').value ) && (sub == 'none' || sub == '')){alert(subjerr);return false}		
	}
	//
	$$$('loader').style.display = "inline"
	if(affId==60307){
		ajaxloader = "http://images1.content-ug.com/widget-cont/img/ajax-loader.gif"
	} else if(affId==130308){
		ajaxloader = "http://images1.content-aus.com/widget-cont/img/ajax-loader.gif"
	} else if(affId==260109){
		ajaxloader = "http://images1.6student.cn/widget-cont/img/ajax-loader.gif"
	} else {
		ajaxloader = "http://images1.content-hca.com/widget-cont/img/ajax-loader.gif"
	}
	$$$('loader').innerHTML = "<img src='"+ajaxloader+"' title='Loading' alt='Loading' />"	
	var current = null;
	current = new AddFormWidget('hcwidget')
	var siteUrl = $$$("siteUrl").value;
	current.siteUrl = siteUrl
	//
	current.config = function(jsonData){
		if(document.getElementById){
			if(! document.location.href.indexOf("file:///") > -1){
				var mappingpath = "/widget/search-result.html?dowhat=get"
				current.siteUrl = current.siteUrl + contextpath + mappingpath
									+ (kwrd != '' && $$$('defauttkeytext') && kwrd != $$$('defauttkeytext').value ? "&kwrd=" + replaceAll(kwrd," ","+") : "")
									+ (sub != '' ? "&sub=" + replaceAll(sub," ","+") : "")
									+ (studylevel != '' ? (studylevel != '-999' ? "&studylevel=" + replaceAll(studylevel," ","+") : "") : "")
									+ (studymode != '' ? "&studymode=" + studymode : "")
									+ (location != '' ? "&location=" + location : "")
									+ "&affId=" + affId
									+ "&excludeColleges=" + $$$('excludeColleges').value
                                                                        + "&widgetId="+widgetId;
				//alert((current.siteUrl + (current.siteUrl.indexOf('?') > -1 ? '&' : '?') + 'callback=' + objectName + '.loadSearchData'))
				current.addScript((current.siteUrl + (current.siteUrl.indexOf('?') > -1 ? '&' : '?') + 'callback=' + objectName + '.loadSearchData'),'rand')
	}	}	}
	//
	current.config()
	SubmitWidget.loadSearchData = function(jsonData){
		data = jsonData.SearchResults
		current.buildSearchResult()
	}
	current.buildSearchResult = function(){
		var parentresultdiv = $$$("hcrs_div")
		parentresultdiv.innerHTML = ""
		if($$$("searchbgColor") != null){parentresultdiv.style.background = $$$("searchbgColor").value}
		if(data.Results.length == 0){
			noneblock("submitajax","none")
			$$$("hcrs_div").innerHTML = "<p class='hcermsg' style='color:#f00;font-weight:bold'>" + data.logResult[0].noresult + "</p>"
			$$$('loader').style.display = "none"
		}else{
			includeImpression(data.logResult[0])
			$$$('loader').style.display = "none"
		}
		var hcrp_holder = document.createElement('div')
		//hcrp_holder.setAttribute('class',"hcrh")
		for(var i=0;i<data.Results.length;i++){
			current.buildSearchItem(data.Results[i],i,parentresultdiv,studylevel,data.Results.length,data,hcrp_holder)
		}
		if(data.Results.length > 0){parentresultdiv.scrollTop = 0}
		showresultdiv()
	}
	return false
}
Inherit(AddFormWidget,SubmitWidget)
//
function Inherit(base,derived){
	for(var i in base.prototype){eval('derived.prototype.' + i + '= base.prototype.' + i)}
}
//
function wshowHide(){
	if($$$('woption').style.display == "none"){
		$$$('woption').style.display = "block"
		$$$('adv').style.display = "none"
}	}
function hcWidget(thisID){
if(navigator.appName==IEFlag){
thisID.style.width="auto";
thisID.styleFloat="left";
thisID.style.clear="both";
thisID.style.minWidth="140px";
thisID.style.margin ="8px 0";
thisID.style.overflow="auto";
thisID.style.minHeight="150px";
thisID.style.paddingBottom ="2px";
}else{
thisID.style.width="auto";
thisID.styleFloat="left";
thisID.style.clear="both";
thisID.style.minWidth="140px";
thisID.style.margin ="8px 0";
thisID.style.overflow="auto";
thisID.style.minHeight="150px";
thisID.style.paddingBottom ="2px";
}}
function hcRP(thisID){
if(navigator.appName==IEFlag){
thisID.style.width="auto"
thisID.style.styleFloat="left"
thisID.style.height="auto"
thisID.style.paddingBottom="9px"
thisID.style.backgroundColor="#ffffff"
}else{
thisID.style.width="auto"
thisID.style.styleFloat="left"
thisID.style.height="auto"
thisID.style.paddingBottom="9px"
thisID.style.backgroundColor="#ffffff"}}
function fieldsetStyle(thisID){
if(navigator.appName==IEFlag){
thisID.style.width="160px"
thisID.style.styleFloat="left"
thisID.style.padding="0 0 10px"
thisID.style.margin="0"
thisID.style.border="0"
thisID.style.color="#333"
thisID.style.textAlign="left"}}
function labelStyle(thisID){
if(navigator.appName==IEFlag){
thisID.style.clear="both"
thisID.style.margin="0"
thisID.style.color="#000"
thisID.style.padding="0"
thisID.style.fontStyle="normal"
thisID.style.fontFamily="Arial, Verdana, Helvetica, Sans-Serif"
thisID.style.fontSize="12px"
thisID.style.fontWeight="normal"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textAlign="left"
thisID.style.textIndent="0"
}else{
thisID.style.clear="both"
thisID.style.margin="0"
thisID.style.color="#000"
thisID.style.padding="0"
thisID.style.fontStyle="normal"
thisID.style.fontFamily="Arial, Verdana, Helvetica, Sans-Serif"
thisID.style.fontSize="12px"
thisID.style.fontWeight="normal"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textAlign="left"
thisID.style.textIndent="0"}

}
function pStyle(thisID){
thisID.style.clear="both"
thisID.style.margin="0"
thisID.style.color=($$$('textColor') && $$$('textColor') != '' ? $$$('textColor').value : "#000")
thisID.style.padding="0 0 5px"
thisID.style.fontStyle="normal"
thisID.style.fontWeight="normal"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textIndent="0"
}
function selectStyle(thisID){
if(navigator.appName==IEFlag){
thisID.style.fontFamily="Arial, Verdana, Helvetica, Sans-Serif"
thisID.style.fontSize="12px"
thisID.style.color="#333"
thisID.style.width="97%";
thisID.style.styleFloat="left"
thisID.style.marginBottom="10px"
}else{
thisID.style.fontFamily="Arial, Verdana, Helvetica, Sans-Serif"
thisID.style.fontSize="12px"
thisID.style.color="#333"
thisID.style.width="97%";
thisID.style.styleFloat="left"
thisID.style.marginBottom="10px"}

}
function txtInputStyle(thisID){
if(navigator.appName==IEFlag){
thisID.style.fontFamily="Arial, Verdana, Helvetica, Sans-Serif"
thisID.style.fontSize="12px"
thisID.style.width="97%"; //"154px"
thisID.style.styleFloat="left"
thisID.style.marginBottom="10px"
}else{
thisID.style.fontFamily="Arial, Verdana, Helvetica, Sans-Serif"
thisID.style.fontSize="12px"
thisID.style.width="97%"; //"154px"
thisID.style.styleFloat="left"
thisID.style.marginBottom="10px"}}
function resultStyle(thisID){
if(navigator.appName==IEFlag){
thisID.style.padding="5px 0 5px"
thisID.style.borderTop="1px dotted #999"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textIndent="0"
thisID.style.overflow="hidden"
}else{
thisID.style.padding="5px 0 5px"
thisID.style.borderTop="1px dotted #999"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textIndent="0"
thisID.style.overflow="hidden"
}}
function w1Style(thisID){
if(navigator.appName==IEFlag){
thisID.style.margin="0"
thisID.style.padding="0 0 8px"
thisID.style.fontSize="1.1em"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textIndent="0"
}else{
thisID.style.margin="0"
thisID.style.padding="0 0 8px"
thisID.style.fontSize="1.1em"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textIndent="0"}}
function h2Style(thisID){
if(navigator.appName==IEFlag){
thisID.style.fontSize="1.1em"
thisID.style.margin="0"
thisID.style.padding="0 10px 5px 0"
thisID.style.color="#333333"
thisID.style.fontStyle="normal"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textIndent="0"
}else{
thisID.style.fontSize="1.1em"
thisID.style.margin="0"
thisID.style.padding="0 10px 5px 0"
thisID.style.color="#333333"
thisID.style.fontStyle="normal"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textIndent="0"
}}
function subjLinkStyle(thisID){
if(navigator.appName==IEFlag){
thisID.style.color="#777"
thisID.style.margin="0 0 5px"
thisID.style.padding="0"
thisID.style.fontWeight="bold"
thisID.style.clear="both"}}
function startNewStyle(thisID){
if(navigator.appName==IEFlag){
thisID.style.styleFloat="left"
thisID.style.color="#fff"
thisID.style.fontFamily="Arial, Verdana, Helvetica, Sans-Serif"
thisID.style.fontSize="1.1em"
thisID.style.backgroundColor="#458598"
thisID.style.backgroundImage="url(http://images3.content-hca.com/int-cont/img/bg/pwdbybg.png)"
thisID.style.backgroundRepeat="no-repeat"
thisID.style.backgroundPosition="right bottom"
thisID.style.padding="2px 16px 2px 9px"
thisID.style.margin="0 0 10px"
thisID.style.fontStyle="normal"
thisID.style.fontWeight="normal"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textAlign="left"
thisID.style.textIndent="0"}
else{
thisID.style.styleFloat="left"
thisID.style.color="#fff"
thisID.style.fontFamily="Arial, Verdana, Helvetica, Sans-Serif"
thisID.style.fontSize="1.1em"
thisID.style.backgroundColor="#458598"
thisID.style.backgroundImage="url(http://images3.content-hca.com/int-cont/img/bg/pwdbybg.png)"
thisID.style.backgroundRepeat="no-repeat"
thisID.style.backgroundPosition="right bottom"
thisID.style.padding="2px 16px 2px 9px"
thisID.style.margin="0 0 10px"
thisID.style.fontStyle="normal"
thisID.style.fontWeight="normal"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textAlign="left"
thisID.style.textIndent="0"}}
function hcacli(thisID){
if(navigator.appName==IEFlag){
thisID.style.fontFamily="Arial, Verdana, Helvetica, Sans-Serif"
thisID.style.listStyle="none"
thisID.style.color="#333"
thisID.style.fontSize="0.9em"
thisID.style.margin="0"
thisID.style.padding="2px 5px"
thisID.style.borderBottom="1px solid #DDDDDD"
thisID.style.fontStyle="normal"
thisID.style.fontWeight="normal"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textAlign="left"
thisID.style.textIndent="0"
thisID.style.cursor="pointer"
}else{
thisID.style.fontFamily="Arial, Verdana, Helvetica, Sans-Serif"
thisID.style.listStyle="none"
thisID.style.color="#333"
thisID.style.fontSize="0.9em"
thisID.style.margin="0"
thisID.style.padding="2px 5px"
thisID.style.borderBottom="1px solid #DDDDDD"
thisID.style.fontStyle="normal"
thisID.style.fontWeight="normal"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textAlign="left"
thisID.style.textIndent="0"
thisID.style.cursor="pointer"}}
function ulStyle(thisID){
if(navigator.appName==IEFlag){
thisID.style.padding="10px 0"
thisID.style.margin="0"
thisID.style.fontStyle="normal"
thisID.style.fontWeight="normal"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textIndent="0"
thisID.style.background = "none";
}else{
thisID.style.padding="10px 0"
thisID.style.margin="0"
thisID.style.fontStyle="normal"
thisID.style.fontWeight="normal"
thisID.style.wordSpacing="normal"
thisID.style.letterSpacing="normal"
thisID.style.lineHeight="normal"
thisID.style.textIndent="0"
thisID.style.background = "none";}}
function hcTL(thisID){
if(navigator.appName==IEFlag){
thisID.style.padding="0px"
}else{
thisID.style.padding="0px"}}
//
/* function includeSCODE(){
	var newScript = document.createElement("script")
	var scodepath = $$$('scodepath').value
	newScript.setAttribute("type","text/javascript")
	newScript.setAttribute("charset","utf-8")
	if($$$('affId') != null){
		//newScript.setAttribute("src",('http://js.content-hca.com/widget-cont/scripts/' + $$$('affId').value + '/s_code.js'))
		newScript.setAttribute("src", scodepath);
		alert("2) scodepath: " + scodepath);
	}else{
		newScript.setAttribute("src",('http://js.content-hca.com/widget-cont/scripts/test/s_code.js'))
	}
	document.getElementsByTagName('head').item(0).appendChild(newScript)
} */
//
function Logging(obj,search){
	//alert("1)\n obj: "+obj + "\n search.collegeid: "+search.collegeid+ "\n search.suborderItem: "+search.suborderItem+ "\n search.quallevel: "+search.Quallevel)
	s.linkTrackVars = "server,channel,hier1,prop32,prop33,prop34,eVar32,eVar33,eVar34,events";
	s.linkTrackEvents = "event14";
	s.events = "event14";
	s.pageName = search.scpageName;
	s.prop32 = search.collegeid;
	s.server = search.serverName;
	s.channel = "int:" + search.citizen + ":" + search.countryName;
	s.hier1 = "int," + search.citizen + ","+search.countryName;
	s.eVar32 = search.collegeid;
	s.prop33 = "H.WC." + search.collegeid;// TODO remove the AMW during live deployment
	s.eVar34 = s.prop34 = s.pageName;
	s.tl(obj,'o',('webclick:'+search.collegeid));
	statsLogging('statsLogging',search.collegeid,search.suborderItem,search.quallevel);
}
//
function statsLogging(obj,collegeid,suborderItem,Quallevel){
	//alert("2)\n obj: "+obj + "\n collegeid: "+collegeid+ "\n suborderItem: "+suborderItem+ "\n Quallevel: "+Quallevel)
	var current = new AddFormWidget('hcwidget')
	var siteUrl = widgetsiteurl
	current.siteUrl = $$$('siteUrl').value
	current.config = function(jsonData){
		if(document.getElementById){
		if(! document.location.href.indexOf("file:///") >- 1){
		
			var mappingpath = "/widgetjsstats.html?collegeId=" + collegeid +
							"&suborderitem=" + suborderItem +
							"&webflag=N&quallevel=" + Quallevel;
							
			if($$$('widgetId').value != null && $$$('widgetId').value != ''){mappingpath = mappingpath + "&widgetId=" + $$$('widgetId').value}
			if($$$('affId').value != null && $$$('affId').value != ""){
				mappingpath = mappingpath + "&affId=" + $$$('affId').value;
			}else if($$$("affId") != null && $$$("affId").value != ""){
				mappingpath = mappingpath + "&affId=" + $$$("affId").value;
			}
			current.siteUrl = current.siteUrl + contextpath + mappingpath
			current.addScript((current.siteUrl+(current.siteUrl.indexOf('?')>-1 ? '&' : '?') + 'callback=' + obj + '.loadSearchData'),'rand')
	}	}	}
	current.config()
}
//
function includeImpression(search){
//alert("includeImpression: \n\n pageName: " + search.pageName + "\n serverName: "+search.serverName+ "\n citizen: "+search.citizen+ "\n countryName: "+search.countryName+ "\n keywordorcatDesc: "+search.keywordorcatDesc+ "\n qualName: "+search.qualName+ "\n GA_account: "+search.GA_account);
	//
	var pageName = (search.pageName).toLowerCase();
	s.pageName = pageName;
	s.server = (search.serverName).toLowerCase();
	s.channel = ("int:" + search.citizen + ":" + search.countryName).toLowerCase();
	s.hier1 = ("int," + search.citizen + "," + search.countryName).toLowerCase();
	if(search.keywordorcatDesc != null && undefined != search.keywordorcatDesc){
		s.prop1 = (search.keywordorcatDesc).toLowerCase();
	}
	if(search.studyModeDesc != null && undefined != search.studyModeDesc){
		s.prop36 = search.studyModeDesc.toLowerCase();
	}else{
		s.prop36 = 'full time';
	}
	s.prop44 = (search.countryName).toLowerCase();
	if(search.qualName != null && undefined != search.qualName){
		s.prop39 = (search.qualName).toLowerCase();
	}
	var s_code =s.t();
	if(s_code)document.write(s_code);
	//
	pageImpression_GA(pageName,search.GA_account);
}
//
function pageImpression_GA(pageName,GA_account){
	var _gaq = _gaq || [];
	_gaq.push(['_setAccount',("'"+GA_account+"'")]); 
	_gaq.push(['_setCustomVar',1,'PageName',("'"+pageName+"'"),3]);
	_gaq.push(['_trackPageview']); 
	//
	(function(){
		var ga = document.createElement('script'); 
		ga.type = 'text/javascript'; 
		ga.async = true;
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		var s = document.getElementsByTagName('script')[0]; 
		s.parentNode.insertBefore(ga,s);
	})();	
}
