﻿
    if(document.location.host=="infoindya.com")
    {
document.location="http://www."+document.location.host+document.location.pathname;
//alert("http://"+document.location.host+document.location.pathname);
    }


function maxlen(multi_txt, len) {
	//alert(multi_txt.value.length);
	if (multi_txt.value.length >= len)
	{ return false; }
	return true;
}



//To validate the user to enter into the textbox. i.e., Required field validator.


function req_validates(txt_id, div_id, err_msg) {
	var txt = txt_id.value;

	for (var i = txt.length - 1; i >= 0; i--) {
		if (txt.charAt(i) == " ") {
			txt = txt.replace(" ", "");
		}
		else {
			i = -1;
		}
	}
	if (txt == "") {
		div_id.innerHTML = err_msg;
		div_id.style.display = "block";
		//txt_id.className="errtr";
		//tr_id.className="errtr";
		return false;
	}
	else {
		div_id.innerHTML = "";
		div_id.style.display = "none";
		// txt_id.className="clrtr";
		//tr_id.className="clrtr";
		return true;
	}
}

function ddlreq_validates(ddl, div_id, err_msg) {
var listbo=document.getElementById('<%=lbDate.ClientID%>');
	if (ddl.selectedIndex == 0) {
		div_id.innerHTML = err_msg;
		//div_id.className = "errText";
		div_id.style.display = "block";
		return false;
	}
	else {
		div_id.innerHTML = "";
		div_id.style.display = "none";
		return true;
	}

}


function reg_validates(txt_id, div_id, err_msg, reg_expression) {
	var txt = txt_id.value;

	for (var i = txt.length - 1; i >= 0; i--) {
		if (txt.charAt(i) == " ") {
			txt = txt.replace(" ", "");
		}
		else {
			i = -1;
		}
	}

	if (txt.match(reg_expression)) {
		div_id.innerHTML = "";
		div_id.style.display = "none";
		return true;
	}
	else {
		div_id.innerHTML = err_msg;
		//div_id.className = "errText";
		div_id.style.display = "block";
		return false;
	}
}
function rblreq_validates(rbl, div_id, err_msg) {
	var bReturn = false;
	for (var i = 0; i < rbl.length; i++) {
		//alert("ghkdhsjkhfsdf");
		if (rbl[i].checked == true) {

			bReturn = true;
		}

	}
	if (bReturn == false) {
		div_id.innerHTML = err_msg;
		div_id.className = "errText";
		div_id.style.display = "block";
	}
	return bReturn;


}

function fun_date() {
	if (event.keyCode != 0) {
		return false;
	}
}
 function Clickheretoprint()
		{ 
				var disp_setting="toolbar=no,location=no,directories=no,menubar=yes,"; 
					disp_setting+="scrollbars=yes,width=750, height=600, left=100, top=25"; 
					
				var content_vlue = document.getElementById("divMainContent").innerHTML; 
				var docprint=window.open("","",disp_setting); 
					docprint.document.open(); 
					docprint.document.write('<html><head><title>InfoIndya</title><link href="../App_Themes/cmsstyless.css" rel="stylesheet" type="text/css" /><style>.print{visibility:hidden;}</style>'); 
					docprint.document.write('</head><body ><center>');
					docprint.document.write("<div style='height: 20px; padding: 0; background: #FBFBFB; border: 1px solid #EEE;text-align:right;font-family:Verdana;font-size: 11px;vertical-align:middle;' id='print'><a href='javascript:void(0);' onclick=document.getElementById('print').style.display='none';window.print();document.getElementById('print').style.display='block'>Click here to print</a></div>");  
					docprint.document.write(content_vlue);          
					docprint.document.write('</center>'); 
					docprint.document.write('</body></html>'); 
					docprint.document.close(); 
					docprint.focus(); 
		}
		 function Clickheretoprint1(id)
		{
				var disp_setting="toolbar=no,location=no,directories=no,menubar=yes,"; 
					disp_setting+="scrollbars=yes,width=750, height=600, left=100, top=25"; 
					var val="div"+id;
				var content_vlue = document.getElementById(val).innerHTML; 
				var docprint=window.open("","",disp_setting); 
					docprint.document.open(); 
					docprint.document.write('<html><head><title>InfoIndya</title><link href="../App_Themes/cmsstyless.css" rel="stylesheet" type="text/css" /><style>.print{visibility:hidden;}</style>'); 
					docprint.document.write('</head><body ><center>');
					docprint.document.write("<div style='height: 20px; padding: 0; background: #FBFBFB; border: 1px solid #EEE;text-align:right;font-family:Verdana;font-size: 11px;vertical-align:middle;' id='print'><a href='javascript:void(0);' onclick=document.getElementById('print').style.display='none';window.print();document.getElementById('print').style.display='block'>Click here to print</a></div>");  
					docprint.document.write(content_vlue);          
					docprint.document.write('</center>'); 
					docprint.document.write('</body></html>'); 
					docprint.document.close(); 
					docprint.focus(); 
		}
		function open_mailtofriend(id,mainfolder,pagename)
		{
		
		  window.open("../mailtofriend.aspx?Q="+id+","+mainfolder+","+pagename,"mailtofriend","toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,width=700, height=350, left=100, top=50");
		}
		function searchvalidation(catdrop)
{
//var catdrop=document.getElementById("<%=DropDownList1.ClientID%>")
// else
//            {
//                if(document.getElementById('<%=ddlChannel.ClientID%>').selectedValue=="0")
//                {
//                    if (!req_validates(document.getElementById('<%=txtChannel.ClientID%>'), document.getElementById('divyxychannel'), "Please enter channel name"))
//                    { flag = 1; }
//                }
//            }
if(catdrop.selectedIndex==0)
{
alert("Please select category")
return false;
}
}



// client side javascript
// if data is not available in value it returns --NA--
    function showValidText(id)
    {
        if(id == "")
        {
            document.write("--NA--");
        }
        else
        {
            document.write(id);
        }
        
    }
// if website is --NA-- to manage open window
    function showWeb(id)
    {
        if(id != "")
        {
        
            window.open("http://"+id.replace("http://",""));
        }
    }
// if mailid is --NA-- to manage mailto:
    function showMailto(obj,id)
    {
        if(id != "")
        {
            obj.href="mailto:"+id
        }
    }
    function validateImage(fileupload,divid,err_msg)
    {
        if (fileupload.value != "")
        {
            if((fileupload.value.lastIndexOf(".jpg") == -1) && (fileupload.value.lastIndexOf(".png") == -1) && (fileupload.value.lastIndexOf(".gif") == -1) && (fileupload.value.lastIndexOf(".bmp") == -1) && (fileupload.value.lastIndexOf(".jpeg") == -1) && (fileupload.value.lastIndexOf(".JPG") == -1) && (fileupload.value.lastIndexOf(".PNG") == -1) && (fileupload.value.lastIndexOf(".GIF") == -1) && (fileupload.value.lastIndexOf(".BMP") == -1) && (fileupload.value.lastIndexOf(".JPEG") == -1))
            {
              divid.innerHTML = err_msg;
		        divid.style.display = "block";
		        return false;
            }
            else
            {
                divid.innerHTML = "";
		        divid.style.display = "none";
		        return true;
            }
        }
        else {
        divid.innerHTML = "";
        divid.style.display = "none";
        return true;
        }
    }
    function validateFlashImage(fileupload,divid,err_msg)
    {
        if (fileupload.value != "")
        {
            if((fileupload.value.lastIndexOf(".jpg") == -1) && (fileupload.value.lastIndexOf(".png") == -1) && (fileupload.value.lastIndexOf(".gif") == -1) && (fileupload.value.lastIndexOf(".bmp") == -1) && (fileupload.value.lastIndexOf(".jpeg") == -1) && (fileupload.value.lastIndexOf(".swf") == -1) && (fileupload.value.lastIndexOf(".JPG") == -1) && (fileupload.value.lastIndexOf(".PNG") == -1) && (fileupload.value.lastIndexOf(".GIF") == -1) && (fileupload.value.lastIndexOf(".BMP") == -1) && (fileupload.value.lastIndexOf(".JPEG") == -1) && (fileupload.value.lastIndexOf("SWF") == -1))
            {
              divid.innerHTML = err_msg;
		        divid.style.display = "block";
		        return false;
            }
            else
            {
                divid.innerHTML = "";
		        divid.style.display = "none";
		        return true;
            }
        }
        else {
        divid.innerHTML = "";
        divid.style.display = "none";
        return true;
        }
    }
     function validateFlash(fileupload,divid,err_msg)
    {
        if (fileupload.value != "")
        {
            if((fileupload.value.lastIndexOf(".swf") == -1) && (fileupload.value.lastIndexOf(".SWF") == -1))
            {
              divid.innerHTML = err_msg;
		        divid.style.display = "block";
		        return false;
            }
            else
            {
                divid.innerHTML = "";
		        divid.style.display = "none";
		        return true;
            }
        }
        else {
        divid.innerHTML = "";
        divid.style.display = "none";
        return true;
        }
    }
