//  Site Login

//  Developed by Roshan Bhattarai 
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use

/*$(document).ready(function()
{
	$("#login_form").submit(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
		//check the username exists or not from ajax
		$.post("ajax_login.php",{ user_name:$('#username').val(),password:$('#password').val(),rand:Math.random() } ,function(data)
        {
		  if(data=='yes') //if correct login detail
		  {
		  	$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Logging in.....').addClass('messageboxok').fadeTo(900,1,
              function()
			  { 
			  	 //redirect to secure page
				 document.location='secure.php';
			  });
			  
			});
		  }
		  else 
		  {
		  	$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Your login are incorrect...').addClass('messageboxerror').fadeTo(900,1);
			});		
          }
				
        });
 		return false; //not to post the  form physically
	});
	//now call the ajax also focus move from 
	$("#password").blur(function()
	{
		$("#login_form").trigger('submit');
	});
});
*/


/////////////////////////////////////////////////////////////////////////////////////////////////////////


function setTabOver(id){
	//var themod = "<?php echo $theModType; ?>";
	document.getElementById(id).style.backgroundColor = "#A7A189";
	document.getElementById(id).style.color = "#EFEFEF";
}
function setTabOut(id){
	//var themod = "<?php echo $theModType; ?>";
	document.getElementById(id).style.backgroundColor = "#8CC041";
	document.getElementById(id).style.color = "#FFFFFF";
}




/////////////////////////////////////////////////////////////////////////////////////////////////////////


function replaceSymbols(str){
	var try_a = str.replace(/&amp;/gi, "&");
	var try_a = try_a.replace(/&pound;/gi, unescape('%A3'));
	var try_a = try_a.replace(/&amp;/gi, unescape('%26'));
	var try_a = try_a.replace(/&quot;/gi, unescape('%22'));
	
	var try_a = try_a.replace(/&lt;/gi, unescape('%3C'));
	var try_a = try_a.replace(/&gt;/gi, unescape('%3E'));
	/*
	var try_a = try_a.replace(/&quot;/gi, unescape('%22'));
	var try_a = try_a.replace(/&quot;/gi, unescape('%22'));
	var try_a = try_a.replace(/&quot;/gi, unescape('%22'));
	var try_a = try_a.replace(/&quot;/gi, unescape('%22'));
	var try_a = try_a.replace(/&quot;/gi, unescape('%22'));
	var try_a = try_a.replace(/&quot;/gi, unescape('%22'));
	var try_a = try_a.replace(/&quot;/gi, unescape('%22'));
	*/
	
	
	
	
	
	
	return try_a;
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////


function toScreenDate(string){
	if(string == "0000-00-00 00:00:00"){
		var theOutput = "";
	} else {
		var myString =  string.substring(0,10);
		var myArray = myString.split('-'); 
		var theOutput = myArray[2] + "/" + myArray[1] + "/" + myArray[0];
	}
	return theOutput;
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////

function configElement(type, form, id, val){
	
	
	if(type == "combo"){
		document.getElementById(id).value = val;
	}
	
	if(type == "checkbox"){
		if(val == 1) {
			eval("document." + form + "." + id + ".checked = true;");
		} else {
			eval("document." + form + "." + id + ".checked = false;");
		}
	}
}




/////////////////////////////////////////////////////////////////////////////////////////////////////////


function checkElements(){
	var theList = document.body.getElementsByTagName("form");
	var output = "";
	var drop = "\n";
	for (var j = 0; j < theList.length; j++) {
		var b = theList[j];
		var thId = b.getAttribute("id");
		eval("for(i=0; i<document." + thId + ".elements.length; i++){output += document." + thId + ".elements[i].id;}");
	}
	alert(output);
}



//		var the_calFlag = "";
//		for( j = 0; j < document.newActivityForm.act_comp.length; j++){
//			if( document.newActivityForm.act_addCal[j].checked == true){
//				var the_jar = document.newActivityForm.act_addCal[j].value;
//				if(the_jar == "yes"){
//					the_calFlag = "1";
//				} else if (the_jar == "no"){
//					the_calFlag = "0";
//				}
//			}
//		}


