var arrActions = new Array();
arrActions[0] = new Array();
arrActions[0][0] = "company";
arrActions[0][1] = "/cm/companylookup.cfm";
arrActions[0][2] = "companyname";
arrActions[0][3] = "Company Name or Symbol";
arrActions[1] = new Array();
arrActions[1][0] = "news";
arrActions[1][1] = "/nc/searchresult.cfm";
arrActions[1][2] = "QUERY";
arrActions[1][3] = "News or Analysis by Keywords";
arrActions[2] = new Array();
arrActions[2][0] = "research";
arrActions[2][1] = "/nc/searchresult.cfm";
arrActions[2][2] = "QUERY";
arrActions[2][3] = "Research Monitor by Keyword";
arrActions[3] = new Array();
arrActions[3][0] = "ipo";
arrActions[3][1] = "/ipomonitor/searchresult.cfm";
arrActions[3][2] = "ipoSearch";
arrActions[3][3] = "Search Issuer or Advisor";
arrActions[4] = new Array();
arrActions[4][0] = "sukuk";
arrActions[4][1] = "/middle-east/sukuk/searchresult.cfm";
arrActions[4][2] = "sukukSearch";
arrActions[4][3] = "Sukuk Monitor by Keyword";
arrActions[5] = new Array();
arrActions[5][0] = "private";
arrActions[5][1] = "/middle-east/private-equity/default.cfm";
arrActions[5][2] = "peSearch";
arrActions[5][3] = "Private Equity Monitor by Keyword";
arrActions[6] = new Array();
arrActions[6][0] = "mutual";
arrActions[6][1] = "/middle-east/funds/searchresult.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] = "/middle-east/projects/projectLookUp.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 = "text";
		window.document.getElementById("SearchLnk_"+arrActions[num][0]).className = (prod == "ZI"?"header3":"textbold");
		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 = $(divid);
	if(div.innerHTML.indexOf('Loading...') != -1 || reload)
		ajaxCaller.getPlainText(url,loadData,divid);
}
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("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)-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 = 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 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 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(bclSec,bclInd_list,bclCtry,bclExch,formObj)
{
	bclSec = !validObject(bclSec)?"":bclSec;
	bclInd_list = !validObject(bclInd_list)?"":bclInd_list;
	bclCtry = !validObject(bclCtry)?"":bclCtry;
	bclExch = !validObject(bclExch)?"":bclExch;
	formObj = !validObject(formObj)?"buildlist":formObj;
	with(document.forms[formObj])
	{
		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;
	}
	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"> <span class="greytextsmall">Loading ...</span></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";
	document.getElementById("feedbackArrowImg").src = "/images/ZP_feedback_arrow_down.gif";
	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;
	}
	document.getElementById("feedBackHeaderBox").onclick = function(){hideFeedback(prod);};
	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";
	document.getElementById("feedbackArrowImg").src = "/images/ZP_feedback_arrow_right.gif";
	document.getElementById("feedBackWindow").className = "gone";
	document.getElementById("feedBackHeaderBox").onclick = function(){showFeedback(prod);};
	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 (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})+$/;
	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;
	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 callBackShowDivCompRanking(text,callingContext,headers,arrParams){
	window.document.getElementById(callingContext).innerHTML = text;
}
function showDivCompRanking(objId,targetajax){			
	document.getElementById(objId).innerHTML = '<div class="loadimg"><img src="/images/LoadingData.gif" border="0" style="vertical-align:middle"> <span class="greytextsmall">Loading ...</span></div>';
	ajaxCaller.getPlainText(targetajax, callBackShowDivCompRanking, objId);
}
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');
}
