var arrActions = new Array();
arrActions[0] = new Array();
arrActions[0][0] = "company";
arrActions[0][1] = "/searchEngine/default.cfm";
arrActions[0][2] = "companyname";
arrActions[0][3] = "";//Company Name or Symbol
arrActions[1] = new Array();
arrActions[1][0] = "news";
arrActions[1][1] = "/searchEngine/default.cfm";
arrActions[1][2] = "QUERY";
arrActions[1][3] = "";//News or Analysis by Keywords
arrActions[2] = new Array();
arrActions[2][0] = "research";
arrActions[2][1] = "/searchEngine/default.cfm";
arrActions[2][2] = "QUERY";
arrActions[2][3] = "";//Research Monitor by Keyword
arrActions[3] = new Array();
arrActions[3][0] = "ipo";
arrActions[3][1] = "/searchEngine/default.cfm";
arrActions[3][2] = "ipoSearch";
arrActions[3][3] = "";//Search Issuer or Advisor
arrActions[4] = new Array();
arrActions[4][0] = "sukuk";
arrActions[4][1] = "/searchEngine/default.cfm";
arrActions[4][2] = "sukukSearch";
arrActions[4][3] = "";//Sukuk Monitor by Keyword
arrActions[5] = new Array();
arrActions[5][0] = "private";
arrActions[5][1] = "/searchEngine/default.cfm";
arrActions[5][2] = "txtFund";
arrActions[5][3] = "";//Private Equity Monitor by Keyword
arrActions[6] = new Array();
arrActions[6][0] = "mutual";
arrActions[6][1] = "/searchEngine/default.cfm";
arrActions[6][2] = "mfSearch";
arrActions[6][3] = "";//Mutual Fund Monitor by Keyword
arrActions[7] = new Array();
arrActions[7][0] = "more";
arrActions[7][1] = "/cm/companylookup.cfm";
arrActions[7][2] = "companyname";
arrActions[7][3] = "";
arrActions[8] = new Array();
arrActions[8][0] = "project";
arrActions[8][1] = "/searchEngine/default.cfm";
arrActions[8][2] = "qryText";
arrActions[8][3] = "";//Project, Owner or Scope of Work

function showSearch(num,prod)
{
	if (lastSelectedSearch != num)
	{		
		window.document.getElementById("SearchLnk_"+arrActions[lastSelectedSearch][0]).className = "moretext";
		window.document.getElementById("SearchLnk_"+arrActions[num][0]).className = "header3";
		window.document.getElementById("SearchArr_"+arrActions[lastSelectedSearch][0]).className = "gone";
		window.document.getElementById("SearchArr_"+arrActions[num][0]).className = "notgone show_arrow";
		if (window.document.getElementById("searchText").value.replace(/ /g,"") == "" || window.document.getElementById("searchText").value == arrActions[lastSelectedSearch][3])
		{
			window.document.getElementById("searchText").value = arrActions[num][3];
			selectFocusSearchField();
		}
		window.document.getElementById("header_search_btn").src = "/images/search_"+arrActions[num][0]+".gif";
		window.document.getElementById("searchForm").action = (window.location.hostname.toLowerCase()=="blogs.zawya.com"?"http://www.zawya.com":"")+arrActions[num][1];
		lastSelectedSearch = num;
	}
	return false;
}

function showSearchFree(num,prod)
{
	if (lastSelectedSearch != num)
	{		
		window.document.getElementById("SearchLnk_"+arrActions[lastSelectedSearch][0]).className = "unselsearch";
		window.document.getElementById("SearchLnk_"+arrActions[num][0]).className = "selsearch";
		window.document.getElementById("SearchArrF_"+arrActions[lastSelectedSearch][0]).className = "gone";
		window.document.getElementById("SearchArrF_"+arrActions[num][0]).className = "notgone show_arrow";
		if (window.document.getElementById("searchText").value.replace(/ /g,"") == "" || window.document.getElementById("searchText").value == arrActions[lastSelectedSearch][3])
		{
			window.document.getElementById("searchText").value = arrActions[num][3];
			selectFocusSearchField();
		}
		window.document.getElementById("header_search_btn").src = "/images/search_"+arrActions[num][0]+".gif";
		window.document.getElementById("searchForm").action = (window.location.hostname.toLowerCase()=="blogs.zawya.com"?"http://www.zawya.com":"")+arrActions[num][1];
		lastSelectedSearch = num;
	}
	return false;
}

function submitSearch()
{
	if (window.document.getElementById("searchText").value != arrActions[lastSelectedSearch][3] && window.document.getElementById("searchText").value.replace(/ /g,"") != "")
	{
		window.document.getElementById(arrActions[lastSelectedSearch][2]).value = window.document.getElementById("searchText").value;
		if (arrActions[lastSelectedSearch][0] == "news")
			window.document.getElementById("category").value = "News";
		else
		{
			if (arrActions[lastSelectedSearch][0] == "research")
				window.document.getElementById("category").value = "Research";
			else
				window.document.getElementById("category").value = "";
		}
		return true;
	}
	else
		return false;
}

function clearSearchField()
{
	if (window.document.getElementById("searchText").value == arrActions[lastSelectedSearch][3])
		window.document.getElementById("searchText").value = "";
}

function selectFocusSearchField()
{
	//window.document.getElementById("searchText").select();
	//window.document.getElementById("searchText").focus();
}

function showTRs(num,num2,str,load,url)
{
	ScrollTop("content"+num+"_"+str);
	for(var i=1;i<=num2;i++)
	{
		var prev_className = window.document.getElementById("tabTitle"+i+"_"+str).className.replace("unselectedTabBlink","").replace("unselectedTab","").replace("selectedTab","");	
		window.document.getElementById("tabTitle"+i+"_"+str).className = ((i==num)?"selectedTab":"unselectedTab")+prev_className;
		window.document.getElementById("tabData"+i+"_"+str).className = ((i==num)?"notgone":"gone");
	}	
	var tab_el = window.document.getElementById("content"+num+"_"+str);
	if (load && (tab_el.innerHTML.indexOf("Loading...")!= -1 || tab_el.innerHTML.indexOf("Loading ...")!= -1) && (tab_el.innerHTML.indexOf("zawya_loading_img2.")!= -1 || tab_el.innerHTML.indexOf("LoadingData.gif")!= -1) ){
		ajaxCaller.getPlainText(url,loadData,"content"+num+"_"+str);
	}
	return false;
}
function urlAjax(url, divid, reload) {	
	if (typeof(reload) == 'undefined' || typeof(reload) == 'null' || reload == '') reload = 0;
	var div = ge(divid);
	if(div.innerHTML.indexOf('Loading...') != -1 || reload)
		ajaxCaller.getPlainText(url,loadData,divid);
}

function formAjax(url,divid,fObj,callBack,btnObj,isloader,txtmsg) {	
	form_postForPlainText(url,fObj,callBack,null,btnObj,divid);
	if(typeof(isloader) != 'undefined' && typeof(isloader) != 'null'  && isloader) {
		if(typeof(txtmsg) == 'undefined' || typeof(txtmsg) == 'null') txtmsg = 'Loading...';
		window.document.getElementById(divid).innerHTML = '<div class="loadimg greytextsmall"><img src="/images/loadingdata.gif" style="vertical-align:middle;"> '+ txtmsg + '</div>';
	}		
	return false;	
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

// showhidestory div script
var cldNme = "gone";
function showhidestory(layer_ref,sourceurl,elt)
{
	if (cldNme == "notgone"){
		cldNme = "gone";
		notcldNme = "notgone";
	}
	else{
		cldNme = "notgone";
		notcldNme = "gone";
	}
	if (cldNme == "notgone")
	{
		window.document.getElementById("storyframe").src = sourceurl;
		var tdElt = document.getElementById("ZDJVtbl");
		/*while ((tdElt.tagName.toUpperCase() != "TD" || tdElt.id.indexOf("content") == -1) && tdElt != null)
			tdElt = tdElt.parentNode;		*/
		if (tdElt != null && tdElt.clientHeight != "undefined" && parseInt(tdElt.clientHeight) > 333)
		{
			window.document.getElementById("storyframe").height = (parseInt(tdElt.clientHeight)-30)+"px";
			//window.document.getElementById(layer_ref).style.top = (-parseInt(tdElt.clientHeight)-22)+"px";
			window.document.getElementById(layer_ref).style.top = (-parseInt(tdElt.clientHeight))+"px";
		}
		//if (tdElt != null && tdElt.clientWidth != "undefined" && tdElt.clientWidth > 430)
		if (tdElt != null && tdElt.clientWidth != "undefined")
		{
			window.document.getElementById("storyframe").width = 416;
			window.document.getElementById(layer_ref).style.width = 416;
		}
	}
	else
		window.document.getElementById("storyframe").src = "/images/zawya_loading_img2.gif";
	window.document.getElementById(layer_ref).className = cldNme;
	window.document.getElementById("newZDJV").className = notcldNme
	return false;
}
/*temp function*/
function ZDJshowhidestory(layer_ref,sourceurl,elt)
{
	if (cldNme == "notgone"){
		cldNme = "gone";
		notcldNme = "notgone";
	}
	else{
		cldNme = "notgone";
		notcldNme = "gone";
	}
	if (cldNme == "notgone")
	{
		window.document.getElementById("storyframe").src = sourceurl;
		var tdElt = document.getElementById("newZDJV");
		/*while ((tdElt.tagName.toUpperCase() != "TD" || tdElt.id.indexOf("content") == -1) && tdElt != null)
			tdElt = tdElt.parentNode;		*/
		if (tdElt != null && tdElt.clientHeight != "undefined" && parseInt(tdElt.clientHeight) > 333)
		{
			window.document.getElementById("storyframe").height = (parseInt(tdElt.clientHeight)-20)+"px";
			//window.document.getElementById(layer_ref).style.top = (-parseInt(tdElt.clientHeight)-22)+"px";
			window.document.getElementById(layer_ref).style.top = (-parseInt(tdElt.clientHeight))+"px";
		}
		//if (tdElt != null && tdElt.clientWidth != "undefined" && tdElt.clientWidth > 430)
		if (tdElt != null && tdElt.clientWidth != "undefined")
		{
			window.document.getElementById("storyframe").width = 414;
			window.document.getElementById(layer_ref).style.width = 414;
		}
	}
	else
		window.document.getElementById("storyframe").src = "/images/zawya_loading_img2.gif";
	window.document.getElementById(layer_ref).className = cldNme;
	//window.document.getElementById("newZDJV").className = notcldNme
	return false;
}
/*temp function end*/

// showhidestory div script
var LMNcldNme = "gone";
function LMNshowhidestory(layer_ref,sourceurl,elt)
{
	if (LMNcldNme == "notgone"){
		LMNcldNme = "gone";
		notcldNme = "notgone";
	}
	else{
		LMNcldNme = "notgone";
		notcldNme = "gone";
	}
	if (LMNcldNme == "notgone")
	{
		window.document.getElementById("LMNstoryframe").src = sourceurl;	
		
	}
	else
		window.document.getElementById("LMNstoryframe").src = "/images/zawya_loading_img2.gif";
	window.document.getElementById(layer_ref).className = LMNcldNme;
	if (LMNcldNme == "notgone")centerThis("LMNstorydiv");
	return false;
}

//scrolling div starts
var global_scrolling_div = "";
var scrolling_div_step=300;
var scroll_step = 5;
function scrollDivDown(id, step, live_news_refresh){
	stopMe();
	//setting gloabal div id
	if(global_scrolling_div != id && id != "divLiveMarket"){
		if (global_scrolling_div != "")
			document.getElementById(global_scrolling_div).scrollTop = 0;
		global_scrolling_div = id;
	}
	
	//setting custom step
	if (typeof(step) != 'undefined' && step != null)
		scrolling_div_step = step;
	/*else 
		scrolling_div_step = 300;*/
	
	clearTimeout(timerDown);
	document.getElementById(id).scrollTop+=scroll_step;
	
	//for live dj refresh	
	if(live_news_refresh == 'ZDJ' && typeof(live_news_refresh) != 'undefined'){
		if(document.getElementById(id).scrollTop == 0)
			global_dj_refresh = true;
		else
			global_dj_refresh = false;
	}
	//for live market news refresh
	if(live_news_refresh == 'LMN' && typeof(live_news_refresh) != 'undefined'){		
		if(document.getElementById(id).scrollTop == 0)
			global_lm_refresh = true;
		else
			global_lm_refresh = false;
		//alert(id + " " + global_lm_refresh + " " + document.getElementById(id).scrollTop);
	}
	
	if (scrolling_div_step > 0){
		scrolling_div_step-=scroll_step;
		timerDown=setTimeout("scrollDivDown('"+id+"'," + null + ",'" + live_news_refresh + "')",10);	
	}
	else
		scrolling_div_step=300;
}
function scrollDivUp(id, step, live_news_refresh){
	stopMe();
	//setting gloabal div id
	if(global_scrolling_div != id && id != "divLiveMarket"){
		if (global_scrolling_div != "")
			document.getElementById(global_scrolling_div).scrollTop = 0;
		global_scrolling_div = id;
	}
	//setting custom step
	if (typeof(step) != 'undefined' && step != null)
		scrolling_div_step = step;
	/*else 
		scrolling_div_step = 400;*/
		
	clearTimeout(timerUp);
	document.getElementById(id).scrollTop-=scroll_step;
	
	//for live dj refresh
	if(live_news_refresh == 'ZDJ' && typeof(live_news_refresh) != 'undefined'){
		if(document.getElementById(id).scrollTop == 0)
			global_dj_refresh = true;
		else
			global_dj_refresh = false;
	}
	//for live market news refresh
	if(live_news_refresh == 'LMN' && typeof(live_news_refresh) != 'undefined'){		
		if(document.getElementById(id).scrollTop == 0)
			global_lm_refresh = true;
		else
			global_lm_refresh = false;
		//alert(id + " " + global_lm_refresh + " " + document.getElementById(id).scrollTop);
	}
	
	if (scrolling_div_step > 0){
		scrolling_div_step-=scroll_step;
		timerUp=setTimeout("scrollDivUp('"+id+"'," + null + ",'" + live_news_refresh + "')",10);	
	}
	else
		scrolling_div_step=300;
	
}
var timerDown="";
var timerUp="";
function stopMe(){
clearTimeout(timerDown);
clearTimeout(timerUp);
}

function ScrollTop(divid){
	var oCloneNode = document.getElementById(divid);
	var tdCollection = oCloneNode.getElementsByTagName("DIV");	
	for (var i=0;i<tdCollection.length;i++)
	{
		if(tdCollection[i].getAttribute("scrollingdivid") != null)
		document.getElementById(tdCollection[i].getAttribute("scrollingdivid")).scrollTop = 0;
	}	
}
//document.onmousemove=function(){stopMe();}
//scrolling div ends

// format numeric to formatted string with commas & decimals
// sample formatnum(3400.3940,2) returns "3,400.39"
function formatnum(num,dec)
{
	num = num.toFixed(dec);
	nStr = num;
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function get_usd_rate(value, dollarrate)
{
	if (value == 0)
		return 0;
	else
		return value / dollarrate;
}

function get_base_rate(value, dollarrate)
{
	return value * dollarrate;
}

function get_class(value)
{ 
	if (value > 0)
		return 'greenfont';
	else if (value < 0)
		return 'redfont';
	return 'blackfont';	
}

function trim(str)
{  
 	if(typeof(str) == "string")
 		return str.replace(/^\s*|\s*$/g,"");
	else 
		return str;
}
function Left(str, n){
		if (n <= 0)
		    return "";
		else if (n > String(str).length)
		    return str;
		else
		    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function IsNumeric(sText)
{
 	var ValidChars = "0123456789.";
 	var IsNumber=true;
  var Chart;
	for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
   	Chart = sText.charAt(i); 
     if (ValidChars.indexOf(Chart) == -1) 
     {
     	IsNumber = false;
     }
   }
  return IsNumber;
}
	
function isNumeric(x) {
	var RegExp = /^(-)?(\d*)(\.?)(\d*)$/; 
	var result = x.match(RegExp);
	if (result==null) 
		return false;
	else	
		return true;
}

var lastTeaserPage = "";
var lastTeaserObj = "";
var lastTeaserContainer = "";
function showTeaser(obj,page,divwrapper)
{
	if (typeof(divwrapper) == 'undefined' || typeof(divwrapper) == 'null' || divwrapper == '') divwrapper = "IndustryNewsTab";
	open_close = (obj.src.indexOf("/images/plus_icon.gif")!=-1?1:0);
	var container = window.document.getElementById(divwrapper);
	divArray = container.getElementsByTagName("DIV");
	for (var i=0;i<divArray.length;i++)
	{
		if (divArray[i].getAttribute("belongPage") == page)
			divArray[i].className = (open_close == 1?"notgone":"gone");
		else if (divArray[i].getAttribute("belongPage") == lastTeaserPage && open_close == 1 && divwrapper == lastTeaserContainer)
			divArray[i].className = "gone";
	}
	if (divwrapper != lastTeaserContainer && lastTeaserContainer != "")
	{
		var container = window.document.getElementById(lastTeaserContainer);
		divArray = container.getElementsByTagName("DIV");
		for (var i=0;i<divArray.length;i++)
		{
			if (divArray[i].getAttribute("belongPage") == lastTeaserPage)
				divArray[i].className = "gone";
		}
	}
	if (lastTeaserPage != page && open_close == 1)
		lastTeaserObj.src = "/images/plus_icon.gif";
	lastTeaserPage = page;
	lastTeaserObj = obj;
	lastTeaserContainer = divwrapper;
	obj.src = (open_close == 1?"/images/minus_icon.gif":"/images/plus_icon.gif");
}

function openAudioFile(v_file)
{

	zi=getCookie('ZI')
	if (zi!=null && zi=="true")
	{
//window.open("/audio/default.cfm?w=320&h=145&" + v_file ,"dubaieye","width=320,height=165,Status=no,Toolbar=no,Menubar=no,Location=no,Scrollbars=no");
	window.open("/audio/default.cfm?w=320&h=145&"  + v_file,"dubaieye","height=165,width=320,status=no,toolbar=no,titlebar=no,menubar=no,location=no");	
	} 
	else 
	{
    window.open("/audio/default.cfm?w=320&h=145&" + v_file ,"dubaieye","width=320,height=165,menubar=no,titlebar=no,Scrollbars=no,location=no,status=no");
		
	}

	
	return false;	
}
function GetInnerSize () {
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	return [x,y];
}
function ResizeToInner (w, h) {
	// make sure we have a final x/y value
	// pick one or the other windows value, not both
	var xx = window.screenLeft || window.screenX;
	var yy = window.screenTop || window.screenY;
	// for now, move the window to the top left
	// then resize to the maximum viewable dimension possible
	window.moveTo(0,0);
	window.resizeTo(screen.availWidth,screen.availHeight);
	// now that we have set the browser to it's biggest possible size
	// get the inner dimensions.  the offset is the difference.
	var inner = GetInnerSize();
	var ox = screen.availWidth-inner[0];
	var oy = screen.availHeight-inner[1];
	// now that we have an offset value, size the browser
	// and position it
	top.resizeTo(w+ox, h+oy);
	
	window.moveTo(xx,yy);
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}

function checkdivheight(){
alert(document.getElementById("outercontainer").height);
}

function submit_keyplayers_form_bcl(bclSec,bclCtry,bclExch,formObj)
{
	bclSec = !validObject(bclSec)?"":bclSec;
	bclCtry = !validObject(bclCtry)?"":bclCtry;
	bclExch = !validObject(bclExch)?"":bclExch;
	formObj = !validObject(formObj)?"buildlist":formObj;
	with(document.forms[formObj])
		with(document.forms[formObj])
	{
		if (validObject(document.forms[formObj].sectorsindustry))
			sectorsindustry.value=bclSec;
		if (validObject(document.forms[formObj].country))
			country.value=bclCtry;
		if (validObject(document.forms[formObj].exchange))
			exchange.value=bclExch;
	}
	document.forms[formObj].submit();
	return false;	
}

function submit_keyplayers_form(bclSec,bclInd_list,bclCtry,bclExch,formObj,bclDisc)
{
	bclSec_Ind = "";
	bclSec = !validObject(bclSec)?"":bclSec;
	bclInd_list = !validObject(bclInd_list)?"":bclInd_list;
	bclCtry = !validObject(bclCtry)?"":bclCtry;
	bclExch = !validObject(bclExch)?"":bclExch;
	bclDisc = !validObject(bclDisc)?"":bclDisc;
		if(formObj==''){
			formObj="buildlist";
		}
	formObj = !validObject(formObj)?"buildlist":formObj;
	with(document.forms[formObj])
	{
		if (validObject(document.forms[formObj].sectorsindustry))
			sectorsindustry.value=bclSec_Ind;
		if (validObject(document.forms[formObj].sectors))
			sectors.value=bclSec;
		if (validObject(document.forms[formObj].industry))
			industry.value=bclInd_list;
		if (validObject(document.forms[formObj].country))
			country.value=bclCtry;
		if (validObject(document.forms[formObj].exchange))
			exchange.value=bclExch;
		if (validObject(document.forms[formObj].descrip))
			descrip.value=bclDisc;
	}
	document.forms[formObj].submit();
	return false;	
}

function submit_keyplayers_form3(bclSec_Ind_list,bclCtry,bclExch,formObj,bclDisc)
{
	bclSec_Ind = !validObject(bclSec_Ind_list)?"":bclSec_Ind_list;
	bclCtry = !validObject(bclCtry)?"":bclCtry;
	bclExch = !validObject(bclExch)?"":bclExch;
	bclDisc = !validObject(bclDisc)?"":bclDisc;
	if(formObj==''){
			formObj="buildlist";
		}
	formObj = !validObject(formObj)?"buildlist":formObj;
	with(document.forms[formObj])
	{
		if (validObject(document.forms[formObj].sectorsindustry))
		{
			sectorsindustry.value=bclSec_Ind;
			sector_type.value="primary";
		}
		if (validObject(document.forms[formObj].country))
			country.value=bclCtry;
		if (validObject(document.forms[formObj].exchange))
			exchange.value=bclExch;
		if (validObject(document.forms["buildlist"].descrip))
			descrip.value=bclDisc;
	}
	document.forms[formObj].submit();
	return false;	
}

function submit_keyplayers_form2(){
		document.getElementById("buildlist2").submit();
	return false;	
}

function hideShowSelect(){
	if (document.getElementById&&document.documentElement.filters){
		var args=arguments;
	for (var i_tem = 0; i_tem < args.length; i_tem++)
		if (document.getElementById(args[i_tem]).style.visibility=='')
			document.getElementById(args[i_tem]).style.visibility='hidden';
		else
			document.getElementById(args[i_tem]).style.visibility='';
	}
}

var iframeCode = "";
function showFeedback(prod)
{	/*for (var frm=0;frm<document.forms.length;frm++)
		for (var con=0;con<document.forms[frm].length;con++)
			if (document.forms[frm][con].type.indexOf("select")>-1)
				document.forms[frm][con].style.display="none";*/
	var tab_el = window.document.getElementById("feedBackForm");
	if (typeof(c_F) == "object" && c_F[0])
	{
		var container = window.document.getElementById("feedBackWindow");
		iframeCode=c_cE("<iframe src=javascript:0 tabindex=-9 style=position:absolute;z-index:-1;width:514px;height:152px;left:0px;top:0px;filter:alpha(opacity=0)>","");
		container.insertBefore(iframeCode,tab_el);
	}
	if(tab_el.innerHTML.indexOf("Thank you for your feedback.") !=-1)
		tab_el.innerHTML = '<div class="loadimg"><img src="/images/LoadingData.gif" border="0" style="vertical-align:middle"> <font class="greytextsmall">Loading ...</font></div>';
	if (tab_el.innerHTML.indexOf("Loading ...")!= -1 && tab_el.innerHTML.indexOf("LoadingData.gif")!= -1)
		ajaxCaller.getPlainText('/zscripts/xml.cfm?feedback',loadDataFeedback,"feedBackForm");
	//document.getElementById("feedbackArrowImg").src = "/images/"+prod+"_feedback_arrow_down.gif";
	try{
		document.getElementById("feedbackArrowImg").src = "/images/ZP_feedback_arrow_down.gif";		
	}catch(e){
		try{
			document.getElementById("ztFeedback_innerdiv").className = "expand";
		}catch(e){}	
	}
	document.getElementById("feedBackWindow").className = "notgone";
	if (!(tab_el.innerHTML.indexOf("Loading ...")!= -1 && tab_el.innerHTML.indexOf("LoadingData.gif")!= -1) && (typeof(c_F) == "object" && c_F[0]) && iframeCode != "")
	{
		iframeCode.style.width = tab_el.offsetWidth+42;
		iframeCode.style.height = tab_el.offsetHeight+12;
	}
	try{
		document.getElementById("feedBackHeaderBox").onclick = function(){hideFeedback(prod);};
	}catch(e){
		try{
			document.getElementById("ztFeedback_innerdiv").onclick = function(){hideFeedback(prod);};			
		}catch(e){}
	}
	return false;
};

function hideFeedback(prod)
{	/*for (var frm=0;frm<document.forms.length;frm++)
		for (var con=0;con<document.forms[frm].length;con++)
			if (document.forms[frm][con].type.indexOf("select")>-1)
				document.forms[frm][con].style.display="";*/
	if (typeof(c_F) == "object" && c_F[0] && iframeCode != "")
	{
		iframeCode.removeNode(1);
		iframeCode = "";
	}
	//document.getElementById("feedbackArrowImg").src = "/images/"+prod+"_feedback_arrow_right.gif";
	try{
		document.getElementById("feedbackArrowImg").src = "/images/ZP_feedback_arrow_right.gif";		
	}catch(e){
		try{
			document.getElementById("ztFeedback_innerdiv").className = "collapse";
		}catch(e){}
	}
	document.getElementById("feedBackWindow").className = "gone";
	try{
		document.getElementById("feedBackHeaderBox").onclick = function(){showFeedback(prod);};
	}catch(e){
		try{
			document.getElementById("ztFeedback_innerdiv").onclick = function(){showFeedback(prod);};
		}catch(e){}
	}
	return false;
};

function submitFeedBack(url,fObj,callBack)
{
	var feedbackDefault1 = "When you make suggestions for improvements or changes well include this in our regular product testing and updates to provide the best possible solution for you.";
	var feedbackDefault2 = "When you ask us a question our customer support team will go out of their way to help clarify any queries you have.";
	var feedbackDefault3 = "When you send us an update well quickly amend any changes you request.";
	var feedbackDefault4 = "When you complain youll be contacted by our team to help resolve any concerns you may have.";
	var feedbackDefault5 = "When you sing our praises well know what were doing right and well repeat it.";	
	var tmp = fObj.feedback.value.replace(/,/g,"");
	tmp = tmp.replace(/'/g,"");
	if (fObj.feedback.value.replace(/ /g,"") == "" || tmp == feedbackDefault1 || tmp == feedbackDefault2 || tmp == feedbackDefault3 || tmp == feedbackDefault4 || tmp == feedbackDefault5)
	{
		window.document.getElementById("feedBackError").innerHTML = "Enter your feedback";
		return false
	}
	else if (!checkEmail(fObj.email.value))
	{
		window.document.getElementById("feedBackError").innerHTML = "Email address is incorrect";
		return false;
	}
	form_postForPlainText(url,fObj,callBack);	
	window.document.getElementById("feedBackForm").innerHTML = '<div class="loadimg"><img src="/images/LoadingData.gif" border="0" style="vertical-align:middle"> <font class="greytextsmall">Sending ...</font></div>';
	if (typeof(c_F) == "object" && c_F[0] && iframeCode != "")
	{
		iframeCode.style.width = window.document.getElementById("feedBackForm").offsetWidth+42;
		iframeCode.style.height = window.document.getElementById("feedBackForm").offsetHeight+12;
	}
	return false;	
}

function returnSubmitFeedback()
{
	window.document.getElementById("feedBackForm").innerHTML = '<div align="center" class="MPHeaderOrange" style="padding:40px 0px;"><strong>Thank you for your feedback.</strong></div>';
	if (typeof(c_F) == "object" && c_F[0] && iframeCode != "")
	{
		iframeCode.style.width = window.document.getElementById("feedBackForm").offsetWidth+42;
		iframeCode.style.height = window.document.getElementById("feedBackForm").offsetHeight+12;
	}
	window.setTimeout(hideFeedback,3000);
	return false;
}

function clearFeedback(num,obj,fobj)
{
	for (var i = 0; i < fobj.feedbackType.length; i ++)
		if (fobj.feedbackType[i].checked == true)
			switch (i)
			{
				case 0:
					var feedbackDefault = "When you make suggestions for improvements or changes, we'll include this in our regular product testing and updates to provide the best possible solution for you.";
					break;
				case 1:
					var feedbackDefault = "When you ask us a question, our customer support team will go out of their way to help clarify any queries you have.";
					break;
				case 2:
					var feedbackDefault = "When you send us an update we'll quickly amend any changes you request.";
					break;
				case 3:
					var feedbackDefault = "When you complain you'll be contacted by our team to help resolve any concerns you may have.";			
					break;
				case 4:
					var feedbackDefault = "When you sing our praises we'll know what we're doing right and we'll repeat it.";	
					break;
			}
	if (num == 1 && obj.value == feedbackDefault)
		obj.value = "";
	else if (num == 2 && obj.value == "")
		obj.value = feedbackDefault;
}

function SwitchFeedbackType(num,field)
{
	switch (num)
	{
		case 1:
			window.document.getElementById(field).value = "When you make suggestions for improvements or changes, we'll include this in our regular product testing and updates to provide the best possible solution for you.";
			break;
		case 2:
			window.document.getElementById(field).value = "When you ask us a question, our customer support team will go out of their way to help clarify any queries you have.";
			break;
		case 3:
			window.document.getElementById(field).value = "When you send us an update we'll quickly amend any changes you request.";
			break;
		case 4:
			window.document.getElementById(field).value = "When you complain you'll be contacted by our team to help resolve any concerns you may have.";			
			break;
		case 5:
			window.document.getElementById(field).value = "When you sing our praises we'll know what we're doing right and we'll repeat it.";	
			break;
	}
}

function loadDataFeedback(text,callingContext,headers,arrParams)
{
	if (text.replace(/ /g,"") != "")
	{
		if(typeof(overwriteDocTitle) != 'undefined') 
			var docTitle = overwriteDocTitle;
		else if (window.document.URL.toLowerCase().indexOf("/story.cfm")!=-1)
			var docTitle = "Story page";
		else if (window.location.pathname.toLowerCase() == "/" || window.location.pathname.toLowerCase().substr(0,12) == "/default.cfm")
			var docTitle = "Homepage";
		else
			var docTitle = ((window.document.title.toLowerCase().indexOf(" - zawya.com")!=-1)?window.document.title.substr(0,window.document.title.toLowerCase().indexOf(" - zawya.com")):window.document.title);
		if (docTitle == "Zawya.com | Middle East Business News and Company Directory") docTitle = "";
		window.document.getElementById(callingContext).innerHTML = text;
		window.document.getElementById("feedbackPageTitle").value = docTitle;
		window.document.getElementById("current_url").value = window.document.URL;
		if (typeof(c_F) == "object" && c_F[0] && iframeCode != "")
		{
			iframeCode.style.width = window.document.getElementById(callingContext).offsetWidth+42;
			iframeCode.style.height = window.document.getElementById(callingContext).offsetHeight+12;
		}
	}
}


function checkEmail(str,alertstr)
{

	var x = str;
	//var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var filter  = /^(['a-zA-Z0-9_\.\-\\])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return true;
	else{
			if (!(typeof(alertstr) == 'undefined' || typeof(alertstr) == 'null' || alertstr == '')) {
				alert(alertstr);
			}	
		return false;
		}

}
/*
function checkEmail(str,alertstr)
{
	if (str.indexOf('@',0)==-1 ||
			str.indexOf('@',0)== 0 ||
			str.indexOf('/',0)>-1 ||
			str.indexOf(':',0)>-1 ||
			str.indexOf(';',0)>-1 ||
			str.indexOf('[',0)>-1 ||
			str.indexOf(']',0)>-1 ||
			str.indexOf('{',0)>-1 ||
			str.indexOf('}',0)>-1 ||
			str.indexOf('.',0)==-1) {
			if (!(typeof(alertstr) == 'undefined' || typeof(alertstr) == 'null' || alertstr == '')) {
				alert(alertstr)
			}	
			return false;
	}		
	return true;
}*/

function SetFlashHeight(flashDivId,flashDivHeight){
if(isLoaded)
	document.getElementById(flashDivId).style.height=flashDivHeight+'px' ;
}
function loadsponsor() { 
	isLoaded = 1;
	var el = document.getElementById('FlashDiv'); 
	if (el) el.style.display = 'block';  
}	

function toggleslidediv(img,divid) { img.src =  img.src.indexOf('collapse') != -1 ? "/images/btn_expand.gif" : "/images/btn_collapse.gif"; document.getElementById(divid).style.display = ''; }

function afterslide(el) {
	if (el.offsetHeight < 5)
		el.style.display = 'none';
}
function toggleCoverage(imgnm,divid) {
	toggleslidediv(document.getElementById(imgnm),divid); 
	Spry.Effect.Slide(divid, {duration: 500, from: '1px', to: '100%', toggle: true, finish: afterslide});
}

function validateimage(fName){
	fullName = fName;
	shortName = fullName.match(/[^\/\\]+$/);
	splitName = fullName.split(".");
	fileType = splitName[splitName.length-1];
	fileType = fileType.toLowerCase();
	return (fileType == 'gif' || fileType == 'jpg' || fileType == 'jpeg' || fileType == 'png') ? true : false;
}

var winW = 1000, winH = 600;
function get_window_dimension() {
	if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    winW = window.innerWidth;
    winH = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    winW = document.documentElement.clientWidth;
    winH = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    winW = document.body.clientWidth;
    winH = document.body.clientHeight;
  }
}
function centerThis(objid) {
	obj = document.getElementById(objid);
	get_window_dimension();
	objW = obj.offsetWidth;
	objH = obj.offsetHeight;
	objBody = document.documentElement;
	if(objBody.scrollTop==0)
		objBody = document.body;
	obj.style.top = parseInt((winH / 2) - (objH / 2)) < 0 ? objBody.scrollTop + "px" : (objBody.scrollTop + parseInt((winH / 2) - (objH / 2))) + 'px';
	obj.style.left = parseInt((winW / 2) - (objW / 2)) < 0 ? objBody.scrollTop + "px" : parseInt((winW / 2) - (objW / 2)) + 'px';
}
function posAbsolute (divid,relativeDiv,align) {
	innerdiv = document.getElementById(divid);
	outerdiv = document.getElementById(relativeDiv);
	innerdivwidth = innerdiv.offsetWidth;
	innerdivheight = innerdiv.offsetHeight;
	outerdivwidth = outerdiv.offsetWidth;
	outerdivheight = outerdiv.offsetHeight;
	if(align == 'right') 
		innerdiv.style.left = (outerdivwidth - innerdivwidth) + 'px';
	if(align == 'left')
		innerdiv.style.left = '0px';	
}

function changeclass(elid, classnm) {
	document.getElementById(elid).className = classnm;
	return false;
}

function showDIVs(num,num2,str,load,url)
{
	ScrollTop("content"+num+"_"+str);
	for(var i=1;i<=num2;i++)
	{				
		var prev_className = window.document.getElementById("tabTitle"+i+"_"+str).className.replace("tab-on","").replace("tab-off","");
		window.document.getElementById("tabTitle"+i+"_"+str).className = ((i==num)?"tab-on":"tab-off")+" " + prev_className;
		var prev_dataClassName = window.document.getElementById("tabData"+i+"_"+str).className.replace("notgone","").replace("gone","").replace("hide","");
		window.document.getElementById("tabData"+i+"_"+str).className = ((i==num)?"notgone":"gone") + " " + prev_dataClassName;
	}	
	var tab_el = window.document.getElementById("content"+num+"_"+str);
	if (load && (tab_el.innerHTML.indexOf("Loading...")!= -1 || tab_el.innerHTML.indexOf("Loading ...")!= -1) && (tab_el.innerHTML.indexOf("zawya_loading_img2.")!= -1 || tab_el.innerHTML.indexOf("LoadingData.gif")!= -1) ){
		ajaxCaller.getPlainText(url,loadData,"content"+num+"_"+str);
	}
	return false;
}

function OuterDivUnSel(num, str){
	for(i=1;i<=num;i++){
		if(i==1)
			document.getElementById("outer_tabTitle" + i + "_" + str).className = "innerHead1";
		else
			document.getElementById("outer_tabTitle" + i + "_" + str).className = "innerHead2";
	}
}

function showTabSys(num,num2,str,load,url,reload)
{
	if(typeof(reload) == "undefined"){
		reload=false;
	}
	ScrollTop("tabsyscontent_"+num+"_"+str);
	var tabtitle = document.getElementById('tabsystitle_' + num + "_" + str);
	var tabcontent = document.getElementById('tabsyscontent_' + num + "_" + str);
	if(tabtitle.className.indexOf(' on') != -1) return false;
	for(var i=1;i<=num2;i++)
	{
		eltitle = document.getElementById('tabsystitle_' + i + "_" + str);
		elcontent = document.getElementById('tabsyscontent_' + i + "_" + str);
		eltitle.className = (num==i) ? eltitle.className + " on" : eltitle.className.replace(" on","");
		elcontent.className = (num==i) ? "notgone" : "gone";
	}
	if(reload)	
		tabcontent.innerHTML = '<div class="loadimg"><img src="/images/LoadingData.gif" border="0" style="vertical-align:middle"> <font class="greytextsmall">Loading ...</font></div>';
		
	if ( (load && (tabcontent.innerHTML.indexOf("Loading...")!= -1 || tabcontent.innerHTML.indexOf("Loading ...")!= -1) && (tabcontent.innerHTML.indexOf("zawya_loading_img2.")!= -1 || tabcontent.innerHTML.indexOf("LoadingData.gif")!= -1)) || reload ) {
		var arrParamsFeatures = new Array();
		arrParamsFeatures[0] = url;
		ajaxCaller.getPlainText_Params(url,loadDataTFS,tabcontent.id, arrParamsFeatures);
	}
	return false;
}

function callBackShowDivCompRanking(text,callingContext,headers,arrParams){
	window.document.getElementById(callingContext).innerHTML = text;
}
function showDivCompRanking(id1,targetajax){			
	document.getElementById(id1).innerHTML = '<div class="loadimg"><img src="/images/LoadingData.gif" border="0" style="vertical-align:middle"> <font class="greytextsmall">Loading ...</font></div>';
	ajaxCaller.getPlainText(targetajax, callBackShowDivCompRanking, id1);
}
function linkToCompRanking(L)
{        	       	  
	var i =1 ;
	for(i=1; i<=3;i++)
	{
		document.getElementById("compRankingLink"+i).className="textsmall"  ;
		document.getElementById("compRankingTab"+i).className="gone"  ;
		if(L==i)
		{
			document.getElementById("compRankingLink"+i).className="orangetextsmall2" ;
			document.getElementById("compRankingTab"+i).className="notgone"  ;
			document.getElementById("rankedby").value= i  ;
		}
	}
	if(document.getElementById("compRankingTab"+L).innerHTML=="")
		showDivCompRanking('compRankingTab'+L,'/zscripts/xml.cfm?tab='+L+'&path='+pagePath+'&compRanking');
}

function performsort(num,num2,str,url,divid) {
	if(document.getElementById('sorter_'+num+'_'+str).className.indexOf('sorted') == -1) {
		for(i=1;i<=num2;i++) {
			el=document.getElementById('sorter_'+i+'_'+str);
			el.className = i==num ? el.className.replace("sort","sorted") : el.className.replace("sorted","sort");
		}
	}
	document.getElementById("performbody").className = "gone";
	document.getElementById("performloader").className = "notgone";
	ajaxCaller.getPlainText(url,loadData,divid);
	return false;
}

function ratioafterslide(el) {
	if (el.offsetHeight < 5) {
		el.style.display = 'none';
		if(el.id == 'gccslider' && document.getElementById('uaeslider').style.display != 'none') {
			Spry.Effect.Slide('uaeslider', {duration: 500, from: '100%', to: '1px', toggle: true, finish: ratioafterslide});
			isUAESlider = 1;
		}
	}
	else {
		if(el.id == 'gccslider' && isUAESlider) {
			document.getElementById('uaeslider').style.display = ''; 
			Spry.Effect.Slide('uaeslider', {duration: 500, from: '100%', to: '1px', toggle: true, finish: ratioafterslide})
			isUAESlider = 0;
		}
	}
}
function toggleRatioSlider(img,divid,open) {
	img.src =  img.src.indexOf('plus_icon.gif') != -1 ? "/images/minus_icon.gif" : "/images/plus_icon.gif"; 
	document.getElementById(divid).style.display = ''; 
	if(!open)
		Spry.Effect.Slide(divid, {duration: 500, from: '1px', to: '100%', toggle: true, finish: ratioafterslide});
	else
		Spry.Effect.Slide(divid, {duration: 500, from: '100%', to: '1px', toggle: true, finish: ratioafterslide});
}

var minfont=7;
var maxfont=13;
function increasefontsize() {
	with(window.document)
	{
	var recnum = getElementById("recnum").value;
   var obj,size;
   for (var i = 1; i<=parseInt(recnum); i ++)
   {
    	obj = getElementById("texttomodify"+i);
   		size = parseInt(obj.className.replace("text",""));   
	   if (size != maxfont)
			size += 2;	
	  obj.className = "text"+size;
	}
	 if (getElementById("printlink").href.indexOf("&fsize") == -1)
		 getElementById("printlink").href += "&fsize="+size;
	else
		getElementById("printlink").href = getElementById("printlink").href.substring(0,getElementById("printlink").href.indexOf("&fsize")) + "&fsize=" + size;
		}
}
function decreasefontsize() {
	with(window.document)
	{
	var recnum = getElementById("recnum").value;
	var obj, size;
	for (var i = 1; i<=parseInt(recnum); i ++)
   {
   		obj = getElementById("texttomodify"+i);
	   size = parseInt(obj.className.replace("text",""));   
	   if (size != minfont)
			size -= 2;	
	  obj.className = "text"+size;
	 }
	 if (getElementById("printlink").href.indexOf("&fsize") == -1)
		 getElementById("printlink").href += "&fsize="+size;
	else
		getElementById("printlink").href = getElementById("printlink").href.substring(0,getElementById("printlink").href.indexOf("&fsize")) + "&fsize=" + size;
		}
}

function show_hide_nav(id, type){
	if(type == 1)
		document.getElementById(id).className='notgone';
	else 
		document.getElementById(id).className='gone';
}

function dt2num(dt) {
  // dt should be in dd-mmm-yyyy || dd-mm-yyyy format
 var arrDt = dt.split("-");
 switch(arrDt[1].toLowerCase()) {
  case "jan": m_num = '01'; break;
  case "feb": m_num = '02'; break;
  case "mar": m_num = '03'; break;
  case "apr": m_num = '04'; break;
  case "may": m_num = '05'; break;
  case "jun": m_num = '06'; break;
  case "jul": m_num = '07'; break;
  case "aug": m_num = '08'; break;
  case "sep": m_num = '09'; break;
  case "oct": m_num = '10'; break;
  case "nov": m_num = '11'; break;
  case "dec": m_num = '12'; break;
  default: m_num = arrDt[1];
 }
 return parseInt(arrDt[2] + m_num + arrDt[0]);
}
function putClass(divid,clsnm) {
	try{
 		document.getElementById(divid).className = clsnm;
	}catch(e){}
 return false;
}
function OpenNewWindow(windowurl, windowname, w, h){ 
	if ((typeof(newWindow) != "undefined") && (typeof(newWindow) != null) && (!newWindow.closed))
		newWindow.focus();
	else
		newWindow = window.open(windowurl,windowname,'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width='+w+',height='+h);
	return false;
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window.document.flexswf;
    } else {
        return document.flexswf2;
    }
}

function callApp(value) {
	if(value != 'newlist')
	{
		var temp1 = window.document.getElementById("splist").value.split(',');
		thisMovie("flexswf").updatelist(value);
	}
	else
	{
		thisMovie("flexswf").updatelist('');
	}
}

function flexisready() {
	window.document.getElementById("splist").disabled = false;
}

function LoadAjaxPage(url, callBack, content){
	document.getElementById(content).innerHTML = '<div class="loadimg"><img src="/images/LoadingData.gif" border="0" style="vertical-align:middle"> <font class="greytextsmall">Loading ...</font></div>';
	ajaxCaller.getPlainText(url, callBack, content);
	return false;
}

function ge(id) {
	return document.getElementById(id);
}

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
		alert('This field is limited to ' + limitNum + ' characters only.');
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
	return false;
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
		curleft += obj.offsetLeft;
		curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

function showTabSys_form(num, num2, str, load, url, fobj, reload){
	if(typeof(reload) == "undefined"){
		reload=false;
	}
	ScrollTop("tabsyscontent_"+num+"_"+str);
	var tabtitle = document.getElementById('tabsystitle_' + num + "_" + str);
	var tabcontent = document.getElementById('tabsyscontent_' + num + "_" + str);
	if(tabtitle.className.indexOf(' on') != -1) return false;
	for(var i=1;i<=num2;i++)
	{
		eltitle = document.getElementById('tabsystitle_' + i + "_" + str);
		elcontent = document.getElementById('tabsyscontent_' + i + "_" + str);
		eltitle.className = (num==i) ? eltitle.className + " on" : eltitle.className.replace(" on","");
		elcontent.className = (num==i) ? "notgone" : "gone";
	}
	if(reload)	
		tabcontent.innerHTML = '<div class="loadimg"><img src="/images/LoadingData.gif" border="0" style="vertical-align:middle"> <font class="greytextsmall">Loading ...</font></div>';
		
	if ( (load && (tabcontent.innerHTML.indexOf("Loading...")!= -1 || tabcontent.innerHTML.indexOf("Loading ...")!= -1) && (tabcontent.innerHTML.indexOf("zawya_loading_img2.")!= -1 || tabcontent.innerHTML.indexOf("LoadingData.gif")!= -1)) || reload ) {
		var arrParamsFeatures = new Array();
		arrParamsFeatures[0] = url;
		//ajaxCaller.getPlainText_Params(url,loadDataTFS,tabcontent.id, arrParamsFeatures);
		form_postForPlainText(url, fobj, loadDataTFS, null, null,tabcontent.id);
	}
	return false;
}

function chgPos(el,divid) {
	if(typeof(divid) == 'undefined' || typeof(divid) == 'null') divid = 'divPosition';
	if(el.options[el.selectedIndex].value == 'Other') {
		ge(divid).className = 'notgone';
		if(divid == 'divIndustry') 
			el.form.industry.focus();
		else if(divid == 'divRole') 
			el.form.business_segment.focus();	
		else
			el.form.job_title.focus();
	} else 
		ge(divid).className = 'gone';
}

function putPos(elFrom,elTo) {
	if(trim(elTo.value) == '') {
		elTo.value = elFrom.options[elFrom.selectedIndex].getAttribute('desc');
		elTo.focus();
	}
	return false;	
}
function thisElValue (el,val,forced,exception) {
	if (trim(el.value) == '' || (exception != '' && el.value == exception) || forced)
		el.value = val;
	return false;
}

/* functions for Attaching files */
function addbrowse(a,divid,suffix) {
	div = document.createElement('div');
	ctr = parseInt(a.getAttribute("total"));
  if(ctr) {
		available_ctr = 1;
		while(ge('fn'+suffix+available_ctr)) {
			available_ctr++;
		}
		ctr = (ctr < available_ctr ? available_ctr : ctr);
	} else { available_ctr = ++ctr;	} ;
 	if(available_ctr > 5 ) {
		alert('Attachments are limited to 5 files only.');
		return false;
	}			
	div.id = 'fn'+suffix+available_ctr;
	div.className = "item";
	// create the file input
	input = document.createElement('input');
	input.name = 'fn'+available_ctr;
	input.type = "File";
	input.className = "f";
	input.size = "35";
	// create the remove link
	lnk = document.createElement('a');
	lnk.href = "#";
	lnk.onclick = function(){ removeEl(this.parentNode,a.id,suffix); return false; }
	lnk.appendChild(document.createTextNode('Remove'));
	lnk.className = 'textsmall remove';
	
	// create the error message element
	span = document.createElement('span');
	span.id = 'err_' + 'fn'+available_ctr+suffix;
	span.className = 'text';

	// append all elements to the item holder
	div.appendChild(input);
	div.appendChild(span);
	div.appendChild(lnk);
	
	// append item holder to the attachBox
	ge(divid).appendChild(div);
	
	// update counter and change the attachment link text
	a.setAttribute("total",ctr);
	a.innerHTML = 'Attach another file';
	//if(ctr == 5)
		//a.className = 'gone';
	return false;
}

function removeEl(el,b,suffix) {
	el.parentNode.removeChild(el);
	a = ge(b);
	ctr = parseInt(a.getAttribute("total"));
	for(i=1;i<=ctr;i++) {
		if(ge('fn'+suffix+i)) {
			a.innerHTML = 'Attach another file';				
			//a.className = 'textbold lnkAttach';
			return false;
		}	
	}
	a.innerHTML = 'Attach file';				
	a.setAttribute("total",0);
	return false;
}

function chkAttachFields(frm,attacher,suffix,lstValidFile) {
	/* code for checking 
		 the reply or message box or 
		 any other required fields 
		 should be done here 
		 before proceeding to the 
		 attachment checks below
	*/
	isOk = 0;
	a = ge(attacher);
	ctr = parseInt(a.getAttribute("total"));
	if(ctr) {
		if (typeof(lstValidFile) == 'undefined' || typeof(lstValidFile) == 'null' || lstValidFile == '') lstValidFile = "doc,xls,ppt,pdf,txt,jpg,jpeg,gif,png";
		for(i=1;i<=ctr;i++) {
			with(frm) {
				for(x=0; x<elements.length;x++) { 
					if(elements[x].name == 'fn'+i) {
						fval = elements[x].value;
						break;
					}	
				}
				if(ge('fn'+suffix+i) && fval != '') {
					//fval = frm.elements['fn'+i].value;
					if(fval.lastIndexOf(".") == -1) {
						alert(fval + ' file has no extension'); // alert if the file has no defined extension
						ge('err_' + 'fn'+i+suffix).innerHTML = '';
						isOk = -1;
						return isOk;
					} else {
						ext = fval.slice(fval.lastIndexOf(".")+1).toLowerCase();
						if(lstValidFile.indexOf(ext) == -1) {
							alert(ext.toUpperCase() + ' attachment is not allowed'); // alert if the file isn't valid
							ge('err_' + 'fn'+i+suffix).innerHTML = '';
							isOk = -1;
							return isOk;
						}	
					}
					elFrame = document.createElement('iframe');
					elFrame.name = target;
					frameholder = ge(target + 'Holder');
					if(frameholder.innerHTML == '') // create the iframe if doesn't exist
						frameholder.innerHTML = "<iframe name='" + target + "' src='about:blank' class='gone'/>";
					attachment_ctr.value = ctr;
					isOk = 1;
					if(ge(suffix+"BoxLoader")) {
						if(ge(suffix+"BoxLoader").innerHTML.indexOf("Loading...") != -1)
							ge(suffix+"BoxLoader").innerHTML = ge(suffix+"BoxLoader").innerHTML.replace(/Loading/g,"Uploading and scanning");
					}
				}	
			}
		}
	}
	return isOk;
}
function readablizeBytes(bytes) {
    var s = ['bytes', 'kb', 'MB', 'GB', 'TB', 'PB'];
    var e = Math.floor(Math.log(bytes)/Math.log(1024));
    return (bytes/Math.pow(1024, Math.floor(e))).toFixed(2)+" "+s[e];
}
/* functions for Attaching files */

function putLoader(divid) {
	ge(divid).innerHTML = '<div class="loadimg greytextsmall"><img src="/images/loadingdata.gif" style="vertical-align:middle;"> Loading...</div>';
	return false;
}

function showDiv(divId) {
	window.document.getElementById(divId).className = 'notgone';
}

function hideDiv(divId) {
	window.document.getElementById(divId).className = 'gone';
}
function trackLogger(src,id)
{
	document.getElementById(id).src= src;
}

function chkFormFieldsForgot(frm){
	with(frm){
		if(trim(email.value) == '') {
			alert('Please enter your email');
			email.focus();
			return false;
		}
		if(!checkEmail(email.value)) {
			alert('Email is not valid');
			email.focus();
			return false;
		}				
	}
	return true;	
}
function submitRequestForgot(frm,btn,divid) {
	//submitAjaxForm('/membership/loader.cfm?freeuser',divid,frm,loadData,btn,true);
	formAjax('/forgotPassword.cfm',divid,frm, loadData,btn)	
	return false; 
}

function popDivById(divid) {
	try {
  	switch (divid) {
  		case 'searchwhatsnew':
  			if (!ge(divid)) {
  				var popdiv = document.createElement('div');
  				var popcontent = document.createElement('div');
  				var poploader = document.createElement('div');
  				var popshadow = document.createElement('div');
  				var ifrm = document.createElement('iframe');
  				var x = document.createElement('a');
  				var h = document.createElement('h1');
  				var txtnode = document.createTextNode('close x');
  				var timestamp = new Date().getTime();
  				popdiv.id = divid;
  				popdiv.className = divid;
  				popcontent.className = 'popcontent';
  				poploader.id = 'poploader_' + timestamp;
  				popshadow.id = 'popshadow_' + timestamp;
  				popshadow.className = 'popshadow';
  				ifrm.id = 'iframe_' + timestamp;
  				ifrm.frameBorder = 0;
  				x.href = "close";
  				x.className = 'close';
  				x.appendChild(txtnode);
  				x.divid = divid;
  				x.onclick = function(){
  					putClass(this.divid, 'gone');
  					return false;
  				}
  				txtnode = document.createTextNode('What\'s new on our search engine...');
  				h.appendChild(txtnode);
  				popcontent.appendChild(x);
  				popcontent.appendChild(h);
  				popcontent.appendChild(poploader);
  				popdiv.appendChild(popcontent);
  				popdiv.appendChild(popshadow);
  				popdiv.appendChild(ifrm);
  				document.body.appendChild(popdiv);
  				putLoader(poploader.id);
  				ifrm.style.width = (popdiv.offsetWidth + 2) + 'px';
  				ifrm.style.height = (popdiv.offsetHeight + 2) + 'px';
  				popshadow.style.width = (popdiv.offsetWidth) + 'px';
  				popshadow.style.height = (popdiv.offsetHeight) + 'px';
  				urlAjax('/zscripts/xml.cfm?searchwhatsnew&timestamp=' + timestamp, poploader.id);
  				//centerThis(divid);
						topheader = ge('ztopheader');
						popdiv.style.left = ((topheader.offsetWidth - popdiv.offsetWidth) / 2) + 'px';
						popdiv.style.top = (topheaderpos[0] + topheader.offsetHeight + 3) + 'px';
						
					}
					else {
						putClass(divid, divid);
						/*topheader = ge('ztopheader');
						popdiv.style.left = ((topheader.offsetWidth - popdiv.offsetWidth) / 2) + 'px';
						popdiv.style.top = (topheaderpos[0] + topheader.offsetHeight + 3) + 'px';*/
					//centerThis(divid);
					}
					break;
			}
		} catch(e) {}
	return false;
}