
var IE = document.all?true:false;

var s_selected_g='pricechart';
var mobile_promo_pricehcart='companypromo';


function post_compfrm()
{
	if(document.comp_peers_frm.comp_type.value == "")
	{
		alert("Please select a Comparison Criteria!!!")
		document.comp_peers_frm.comp_type.focus();
		return false;
	}
	document.comp_peers_frm.action = "/stocks/company_info/competition.php";
	document.comp_peers_frm.submit();
	return true;
}

function show_addport()
{
	document.getElementById("addport_div").style.display="block";
}

function post_addport()
{
	var sc_id = document.addport_frm.sc_id.value;
	var sc_smid = document.addport_frm.sc_smid.value;
	var buy_dd = document.addport_frm.b_dd.value;
	var buy_mm = document.addport_frm.b_mm.value;
	var buy_yy = document.addport_frm.b_yy.value;
	var buy_dt = buy_yy+"-"+buy_mm+"-"+buy_dd;

	var buy_qty = document.addport_frm.b_qty.value;
	var buy_price = document.addport_frm.b_price.value;
	if(buy_dt.length != 10)
	{
		alert("Please select buy date");
		document.addport_frm.b_dd.focus;
		return false;
	}

	if(buy_qty.length <= 0 || buy_qty == "0")
	{
		alert("Buy Qty. cannot be 0");
		document.addport_frm.b_qty.focus;
		return false;
	}
	
	if(buy_price.length <= 0 || buy_price == "0")
	{
		alert("Buy Price cannot be 0");
		document.addport_frm.b_price.focus;
		return false;
	}
	document.addport_frm.buy_date.value = buy_dt;
	document.addport_frm.referer.value = "/portfolio_plus/add_stocks_pc.php?post_values="+sc_id+"|"+sc_smid+"|"+buy_dt+"|"+buy_qty+"|"+buy_price;
	document.addport_frm.post_values.value = sc_id+"|"+sc_smid+"|"+buy_dt+"|"+buy_qty+"|"+buy_price;
	document.addport_frm.submit();
	return true;
}

function post_addwl()
{
	var sc_id = document.addwl_frm.sc_id.value;
	var sc_smid = document.addwl_frm.sc_smid.value;
	var short_name = document.addwl_frm.short_name.value;
	var postvalues = sc_id+"~"+sc_smid+"~"+short_name;

	document.addwl_frm.referer.value = "/portfolio_plus/add_stk_wl_pc.php?postvalues="+postvalues;
//	document.addwl_frm.postvalues.value = postvalues;
	document.addwl_frm.submit();
	return true;
}

function close_addport()
{
	document.getElementById("addport_div").style.display="none";
	return false;
}

function checkInt(obj)
{
	if((obj.value*1)!=obj.value)
	{obj.value="";}
	
	if(obj.value.indexOf(" ",0)!=-1)
	{
		obj.value="";
		alert ("No Spaces Allowed");
		obj.focus();
		obj.value="";
	}
}

function votewiki(newsid,vote,wiki_name)
{
	entid=document.getElementById("entityid").value;
	document.getElementById("vote").value=vote;

	document.wikivote.action = "http://connect.in.com/profile/"+wiki_name+"/"+newsid;
	//alert(document.wikivote.action);
	document.wikivote.submit();		
	return false;
}

function post_hist_price(div_no)
{
	if(div_no == "1")
	{
		document.getElementById("bse_hist_price").style.display = "block";
		document.getElementById("nse_hist_price").style.display = "none";
		document.getElementById("bsehist_id").innerHTML = "BSE";
		document.getElementById("nsehist_id").innerHTML = "<a href='javascript:void(0);' onclick=\"post_hist_price('2');\">NSE</a>";
		document.getElementById("bsehist_id").className = "on";
		document.getElementById("nsehist_id").className = "";
	}
	else
	{
		document.getElementById("bse_hist_price").style.display = "none";
		document.getElementById("nse_hist_price").style.display = "block";
		document.getElementById("nsehist_id").innerHTML = "NSE";
		document.getElementById("bsehist_id").className = "";
		document.getElementById("nsehist_id").className = "on";
		document.getElementById("bsehist_id").innerHTML = "<a href='javascript:void(0);' onclick=\"post_hist_price('1');\">BSE</a>";
	}
}

function price_chkfeed()
{
	var msgobj=document.enter_newmsg.f_message;
	var headobj=document.enter_newmsg.f_heading;
	var tmp=msgobj.value;
	var heading=headobj.value;
	
	tmp.replace(" ","");
	heading.replace(" ","");
 
	if(heading=="" || heading=="Heading")
	{
		alert("Please input heading");
		headobj.focus();
		return false;
	}

	if(tmp.length < 1 || tmp=="Comment")
	{
		alert("Please input your Message");
		msgobj.focus();
		return false;
	}
	else if(tmp.length < 4)
	{
		alert ("Please enter the message more then 4 character");
		return false;
	}

	if(tmp.length > 5000)
	{
		alert("max 5000 characters allowed");
		return false;
	}
	
	var char1=new Array('<','>','&lt;','&gt;','http://');
	for(i=0;i<=char1.length;++i)
	{
		if(tmp.indexOf(char1[i],0)!=-1)
		{
			alert("No "+char1[i]+" allowed");
			return false;
		}
	}

	var str=tmp;
	str=str.toLowerCase();
	var char1=new Array('<','>','www','&lt;','&gt;','http://','.com','.net','.org','.fr','.in','fuck','aswhole','co.uk');
	for(i=0;i<=char1.length;++i)
	{
		if(str.indexOf(char1[i],0)!=-1)
		{
			alert("Word "+char1[i]+" not allowed");
			return false;
		}
	}
	return true;
}

function post_addalert()
{
	var postvalues = document.addalert_frm.postvalues.value;
	document.addalert_frm.referer.value = "/portfolio_plus/set_alerts.php?postvalues="+postvalues;
	document.addalert_frm.submit();
	return false;
}