function tabberObj(argsObj)
{
  var arg; 
  this.div = null;
  this.classMain = "tabber";
  this.classMainLive = "tabberlive";

  this.classTab = "tabbertab";

  this.classTabDefault = "tabbertabdefault";

  this.classNav = "tabbernav";

  this.classTabHide = "tabbertabhide";

  this.classNavActive = "tabberactive";

  this.titleElements = ['h2','h3','h4','h5','h6'];

  this.titleElementsStripHTML = true;

  this.removeTitle = true;

  this.addLinkId = false;

  this.linkIdFormat = '<tabberid>nav<tabnumberone>';

  for (arg in argsObj) { this[arg] = argsObj[arg]; }

  this.REclassMain = new RegExp('\\b' + this.classMain + '\\b', 'gi');
  this.REclassMainLive = new RegExp('\\b' + this.classMainLive + '\\b', 'gi');
  this.REclassTab = new RegExp('\\b' + this.classTab + '\\b', 'gi');
  this.REclassTabDefault = new RegExp('\\b' + this.classTabDefault + '\\b', 'gi');
  this.REclassTabHide = new RegExp('\\b' + this.classTabHide + '\\b', 'gi');

  this.tabs = new Array();

  if (this.div) {

    this.init(this.div);

    this.div = null;
  }
}


tabberObj.prototype.init = function(e)
{

  var
  childNodes, /* child nodes of the tabber div */
  i, i2, /* loop indices */
  t, /* object to store info about a single tab */
  defaultTab=0, /* which tab to select by default */
  DOM_ul, /* tabbernav list */
  DOM_li, /* tabbernav list item */
  DOM_a, /* tabbernav link */
  aId, /* A unique id for DOM_a */
  headingElement; /* searching for text to use in the tab */

  if (!document.getElementsByTagName) { return false; }

  if (e.id) {
    this.id = e.id;
  }

  this.tabs.length = 0;

  childNodes = e.childNodes;
  for(i=0; i < childNodes.length; i++) {

    if(childNodes[i].className &&
       childNodes[i].className.match(this.REclassTab)) {
      
      t = new Object();
      
      t.div = childNodes[i];
      
      this.tabs[this.tabs.length] = t;

      if (childNodes[i].className.match(this.REclassTabDefault)) {
	defaultTab = this.tabs.length-1;
      }
    }
  }

  DOM_ul = document.createElement("ul");
  DOM_ul.className = this.classNav;
  
  for (i=0; i < this.tabs.length; i++) {

    t = this.tabs[i];

    t.headingText = t.div.title;

    if (this.removeTitle) { t.div.title = ''; }

    if (!t.headingText) {

     
      for (i2=0; i2<this.titleElements.length; i2++) {
	headingElement = t.div.getElementsByTagName(this.titleElements[i2])[0];
	if (headingElement) {
	  t.headingText = headingElement.innerHTML;
	  if (this.titleElementsStripHTML) {
	    t.headingText.replace(/<br>/gi," ");
	    t.headingText = t.headingText.replace(/<[^>]+>/g,"");
	  }
	  break;
	}
      }
    }

    if (!t.headingText) {
      
      t.headingText = i + 1;
    }

    
    DOM_li = document.createElement("li");

   
    t.li = DOM_li;

    
    DOM_a = document.createElement("a");
    DOM_a.appendChild(document.createTextNode(t.headingText));
    DOM_a.href = "javascript:void(null);";
    DOM_a.title = t.headingText;
    DOM_a.onclick = this.navClick;

    
    DOM_a.tabber = this;
    DOM_a.tabberIndex = i;

    
    if (this.addLinkId && this.linkIdFormat) {

      
      aId = this.linkIdFormat;
      aId = aId.replace(/<tabberid>/gi, this.id);
      aId = aId.replace(/<tabnumberzero>/gi, i);
      aId = aId.replace(/<tabnumberone>/gi, i+1);
      aId = aId.replace(/<tabtitle>/gi, t.headingText.replace(/[^a-zA-Z0-9\-]/gi, ''));

      DOM_a.id = aId;
    }

    DOM_li.appendChild(DOM_a);

    DOM_ul.appendChild(DOM_li);
  }

  e.insertBefore(DOM_ul, e.firstChild);

  e.className = e.className.replace(this.REclassMain, this.classMainLive);

  this.tabShow(defaultTab);

  if (typeof this.onLoad == 'function') {
    this.onLoad({tabber:this});
  }

  return this;
};


tabberObj.prototype.navClick = function(event)
{
    var
  rVal, /* Return value from the user onclick function */
  a, /* element that triggered the onclick event */
  self, /* the tabber object */
  tabberIndex, /* index of the tab that triggered the event */
  onClickArgs; /* args to send the onclick function */

  a = this;
  if (!a.tabber) { return false; }

  self = a.tabber;
  tabberIndex = a.tabberIndex;

  a.blur();

  if (typeof self.onClick == 'function') {

    onClickArgs = {'tabber':self, 'index':tabberIndex, 'event':event};

    /* IE uses a different way to access the event object */
    if (!event) { onClickArgs.event = window.event; }

    rVal = self.onClick(onClickArgs);
    if (rVal === false) { return false; }
  }

  self.tabShow(tabberIndex);

  return false;
};


tabberObj.prototype.tabHideAll = function()
{
  var i; /* counter */

  for (i = 0; i < this.tabs.length; i++) {
    this.tabHide(i);
  }
};


tabberObj.prototype.tabHide = function(tabberIndex)
{
  var div;

  if (!this.tabs[tabberIndex]) { return false; }

  div = this.tabs[tabberIndex].div;

  if (!div.className.match(this.REclassTabHide)) {
    div.className += ' ' + this.classTabHide;
  }
  this.navClearActive(tabberIndex);

  return this;
};


tabberObj.prototype.tabShow = function(tabberIndex)
{
  var div;

  if (!this.tabs[tabberIndex]) { return false; }

  this.tabHideAll();

  div = this.tabs[tabberIndex].div;

  div.className = div.className.replace(this.REclassTabHide, '');

  this.navSetActive(tabberIndex);

  if (typeof this.onTabDisplay == 'function') {
    this.onTabDisplay({'tabber':this, 'index':tabberIndex});
  }

  return this;
};

tabberObj.prototype.navSetActive = function(tabberIndex)
{
  this.tabs[tabberIndex].li.className = this.classNavActive;

  return this;
};


tabberObj.prototype.navClearActive = function(tabberIndex)
{
  this.tabs[tabberIndex].li.className = '';

  return this;
};


/*==================================================*/


function tabberAutomatic(tabberArgs)
{
  
  var
    tempObj, /* Temporary tabber object */
    divs, /* Array of all divs on the page */
    i; /* Loop index */

  if (!tabberArgs) { tabberArgs = {}; }

  tempObj = new tabberObj(tabberArgs);

  divs = document.getElementsByTagName("div");
  for (i=0; i < divs.length; i++) {
    
    if (divs[i].className &&
	divs[i].className.match(tempObj.REclassMain)) {
      
      tabberArgs.div = divs[i];
      divs[i].tabber = new tabberObj(tabberArgs);
    }
  }
  
  return this;
}

function tabberAutomaticOnLoad(tabberArgs)
{
  var oldOnLoad;

  if (!tabberArgs) { tabberArgs = {}; }

  oldOnLoad = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = function() {
      tabberAutomatic(tabberArgs);
    };
  } else {
    window.onload = function() {
      oldOnLoad();
      tabberAutomatic(tabberArgs);
    };
  }
}

if (typeof tabberOptions == 'undefined') {

    tabberAutomaticOnLoad();

} else {

  if (!tabberOptions['manualStartup']) {
    tabberAutomaticOnLoad(tabberOptions);
  }

}


function ddtabcontent(tabinterfaceid){
	this.tabinterfaceid=tabinterfaceid //ID of Tab Menu main container
	this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container
	this.enabletabpersistence=true
	this.hottabspositions=[] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container
	this.currentTabIndex=0 //Index of currently selected hot tab (tab with sub content) within hottabspositions[] array
	this.subcontentids=[] //Array to store ids of the sub contents ("rel" attr values)
	this.revcontentids=[] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)
	this.selectedClassTarget="link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")
}

ddtabcontent.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

ddtabcontent.setCookie=function(name, value){
	document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)
}

ddtabcontent.prototype={

	expandit:function(tabid_or_position){ //PUBLIC function to select a tab either by its ID or position(int) within its peers
		this.cancelautorun() //stop auto cycling of tabs (if running)
		var tabref=""
		try{
			if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel")) //if specified tab contains "rel" attr
				tabref=document.getElementById(tabid_or_position)
			else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel")) //if specified tab contains "rel" attr
				tabref=this.tabs[tabid_or_position]
		}
		catch(err){alert("Invalid Tab ID or position entered!")}
		if (tabref!="") //if a valid tab is found based on function parameter
			this.expandtab(tabref) //expand this tab
	},

	cycleit:function(dir, autorun){ //PUBLIC function to move foward or backwards through each hot tab (tabinstance.cycleit('foward/back') )
		if (dir=="next"){
			var currentTabIndex=(this.currentTabIndex<this.hottabspositions.length-1)? this.currentTabIndex+1 : 0
		}
		else if (dir=="prev"){
			var currentTabIndex=(this.currentTabIndex>0)? this.currentTabIndex-1 : this.hottabspositions.length-1
		}
		if (typeof autorun=="undefined") //if cycleit() is being called by user, versus autorun() function
			this.cancelautorun() //stop auto cycling of tabs (if running)
		this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]])
	},

	setpersist:function(bool){ //PUBLIC function to toggle persistence feature
			this.enabletabpersistence=bool
	},

	setselectedClassTarget:function(objstr){ //PUBLIC function to set which target element to assign "selected" CSS class ("linkparent" or "link")
		this.selectedClassTarget=objstr || "link"
	},

	getselectedClassTarget:function(tabref){ //Returns target element to assign "selected" CSS class to
		return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref
	},

	urlparamselect:function(tabinterfaceid){
		var result=window.location.search.match(new RegExp(tabinterfaceid+"=(\\d+)", "i")) //check for "?tabinterfaceid=2" in URL
		return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index
	},

	expandtab:function(tabref){
		var subcontentid=tabref.getAttribute("rel") //Get id of subcontent to expand
		//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easily search through
		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
		this.expandsubcontent(subcontentid)
		this.expandrevcontent(associatedrevids)
		for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"
			this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("rel")==subcontentid)? "selected" : ""
		}
		if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
			ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition)
		this.setcurrenttabindex(tabref.tabposition) //remember position of selected tab within hottabspositions[] array
	},

	expandsubcontent:function(subcontentid){
		for (var i=0; i<this.subcontentids.length; i++){
			var subcontent=document.getElementById(this.subcontentids[i]) //cache current subcontent obj (in for loop)
			subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none" //"show" or hide sub content based on matching id attr value
		}
	},

	expandrevcontent:function(associatedrevids){
		var allrevids=this.revcontentids
		for (var i=0; i<allrevids.length; i++){ //Loop through rev attributes for all tabs in this tab interface
			//if any values stored within associatedrevids matches one within allrevids, expand that DIV, otherwise, contract it
			document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"
		}
	},

	setcurrenttabindex:function(tabposition){ //store current position of tab (within hottabspositions[] array)
		for (var i=0; i<this.hottabspositions.length; i++){
			if (tabposition==this.hottabspositions[i]){
				this.currentTabIndex=i
				break
			}
		}
	},

	autorun:function(){ //function to auto cycle through and select tabs based on a set interval
		this.cycleit('next', true)
	},

	cancelautorun:function(){
		if (typeof this.autoruntimer!="undefined")
			clearInterval(this.autoruntimer)
	},

	init:function(automodeperiod){
		var persistedtab=ddtabcontent.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)
		var selectedtab=-1 //Currently selected tab index (-1 meaning none)
		var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid) //returns null or index from: tabcontent.htm?tabinterfaceid=index
		this.automodeperiod=automodeperiod || 0
		for (var i=0; i<this.tabs.length; i++){
			this.tabs[i].tabposition=i //remember position of tab relative to its peers
			if (this.tabs[i].getAttribute("rel")){
				var tabinstance=this
				this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers
				this.subcontentids[this.subcontentids.length]=this.tabs[i].getAttribute("rel") //store id of sub content ("rel" attr value)
				this.tabs[i].onclick=function(){
					tabinstance.expandtab(this)
					tabinstance.cancelautorun() //stop auto cycling of tabs (if running)
					return false
				}
				if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element
					this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))
				}
				if (selectedtabfromurl==i || this.enabletabpersistence && selectedtab==-1 && parseInt(persistedtab)==i || !this.enabletabpersistence && selectedtab==-1 && this.getselectedClassTarget(this.tabs[i]).className=="selected"){
					selectedtab=i //Selected tab index, if found
				}
			}
		} //END for loop
		if (selectedtab!=-1) //if a valid default selected tab index is found
			this.expandtab(this.tabs[selectedtab]) //expand selected tab (either from URL parameter, persistent feature, or class="selected" class)
		else //if no valid default selected index found
			this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr
		if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){
			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)
		}
	} //END int() function

} //END Prototype assignment



var popUpVisible = false;
var xmlHttp = null;

function isInteger (value,pos) //pos = 1 : Strictly Positive; pos = 2 : Non negative
{
	if ( isNaN (value) )
	{
		return false;
	}
	else
	if ( Math.floor(value)-value != 0 )
	{
		return false;
	}
	else
	if (pos==2 && value<0)
	{
		return false;
	}
	else
	if (pos==1 && value<=0)
	{
		return false;
	}
	else
	{
		return true;
	}
}


function showPopUp (popUpText,popUpSubmitButtonText)
{
	var popUp = document.getElementById ('pop_up');
	popUp.style.display = "block";
	popUpVisible = true;
	
	if (popUpText != undefined )
	{
		var popUpTextElement = document.getElementById ('pop_up_text');
		popUpTextElement.innerHTML = popUpText;
	}
	
	if(popUpSubmitButtonText != undefined )
	{
		var popUpSubmitButtonTextElement = document.getElementById ('pop_up_submit_button_text');
		popUpSubmitButtonTextElement.innerHTML = popUpSubmitButtonText;
	}
}

function collapsePopUp ()
{
	var popUp = document.getElementById ('pop_up');
	popUp.style.display = "none";
	popUpVisible = false;
}

function switchMousePointer (checkVar,elementId)
{
	if(!checkVar)
	{
		document.getElementById(elementId).style.cursor='pointer';
	}
	else
	{
		document.getElementById(elementId).style.cursor='default';
	}
}

function executeOrder (formName,isBuy,popUpText,maxQuantity)
{
	var formElement = document.getElementById(formName);
	if (isBuy)
	{
		if (isInteger(formElement.qty.value,1) && (maxQuantity==undefined || Math.floor(formElement.qty.value)<=maxQuantity ))
		{
			showPopUp (popUpText);
		}
		else
		{
			alert('Enter a positive integral value in quantity'+((maxQuantity==undefined)?'':(' less than or equal to '+maxQuantity))+' .');
		}
	}
}

function followMouse(evt,elementId)
{
	mouseX=evt.pageX?evt.pageX:(evt.clientX + document.documentElement.scrollLeft + document.body.scrollLeft);
	mouseY=evt.pageY?evt.pageY:(evt.clientY + document.documentElement.scrollTop + document.body.scrollTop);
	
	var notIE7  = (navigator.appVersion.indexOf("MSIE 7") != -1) ? 0 : 1;
	var moveX = 0;//150*notIE7;
	var moveY = 0;//85*notIE7;
	document.getElementById(elementId).style.left=mouseX-moveX-document.getElementById(elementId).clientWidth/2 +'px';
	document.getElementById(elementId).style.top =mouseY-moveY-document.getElementById(elementId).clientHeight +'px';
	
}

function updateDiv (firstElementId,prefix,divElementId)
{
	var fetchValueElement = prefix+document.getElementById(firstElementId).value;
	document.getElementById(divElementId).innerHTML=document.getElementById(fetchValueElement).value;
}

function getValue (firstElementId,prefix)
{
	var fetchValueElement = prefix+document.getElementById(firstElementId).value;
	return document.getElementById(fetchValueElement).value;
}

function GetXmlHttpObject()
{
	xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
}

var myJson = null;
var numRows = 4;
var numEnteriesPerRow = 7;

function fetchAll(id,ind,mainDiv,textDiv)
{
	document.getElementById (mainDiv).style.display = 'block';
	if (document.getElementById(textDiv).innerHTML!='')
	{
		return;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="view_all.php";
	var finalPost="pm_id="+id+"&fol="+ind+"&div1="+mainDiv+"&div2="+textDiv;
	xmlHttp.open("POST", url, true);
	xmlHttp.onreadystatechange=stateChangedViewAll;
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", finalPost.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(finalPost);
	
}

function stateChangedViewAll()
{
	if (xmlHttp.readyState==4)
	{ 
		if (xmlHttp.status == 200)
		{
			myJson = eval ('('+xmlHttp.responseText+')');					
			if (myJson.error != 0)
			{
				document.getElementById (myJson.div1).style.display = 'none';
				alert ("Error Accessing information" );
			}
			else
			{
				showFollowers (1);
			}
		}
		else
		{
			alert ("Error Accessing information" );
			window.location = window.location;
		}
	}
}

function showFollowers (pageNum)
{
	var totalPages = Math.ceil(myJson.enteries.length/numEnteriesPerRow/numRows);
	if ( pageNum > totalPages )
		return;
	var html = '<table width="100%" border="0" align="center">';
	for (var loopVar1 = (pageNum-1)*numRows; (loopVar1<pageNum*numRows && loopVar1*numEnteriesPerRow<myJson.enteries.length); loopVar1 ++)
	{
		var html1 = '<tr>';
		var html2 = '<tr>';
		var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? 1 : 0;
		for (var loopVar2 = 0; (loopVar2<numEnteriesPerRow && (loopVar2+loopVar1*numEnteriesPerRow<myJson.enteries.length-isIE)); loopVar2 ++)
		{
			if (myJson.enteries[loopVar2+loopVar1*numEnteriesPerRow].user_type==1)
				html1 += '<td width="13%" align="center" valign="middle"><img src="http://images.ibibo.com/displayavatar.aspx?id='+myJson.enteries[loopVar2+loopVar1*numEnteriesPerRow].ib_id+'&s=48" width="48" height="48" style="cursor:pointer;" onclick="window.location=\'portfolio.php?id='+myJson.enteries[loopVar2+loopVar1*numEnteriesPerRow].pm_id+'\'" title="'+myJson.enteries[loopVar2+loopVar1*numEnteriesPerRow].name+'" /></td>';
			else
				html1 += '<td width="13%" align="center" valign="middle"><img src="'+myJson.enteries[loopVar2+loopVar1*numEnteriesPerRow].image_url+'" width="48" height="48" style="cursor:pointer;" onclick="window.location=\'portfolio.php?id='+myJson.enteries[loopVar2+loopVar1*numEnteriesPerRow].pm_id+'\'" title="'+myJson.enteries[loopVar2+loopVar1*numEnteriesPerRow].name+'" /></td>';
			html2 += ' <td align="center" valign="middle">'+'&nbsp;'+'</td>';					
		}
		html1 += '</tr>';
		html2 += '</tr>';
		html += html1+html2;
		
	}
	
	currentPage = '<div class="stock_box-grey">';
	otherPage1 = '<div class="stock_box-yellow" style="cursor:pointer;" onclick="showFollowers(';
	otherPage2 = ')">';
	
	html += '</table>';
	
	
	if ( totalPages > 1 )
	{
		if (pageNum==1)
		{
			html += '<div style="float:right; width:150px; margin-bottom:10px;"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">'+currentPage+'1</div></td>';
			for (loopVar1=2;loopVar1<=4 && loopVar1 <=totalPages; loopVar1 ++)
			{
				html += '<td align="center" valign="middle">'+otherPage1+loopVar1+otherPage2+loopVar1+'</div></td>';
			}
			if (loopVar1 <= totalPages)
				html += '<td align="center" valign="middle"><div style="cursor:pointer;" onclick="showFollowers('+loopVar1+')" class="stock_box-next">NEXT</div></td></tr></table></div>';
		}
		else
		{
			html += '<div style="float:right; width:150px; margin-bottom:10px;"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">'+otherPage1+'1'+otherPage2+'1</div></td>';
			for ((loopVar1=(pageNum==2)?2:(pageNum-1));loopVar1<=pageNum+1 && loopVar1 <=totalPages; loopVar1 ++)
			{
				if (loopVar1 != pageNum )
					html += '<td align="center" valign="middle">'+otherPage1+loopVar1+otherPage2+loopVar1+'</div></td>';
				else
					html += '<td align="center" valign="middle">'+currentPage+loopVar1+'</div></td>';
				
			}
			
			if (loopVar1 <= totalPages)
				html += '<td align="center" valign="middle"><div style="cursor:pointer;" onclick="showFollowers('+loopVar1+')" class="stock_box-next">NEXT</div></td></tr></table></div>';
		}
	}
	document.getElementById (myJson.div2).innerHTML = html;
}

function checkSearch (anchorId,searchBoxId,buttonText)
{
	var currentURL = document.location.href;
	var indexOfHash = currentURL.indexOf('#');
	if (indexOfHash!=-1)
		currentURL = currentURL.substring (0,indexOfHash);	
	
	var tempURL = document.getElementById(anchorId).href;
	indexOfHash = tempURL.indexOf('#');
	
	/*if(document.getElementById(anchorId).href=='#' || document.getElementById(anchorId).href==(currentURL+'#'))*/
	if (indexOfHash!=-1)
	{
		if ( document.getElementById(searchBoxId).value=="")
			alert ('Please enter the stock name.');
		else
		{
			alert ('Please enter a valid Stock Name.\nYou can only trade stocks that are listed on BSE.');
		}
		document.getElementById(searchBoxId).value="";
		return false;
	}
	
	return true;
}

function clearSearch (anchorId,searchBoxId)
{
	document.getElementById(anchorId).href='#';
	if (searchBoxId!=undefined)
		document.getElementById(searchBoxId).value="";
}

function currencyConvert(num,numDecimals)
{
	var sign = '';
	if (num<0)
	{
		num *= -1;
		sign = '-';
	}
	var nStr = num.toFixed(numDecimals);
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx3 = /(^\d+)(\d{3})/;
	var rgx = /(^\d+)(\d{2})/;
	if (rgx3.test(x1))
	{
		x1 = x1.replace(rgx3, '$1' + ',' + '$2');
	}
	if (x1.length>3)
	{
		while (rgx.test(x1))
		{
			x1 = x1.replace(rgx, '$1' + ',' + '$2');
		}
	}
	return sign + x1 + x2;
}

function checkKey(e)
{
	var keynum;
	
	if(window.event) // IE
	  {
	  keynum = e.keyCode;
	  }
	else if(e.which) // Netscape/Firefox/Opera
	  {
	  keynum = e.which;
	  }
	if (((keynum >= 0x30) && (keynum < 0x3A)) || keynum==8 || keynum==13 || keynum==undefined)
	{
		return true;
	}
	return false;
}

function changeEvent ()
{
	var qtyValue = document.getElementById('buy_form').qty.value;
	if (isInteger(qtyValue))
		document.getElementById('cash_need').innerHTML=currencyConvert(qtyValue*document.getElementById('buy_form').sPrice.value*(1+document.getElementById('buy_form').comm.value/100),2);
	else
	{
		qtyValue = 1;
		document.getElementById('buy_form').qty.value = qtyValue;
		document.getElementById('cash_need').innerHTML=currencyConvert((0+qtyValue)*document.getElementById('buy_form').sPrice.value*(1+document.getElementById('buy_form').comm.value/100),2);
	}
	
	return true;
}

function pageOnLoadComplete ()
{
	var tempElement1 = document.getElementById ('portsearch');
	var tempElement2 = document.getElementById ('buy_search_button');
	var tempElement3 = document.getElementById ('sharesearch');
	var tempElement4 = document.getElementById ('search_button_header');
	var tempElement5 = document.getElementById ('short_sell_search_button');
	if (tempElement1 && tempElement1 != undefined)
	{
		tempElement1.style.display = 'block';
	}
	if (tempElement2 && tempElement2 != undefined)
	{
		tempElement2.style.display = 'block';
	}
	if (tempElement3 && tempElement3 != undefined)
	{
		tempElement3.style.display = 'block';
	}
	if (tempElement4 && tempElement4 != undefined)
	{
		tempElement4.style.display = 'block';
	}
	if (tempElement5 && tempElement5 != undefined)
	{
		tempElement5.style.display = 'block';
	}
	
	jQuery("#sharesearch").keyup(function(event){
	  if(event.keyCode == 13){
		if ( jQuery("#search_button_header").click() )
		{
			window.location.href = jQuery("#search_button").attr('href');
		}
	  }
	});
	
	jQuery("#portsearch").keyup(function(event){
	  if(event.keyCode == 13){
		if ( jQuery("#buy_search_button").click() )
		{
			window.location.href = jQuery("#buy_button").attr('href');
		}
	  }
	});
}


