<?php
$pgMod="sms";
$pgAct="view";
if(isset($_GET['action']) && trim($_GET['action'])!='')
		$pgAct=strtolower($_GET['action']);


//error_reporting("555");
//print_r($_REQUEST);print_r($_FILES);exit;
if(isset($_REQUEST["sms"]) && ($_POST["msgHindi"]!="" || $_POST["msgEnglish"]!="")){
	$status="";$send="";$fail="";
	$mob=array();$alert_err=array();$mmm="";
	if(is_array($_POST["cat"]) && count($_POST["cat"])>0){
		for($i=0;$i<(count($_POST["cat"]));$i++){
			$phoneNumber=$_POST["cat"][$i];
			if($_POST["changer"]=="hindi")
			$status.=sms($phoneNumber,$_POST["msgHindi"],$_GET["type"]."_sms");
			else
			$status.=sms($phoneNumber,$_POST["msgEnglish"],$_GET["type"]."_sms");
		}
	}
	if($status!=""){
		$_SESSION["msg"]="message send successfully";
		redirect();
	}
	?><script>
    $(document).ready(function(e) {
        $('#loaders').hide()
    });
    </script><?php
	
}


elseif(isset($_REQUEST["templatesms"]) ){
	$status="";$send="";$fail="";
	$mob=array();$alert_err=array();$mmm="";

	if(is_array($_POST["cat"]) && count($_POST["cat"])>0){
		
		
		
		for($i=0;$i<(count($_POST["cat"]));$i++){
		    

			$Number=$_POST["cat"][$i];
$str_arr = explode (",", $Number);  

 	for($k=0;$k<(count($str_arr));$k++)
 
 { 
     $pt = explode ("~", $str_arr[$k]);  

      $pt[0];
      $pt[1];
  $ch_name=$db->getRow("select name,admissionno,password from student where mobile='".$pt[0]."' and  idno='".$pt[1]."' and  session='".$_SESSION["admin"]["session"]."' ");
		    //echo 	 $ss="select name,admissionno,password from student where mobile='".$pt[0]."' and  idno='".$pt[1]."' and  session='".$_SESSION["admin"]["session"]."' ";
	 $ch_name["admissionno"];
	      //echo	$SMSdetail="Dear Parents,   Download your School App from google play store ".$ch_name['admissionno']."      ";
      	$SMSdetail="Dear Parents, Download your School App of your child(".$ch_name["name"].") from google play store ".$LinksDetails["website"]." or you can type your school name on play store \n user id-".$ch_name["admissionno"]."  \n password -".$ch_name["password"]." \n Regard  \n ".$LinksDetails["site_name"]."  ";

$_GET["type"]="class";
			$status.=sms($pt[0],$SMSdetail,$_GET["type"]."_sms");
		
 }
		}  
	}

	if($status!=""){
		$_SESSION["msg"]="message send successfully";
		//redirect();
	}
	?><?php
	
}


elseif(isset($_REQUEST["voice"])){
	
	//echo "voide ";exit;
	if(isset($_FILES["vsms"]["name"]) && !empty($_FILES["vsms"]["name"])){
		$lfilename = basename($_FILES['vsms']['name']);
		$lext = strtolower(substr($lfilename, strrpos($lfilename, '.')+1));
		if($lext=="wav" || $lext=="mp3"){
			set_time_limit(300);
			$server_path = "/mssinfotech/uploads/vcall/";
			$file_tmp_name = $_FILES["vsms"]["tmp_name"];
			
			$ftp_server = "66.96.147.115";
			$ftp_username = "mssinfotech";
			$ftp_password = "Mragank@123";
			$file_name = $_FILES["vsms"]["name"];
			
			// Create FTP stream, a connection to the FTP server
			$connection = ftp_connect($ftp_server);
			
			// Login to the server
			$ftp_conn = ftp_login($connection, $ftp_username, $ftp_password);
			
			// Login check
			if ((!$connection) || (!$ftp_conn)) {
				//echo "<p>Connection to <b>$ftp_server</b> for user<b>$ftp_username</b> FAILED</p>"; exit;
			} else {
				// Upload file to specified path
				$ftp_upload = ftp_put($connection,
				str_replace("//","/",$server_path."/".$file_name),
				$file_tmp_name, FTP_BINARY);					
				// Close FTP connection
				ftp_close($ftp_conn);
			
				$status="";$send="";$fail="";
				$mob=array();$alert_err=array();$mmm="";
				if(is_array($_POST["cat"]) && count($_POST["cat"])>0){
					for($i=0;$i<(count($_POST["cat"]));$i++){
						$phoneNumber=$_POST["cat"][$i];
						//$_POST["photo"]=$lnewfile;
						$status.=vsms("http://mssinfotech.com/uploads/vcall/".$file_name,$phoneNumber,$_GET["type"]."_sms");
					}
					$_SESSION["msg"]="voice sms send successfully";
					redirect();
				}else{
					$alert_err[]="Please select atleast one student";		
				}
			}
		}else{
			$alert_err[]="invalid file please upload only wav or mp3 file of 30sec.";
		}
	}else{
		$alert_err[]="please select any wav or mp3 file";
	}
	
	?><script>
    $(document).ready(function(e) {
        $('#loaders').hide()
    });
    </script><?php
}
if(isset($_SESSION['msg']) && $_SESSION['msg']!="")
{
	?>
    <embed src='media/sms_voice.mp3' width='180' height='90' loop='false' autostart='true' hidden='true' style="position:absolute; top:-1000px" />
	<div class="alert alert-success">
	  <a class="close" data-dismiss="alert">×</a>
	  <i class="icon icon-thumbs-up-alt"></i> <b>Notice</b><?php echo $_SESSION['msg'] ?></i>
	</div>
	<?php
	unset($_SESSION["msg"]);
}
if(is_array($alert_err) && count($alert_err)>0)
{
	?>
	<div class="alert alert-error">
	  <a class="close" data-dismiss="alert">×</a>
	  <i class="icon icon-warning-sign"></i> <b>Notice</b> <?php echo $alert_err[0] ?></i>
	</div>
	<?php
}
?><div id="loaders" style="position:fixed; z-index: 999999999; padding-top: 15%; display:none; top:0; left:0; width:100%; height:100%; opacity:0.7; background-color:#000; vertical-align:central; text-align:center">
    	<img src="assets/img/load.gif" /><br />
		<h1>Loading...</h1>
    </div>
<!-- Forms --> 
<style>.top-bar-minimize{display:none;}
thead, tfoot {display: table-header-group;}
.top-bar+.well,.accordion .accordion-heading+.accordion-body{display: inline-block !important;width: 96.7% !important;overflow: inherit !important;} 
.classList{cursor:pointer;text-decoration:none;display:block;border:1px solid #666;margin: 5px 0;padding: 5px 11px;}
.selected{background-color: #ccc;color: #fff;font-weight: bolder;box-shadow: 5px 5px 16px #000;}
.imgs{float:left;height: 60px;margin-right: 10px;}
.classList span{color:#F00; font-weight:bolder;}
.driverDetail { border: 1px solid #000;padding: 5px 10px;background-color: #ccc;box-shadow: 0 0 10px #2B2929;font-weight: bolder;font-size: 14px;margin: 10px 5px;}
.cat {	display: inline-block;	width: 87%;	border: 1px solid #ccc;	padding: 5px 10px;	box-shadow: 4px 3px 6px #ccc;	cursor: pointer;	margin-right: 6px;}
.subcat {	display: inline-block;	width: 75%;	border: 1px solid #ccc;	padding: 5px 10px;	box-shadow: 4px 3px 6px #ccc;	cursor: pointer;	margin-left: 28px;}
.selected{	box-shadow: inset 0 0 10px #ccc;}
.cat .check, .subcat .check{	float: left;	margin: 5px 5px 5px 0;}
</style>
<script type="text/javascript" src="https://www.google.com/jsapi?key=AIzaSyC-AVNcwRpILi9j9SFyjIEx69diirtCWQk"></script>
<script type="text/javascript">
function checkAll(checkboxa){
    if($('#'+checkboxa).is(':checked')) {
        $('.'+checkboxa).attr('checked', 'checked');
		$('.'+checkboxa).parent('span').addClass('checked');
    } else {
		$('.'+checkboxa).parent('span').removeClass('checked');
        $('.'+checkboxa).removeAttr('checked');
    }
}
$(document).ready(function(){
    $("#filter").keyup(function(){
 
        // Retrieve the input field text and reset the count to zero
        var filter = $(this).val(), count = 0;
 
        // Loop through the comment list
        $(".subcat").each(function(){
 
            // If the list item does not contain the text phrase fade it out
            if ($(this).text().search(new RegExp(filter, "i")) < 0) {
                $(this).fadeOut();
 
            // Show the list item if the phrase matches and increase the count by 1
            } else {
                $(this).show();
                count++;
            }
        });
 
        // Update the count
        var numberItems = count;
        //$("#filter-count").text("Number of Comments = "+count);
    });
});
google.load("elements", "1", {
	packages: "transliteration"
  });

function onLoad() {
	var options = {
		sourceLanguage:
			google.elements.transliteration.LanguageCode.ENGLISH,
		destinationLanguage:
			[google.elements.transliteration.LanguageCode.HINDI],
		shortcutKey: 'ctrl+g',
		transliterationEnabled: true
	};
	
	// Create an instance on TransliterationControl with the required
	// options.
	var control =
		new google.elements.transliteration.TransliterationControl(options);
	
	// Enable transliteration in the textbox with id
	// 'transliterateTextarea'.
	control.makeTransliteratable(['transliterateTextarea']);
}
google.setOnLoadCallback(onLoad);
function checkHindi(){
	// Load the Google Transliterate API
  	var checkID=$(".checkHindiClass").attr("id");
	if(checkID=="transliterateTextarea"){
		$(".checkHindiClass").removeAttr("id");
	}else{
		$(".checkHindiClass").attr("id","transliterateTextarea");
	}
}
</script>
<form method="post" action="" enctype="multipart/form-data">
     <div class="row-fluid">
        <div class="span12">
            <div class="top-bar">
                <h3><i class="icon-cog"></i> Send SMS to Selected <?php echo $checkbox=ucfirst($_GET["type"]); ?></h3>
            </div>
            <div class="well">
			<!-- Forms: Box -->
			<div class="span6">
				<!-- Forms: Top Bar -->
				<div class="top-bar">
                    <h3><i class="icon-cog"></i><input type="text" id="filter" style="float:right; margin-left:30px" placeholder="Search Here" /><label style="float:right; margin-left:10px;" for="<?php echo $checkbox; ?>">All  <?php echo ucfirst($_GET["type"]); ?></label>
                        <input  onchange="checkAll('<?php echo $checkbox; ?>')" class="check" type="checkbox" name="cat[]" value="1" id="<?php echo $checkbox; ?>" />
                        
					
                    </h3>
                </div>
				<!-- / Forms: Top Bar -->

				<!-- Forms: Content -->
				<div class="well no-padding" style="max-height: 848px;overflow-y: auto !important;overflow-x: hidden !important;">

						
                        
                        <div class="control-group">
                        <?php 
				if($_GET["type"]=="student"){
					$arr=explode(",",$_REQUEST['chk']);
					$class=$db->getRows("select * from student where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and issue_TC=0 and status = 1 order by name");
					if(is_array($class) && count($class)>0){$i=0;
						foreach($class as $cla){
							$id=$cla["idno"];
							 ?>
                        	<div class="subcat">
                            <?php if($arr[$i]==$cla["idno"]) { $i++;?>
                                <input class="check <?php echo $checkbox; ?>" type="checkbox" name="cat[]" value="<?php echo $cla["mobile"];?>" id="cat<?php echo $cla["idno"]; ?>"checked="checked" />
                                <label for="cat<?php echo $cla["idno"]; ?>"><?php echo $cla["name"] ?>(<?php echo $cla["class"] ?>)</label>
                                <?php } else { ?>
                                <input class="check <?php echo $checkbox; ?>" type="checkbox" name="cat[]" value="<?php echo $cla["mobile"];?>" id="cat<?php echo $cla["idno"]; ?>" />								 <label for="cat<?php echo $cla["idno"]; ?>"><?php echo $cla["name"] ?>(<?php echo $cla["class"] ?>)</label>
								 <?php } ?>

                            </div>
                          <?php }		
					}	
				}elseif($_GET["type"]=="faculty"){
					$class=$db->getRows("select * from staff  where school_id='".$_SESSION["admin"]["school_id"]."' and status=1 order by name ");
					if(is_array($class) && count($class)>0){
						foreach($class as $cla){ ?>
                        	<div class="subcat">
                            
                                <input class="check <?php echo $checkbox; ?>" type="checkbox" name="cat[]" value="<?php echo $cla["mobile"];?>" id="cat<?php echo $cla["idno"]; ?>" />
                                <label for="cat<?php echo $cla["idno"]; ?>"><?php echo $cla["name"] ?></label>
                            </div>
                          <?php }		
					}
				}elseif($_GET["type"]=="class"){
					$class=$db->getRows("select * from class where school_id='".$_SESSION["admin"]["school_id"]."' and status=1");
					if(is_array($class) && count($class)>0){
						foreach($class as $cla){ $number=array();
							$mobile=$db->getRows("select idno,mobile from student where school_id='".$_SESSION["admin"]["school_id"]."' and class='".$cla["class"]."' and  session='".$_SESSION["admin"]["session"]."' and status = 1");
							if(is_array($mobile) && count($mobile)>0){
								foreach($mobile as $mob){
									$number[]=$mob["mobile"]."~".$mob["idno"];
								
								

								}
							}
						?>
                        	<div class="subcat">

                                <input class="check <?php echo $checkbox; ?>" type="checkbox" name="cat[]" value="<?php echo implode(",",$number);?>" id="cat<?php echo $cla["id"]; ?>" />
                                <label for="cat<?php echo $cla["id"]; ?>"><?php echo $cla["class"] ?></label>
                            </div>
                          <?php }		
					}
				}
			
			
			elseif($_GET["type"]=="app_data"){
					$class=$db->getRows("select * from class where school_id='".$_SESSION["admin"]["school_id"]."' and status=1");
					if(is_array($class) && count($class)>0){
						foreach($class as $cla){ $number=array();
							$mobile=$db->getRows("select idno,mobile from student where school_id='".$_SESSION["admin"]["school_id"]."' and class='".$cla["class"]."' and  session='".$_SESSION["admin"]["session"]."' and status = 1");
							if(is_array($mobile) && count($mobile)>0){
								foreach($mobile as $mob){
									$number[]=$mob["mobile"]."~".$mob["idno"];
								
								

								}
							}
						?>
                        	<div class="subcat">

                                <input class="check <?php echo $checkbox; ?>" type="checkbox" name="cat[]" value="<?php echo implode(",",$number);?>" id="cat<?php echo $cla["id"]; ?>" />
                                <label for="cat<?php echo $cla["id"]; ?>"><?php echo $cla["class"] ?></label>
                            </div>
                          <?php }		
					}
				}	
				
				elseif($_GET["type"]=="department"){
					$class=$db->getRows("select * from department where school_id='".$_SESSION["admin"]["school_id"]."' and status=1");
					if(is_array($class) && count($class)>0){
						foreach($class as $cla){ $number=array();
							$mobile=$db->getRows("select mobile from staff where school_id='".$_SESSION["admin"]["school_id"]."' and class='".$cla["class"]."' and  session='".$_SESSION["admin"]["session"]."'");
							if(is_array($mobile) && count($mobile)>0){
								foreach($mobile as $mob){
									$number[]=$mob["mobile"];
								}
							}?>
                        	<div class="subcat">
                                <input class="check <?php echo $checkbox; ?>" type="checkbox" name="cat[]" value="<?php echo implode(",",$number);?>" id="cat<?php echo $cla["id"]; ?>" />
                                <label for="cat<?php echo $cla["id"]; ?>"><?php echo $cla["name"] ?></label>
                            </div>
                          <?php }		
					}
				}
				elseif($_GET["type"]=="transport"){
						$class=$db->getRows("select * from student where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and bus!='' and issue_TC=0 and status = 1 order by name");
					if(is_array($class) && count($class)>0){$i=0;
						foreach($class as $cla){
							$id=$cla["idno"];
							 ?>
                        	<div class="subcat">
                            
                                <input class="check <?php echo $checkbox; ?>" type="checkbox" name="cat[]" value="<?php echo $cla["mobile"];?>" id="cat<?php echo $cla["idno"]; ?>" />								 <label for="cat<?php echo $cla["idno"]; ?>"><?php echo $cla["name"] ?>(<?php echo $cla["class"] ?>)</label>
							</div>
                          <?php		
					}	}
				}
				elseif($_GET["type"]=="bus"){
					$bus=$db->getRows("select * from bus where school_id='".$_SESSION["admin"]["school_id"]."' and status=1");
					if(is_array($bus) && count($bus)>0){
						foreach($bus as $b){ $number=array();
							$mobile=$db->getRows("select mobile from student where school_id='".$_SESSION["admin"]["school_id"]."' and bus='".$b["id"]."' and  session='".$_SESSION["admin"]["session"]."' and status = 1");
							if(is_array($mobile) && count($mobile)>0){
								foreach($mobile as $mob){
									$number[]=$mob["mobile"];
								}
							}
						?>
                        	<div class="subcat">
                                <input class="check <?php echo $checkbox; ?>" type="checkbox" name="cat[]" value="<?php echo implode(",",$number);?>" id="cat<?php echo $cla["id"]; ?>" />
                                <label for="cat<?php echo $b["id"]; ?>"><?php echo $b["root"] ?></label>
                            </div>
                          <?php }		
					}
				}elseif($_GET["type"]=="all"){
					?><hr>Student<hr><?php
					$class=$db->getRows("select * from student where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and issue_TC=0 order by name");
					if(is_array($class) && count($class)>0){
						foreach($class as $cla){ ?>
                        	<div class="subcat">
                                <input class="check <?php echo $checkbox; ?>" type="checkbox" name="cat[]" value="<?php echo $cla["mobile"];?>" id="cat<?php echo $cla["idno"]; ?>" />
                                <label for="cat<?php echo $cla["idno"]; ?>"><?php echo $cla["name"] ?>(<?php echo $class["class"] ?>)</label>
                            </div>
                          <?php }		
					}
					?><hr>Faculty<hr><?php
					$class=$db->getRows("select * from staff where school_id='".$_SESSION["admin"]["school_id"]."' and status=1");
					if(is_array($class) && count($class)>0){
						foreach($class as $cla){ $number=array();
							$mobile=$db->getRows("select mobile from staff where idno='".$cla["idno"]."' and school_id='".$_SESSION["admin"]["school_id"]."' ");
							if(is_array($mobile) && count($mobile)>0){
								foreach($mobile as $mob){
									$number[]=$mob["mobile"];
								}
							}  ?>
                        	<div class="subcat">
                                <input class="check <?php echo $checkbox; ?>" type="checkbox" name="cat[]" value="<?php echo implode(",",$number);?>" id="cat<?php echo $cla["idno"]; ?>" />
                                <label for="cat<?php echo $cla["idno"]; ?>"><?php echo $cla["name"] ?></label>
                            </div>
                          <?php }		
					}
				}
				elseif($_GET["type"]=="enquiry"){
					$arr=explode(",",$_REQUEST['chk']);
					$class=$db->getRows("select * from enquiry where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and status = 1 order by name");
					if(is_array($class) && count($class)>0){$i=0;
						foreach($class as $cla){
							$id=$cla["idno"];
							 ?>
                        	<div class="subcat">
                            <?php if($arr[$i]==$cla["idno"]) { $i++;?>
                                <input class="check <?php echo $checkbox; ?>" type="checkbox" name="cat[]" value="<?php echo $cla["mobile"];?>" id="cat<?php echo $cla["idno"]; ?>"checked="checked" />
                                <label for="cat<?php echo $cla["idno"]; ?>"><?php echo $cla["name"] ?>(<?php echo $cla["class"] ?>)</label>
                                <?php } else { ?>
                                <input class="check <?php echo $checkbox; ?>" type="checkbox" name="cat[]" value="<?php echo $cla["mobile"];?>" id="cat<?php echo $cla["idno"]; ?>" />								 <label for="cat<?php echo $cla["idno"]; ?>"><?php echo $cla["name"] ?>(<?php echo $cla["class"] ?>)</label>
								 <?php } ?>

                            </div>
                          <?php }		
					}	
				}
				elseif($_GET["type"]=="enquiry_class"){
					$class=$db->getRows("select * from class where school_id='".$_SESSION["admin"]["school_id"]."' and status=1");
					if(is_array($class) && count($class)>0){
						foreach($class as $cla){ $number=array();
							$mobile=$db->getRows("select mobile from enquiry where school_id='".$_SESSION["admin"]["school_id"]."' and class='".$cla["class"]."' and  session='".$_SESSION["admin"]["session"]."' and status = 1");
							if(is_array($mobile) && count($mobile)>0){
								foreach($mobile as $mob){
									$number[]=$mob["mobile"];
								}
							}
						?>
                        	<div class="subcat">
                                <input class="check <?php echo $checkbox; ?>" type="checkbox" name="cat[]" value="<?php echo implode(",",$number);?>" id="cat<?php echo $cla["id"]; ?>" />
                                <label for="cat<?php echo $cla["id"]; ?>"><?php echo $cla["class"] ?></label>
                            </div>
                          <?php }		
					}
				}?>
						</div>
                          
                        
						
				</div>
				<!-- / Forms: Content -->

			</div>
			<!-- / Forms: Box -->
			<!-- Forms: Box -->
			<div class="span6">

				<!-- Forms: Top Bar -->
				<div class="top-bar">
                    <h3>Enter SMS  <a href="javascript:;" onclick="changelang()" id="switcher">Click Here To Start Typing in English</a>
                            
                    </h3>
                </div>
				<!-- / Forms: Top Bar -->
          
				<!-- Forms: Content -->
				<div class="well no-padding">

					<!-- Forms: Form -->
                    <!-- Forms: Form Textarea -->
						<div class="control-group">
							<label class="control-label" for="inputInline"><i class="icon-edit"></i> SMS Contentd 
                           <input type="hidden"  name="changer" id="changer" value="hindi" />
                            </label>
							<div class="controls" id="hindi">
								<textarea maxlength="70" name="msgHindi" rows="3" class="span12 checkHindiClass" id="transliterateTextarea"></textarea>
                            <p id="hindiLeft"></p>
							</div>
                            <div class="controls" id="english" style="display:none">
							<textarea name="msgEnglish" id="englishtext" maxlength="160" rows="3" class="span12"></textarea>
                            <p id="englishLeft"></p>
							</div>
						</div>
						<!-- / Forms: Form Textarea -->

	 
						<!-- Forms: Form Actions -->
						<div class="form-actions">
							<button type="submit" name="sms" value="sms" onclick="$('#loaders').show()" class="btn btn-primary"> Send</button>
							<button type="reset" class="btn"> Cancel</button>
						</div>

                    <!-- Forms: Form Actions -->
						
						<!-- / Forms: Form Actions -->
	 
					<!-- / Forms: Form -->           

				</div>
				<!-- / Forms: Content -->
		  </div>
          <div class="span6">
          		<div class="top-bar">
                    <h3>Send Voice Call</h3>
                </div>
          		<div class="well no-padding">

					<!-- Forms: Form -->
                    <!-- Forms: Form Textarea -->
						<div class="control-group">
							<label class="control-label" for="inputInline"><i class="icon-edit"></i> File(.wav,mp3) </label>
							<div class="controls">
								<input type="file" name="vsms" />
							</div>
                            
						</div>
						<!-- / Forms: Form Textarea -->

	 
						<!-- Forms: Form Actions -->
						<div class="form-actions">
							<button type="submit" name="voice" onclick="$('#loaders').show()" value="sms" class="btn btn-primary"> Send</button>
							

							<button type="reset" class="btn"> Cancel</button>
						<button type="submit" name="templatesms" onclick="$('#loaders').show()" value="templatesms" class="btn btn-primary"> Send App Template</button>

						</div>

                    <!-- Forms: Form Actions -->
						
						<!-- / Forms: Form Actions -->
	 
					<!-- / Forms: Form -->           

				</div>
			</div>
			<!-- / Forms: Box -->
            </div>
        </div>
        
	</div>
</form>
<!-- / Forms -->
<script>
$(document).ready(function(){
    $('textarea[maxlength]').keyup(function(){
        var max = parseInt($(this).attr('maxlength'));
        if($(this).val().length > max){
            $(this).val($(this).val().substr(0, $(this).attr('maxlength')));
        }
        $(this).parent().find('.charsRemaining').html('You have ' + (max - $(this).val().length) + ' characters remaining');
    });
});


function changelang(){
	var ctype=$("#changer").val();
	if(ctype=="english"){
		$("#changer").val('hindi');
		$("#switcher").html('Click Here To Start Typing in English');
		$("#hindi").show();
		$("#english").hide();
	}else{
		$("#changer").val('english');
		$("#switcher").html('Click Here To Start Typing in Hindi');
		$("#hindi").hide();
		$("#english").show();
	}
}
$('#englishLeft').text('160 characters left');
$('#englishtext').keyup(function () {
	var max = 160;
	var len = $(this).val().length;
	if (len >= max) {
		$('#englishLeft').text(' you have reached the limit');
	} else {
		var ch = max - len;
		$('#englishLeft').text(ch + ' characters left');
	}
});
$('#hindiLeft').text('70 characters left');
$('#transliterateTextarea').keyup(function(){
	var max = 70;
	var len = $(this).val().length;
	if (len >= max) {
		$('#hindiLeft').text(' you have reached the limit');
	} else {
		var ch = max - len;
		$('#hindiLeft').text(ch + ' characters left');
	}
});
</script>