// JavaScript Document
//common tech2 js functions
function valaskexpert(form1){ alert('hi');
	var frm = document.askform;		alert("q="+frm.question.value);
	if(frm.question.value==""){		alert("q="+frm.question);
		alert("please enter the question");
		frm.question.focus();
		return false;
	}/*else{
		document.askform.action="askexpert.php";
		document.askform.submit();
		return true;
	}*/
	return true;
}

function validateqna(){
	if(document.askform.qnaquestion.value == '' || document.askform.qnaquestion.value == 'Question'){
		alert("Please enter your question");
		document.askform.qnaquestion.focus();
	}else{
		document.askform.action="/askexpert.php";
		document.askform.submit();
	}
	return false;
}

function popupaboutus(id,flag) {
	oNewWindow = window.open("/popup_aboutus.php?flag="+flag+"&id="+id,null,"height=450,width=400,status=yes,toolbar=no,menubar=no,location=no");
}

function popupsugestquiz(id,flag) {
	oNewWindow = window.open("/popupsugestquiz.php?flag="+flag+"&id="+id,null,"height=450,width=400,status=yes,toolbar=no,menubar=no,location=no");
}
/*function popupsugestcolumn(authorid) {
	oNewWindow = window.open("popupsugestcolumn.php?authorid="+authorid,null,"height=450,width=400,status=yes,toolbar=no,menubar=no,location=no");
}*/
function popupsugestcolumn(id,flag) {
	oNewWindow = window.open("/popupsugestcolumn.php?flag="+flag+"&id="+id,null,"height=450,width=400,status=yes,toolbar=no,menubar=no,location=no");
}
function popupsugeststory(id,flag) {
	oNewWindow = window.open("/popupsugeststory.php?flag="+flag+"&id="+id,null,"height=450,width=400,status=yes,toolbar=no,menubar=no,location=no");
}
function popupsugestgallery(id,flag) {
	oNewWindow = window.open("/popupsugestgallery.php?flag="+flag+"&id="+id,null,"height=450,width=400,status=yes,toolbar=no,menubar=no,location=no");
}
function popupsugestvideo(id,flag) {
	oNewWindow = window.open("/popupsugestvideo.php?flag="+flag+"&id="+id,null,"height=450,width=400,status=yes,toolbar=no,menubar=no,location=no");
}
function popupsugeststartupkit(id,flag) {
	oNewWindow = window.open("http://wealth.moneycontrol.com/popupsugeststartupkit.php?flag="+flag+"&id="+id,null,"height=450,width=400,status=yes,toolbar=no,menubar=no,location=no");
}

function popupsugestpoll(pollid, flag) {
	oNewWindow = window.open("/popupsugestpoll.php?flag="+flag+"&pollid="+pollid,null,"height=450,width=400,status=yes,toolbar=no,menubar=no,location=no");
}
/*function popuppoll(id,option){
	oNewWindow = window.open("popupresult1.php?id="+id+"&option="+option,null,"height=336,width=400,status=yes,toolbar=no,menubar=no,location=no");
}*/
function popuppoll(id,option, sid){ 
	document.location.href = "http://wealth.moneycontrol.com/popupresult1.php?id="+id+"&option="+option+"&sid="+sid;
}

function popuppollresult(id, sid){
	//oNewWindow = window.open("popupresult2.php?id="+id,null,"height=336,width=400,status=yes,toolbar=no,menubar=no,location=no");
	document.location.href = "/popupresult1.php?id="+id+"&sid="+sid;
}

function biopopup(authorid) {
	oNewWindow = window.open("/popupauthorbio.php?authorid="+authorid,null,"height=500,width=400,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes");
}
function textLimit(field, maxlen) {
	if (field.value.length > maxlen) {
	field.value = field.value.substring(0, maxlen);
	alert('Only 800 Character Allowed!');
	} 
}

function createAlertPopup(authorid) 
{
	oNewWindow = window.open("/alertpopup.php?authorid="+authorid,null,"height=280,width=400,status=yes,toolbar=no,menubar=no,location=no");
}

function callsign(sid, sign){
  document.location.href='/horoscope.php?sid='+sid+'#'+sign
}

function validate(){
	emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/
	val = document.comments;
	
	if(val.comment.value==''){
		alert("Enter comment");
		val.comment.focus();
		return false;
		
	}
	if(val.commentname.value == '' || val.commentname.value=='Name'){
		alert("Enter your name");
		val.commentname.focus();
		return false;
	}
	/*if(val.address.value == '' || val.address.value=='City'){
		alert("Enter your city");
		val.address.focus();
		return false;
	}*/
	if(val.email.value != '') {
		if (!emailRe.test(val.email.value)) {
		alert("Enter Valid Email");
		val.email.focus();
		return false;
		}
	}

	if(val.comment.value == ''){
		alert("Comment too short");
		val.comment.focus();
		return false;
	}
	val.submit();
	return true;
}
function writit(text,id){
for(i=1;i<=10;i++){
	tagid="rImage"+i;
	if(i % 2 == 1){
		document.getElementById(tagid).src="/images/rstar1off.jpg";
	}
	else{
		document.getElementById(tagid).src="/images/rstar2off.jpg";
	}
}
cnt=text*2;
for(i=1;i<=cnt;i++){
	tagid="rImage"+i;
	modi = i%2;
	if(modi == 0){
		document.getElementById(tagid).src="/images/rstar2on.jpg";
	}
	else{
		document.getElementById(tagid).src="/images/rstar1on.jpg";
	}
}
	disptext = text + " Star";
	if (document.getElementById)
	{
		x = document.getElementById(id);
		x.innerHTML = '';
		x.innerHTML = disptext;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML = disptext;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		text2 = '<P CLASS="ntdBL">' + disptext + '</P>';
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}

function clearrating(){
	for(i=1;i<=10;i++){
		tagid="rImage"+i;
		if(i % 2 == 1){
			document.getElementById(tagid).src="/images/rstar1off.jpg";
		}
		else{
			document.getElementById(tagid).src="/images/rstar2off.jpg";
		}
	}
	disptext = "";
	id="test"
	if (document.getElementById)
	{
		x = document.getElementById(id);
		x.innerHTML = '';
		x.innerHTML = disptext;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML = disptext;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		text2 = '<P CLASS="ntdBL">' + disptext + '</P>';
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}

function drawrating(x,y){
	prnt = "<ul>";
	for(i=1;i<=x;i++){
		prnt += "<li style=\"margin-left:5px;\"><img src=\"/images/video_star.jpg\" width=28 height=24 hspace=0 vspace=0 border=0></li>";
	}
	if(y > 0){
		prnt += "<li style=\"margin-left:5px;\"><img src=\"/images/video_halfstar.jpg\" width=28 height=24 hspace=0 vspace=0 border=0></li>";
	}
	else{
		y = 0;
	}
	prnt +=	"<li style=\"margin-left:25px;margin-top:5px;\" class=ntdBL>" + x + "." + y +" Stars</li>";
	document.getElementById("DynUsrRating").innerHTML = prnt;
	prnt += "</ul>";
}


// JavaScript Document
//common cms functions

function callAHAH(url, type, parameters, fname){ 
	try {
		req = new XMLHttpRequest(); /* e.g. Firefox */
	} catch(e) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP"); /* some versions IE */
		} catch (e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP"); /* some versions IE */ }
			catch (E) {
				req = false;
			}
		}
	}
	req.onreadystatechange = function() {
		responseAHAH(fname);
	};
	req.open(type,url,true);
    req.setRequestHeader("Content-length", parameters.length);
	req.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	if(parameters == '') parameters = null;
	req.send(parameters);
}

function responseAHAH(fname) { 
	if(req.readyState == 1 ) { //loading
		if(document.getElementById('busyimg') != null){ 
			document.getElementById('busyimg').style.display = "block";
		}
	}
	else if(req.readyState == 4) {
		if(document.getElementById('busyimg') != null)
				document.getElementById('busyimg').style.display = "none";
		if(req.status == 200) {
			 fname(req);		
			//alert(output);
		} else {
			alert("Ooops Error! Call 911");
		}
	}
}



function addBookmark(title, url) {
        if (window.sidebar) { // firefox
              window.sidebar.addPanel(title, url,"");
        } else if( document.all ) { //MSIE
                window.external.AddFavorite( url, title);
        } else {
               alert("Sorry, your browser doesn't support this");
        }
}
