/* -------------------------------------------------------------------------------------------------------------------------*/
function numbersonly(evnt) 
{
	var unicode=evnt.charCode? evnt.charCode : evnt.keyCode
	
	if (unicode<=46 || unicode>57 || unicode==47 || unicode==32)
	{ 
		if(unicode == 43 || unicode == 32 || unicode == 8  || unicode == 9)
			return true;	
		else
		{
			return false;
		}
	}
}

/*This function have not allow space and  allow dot(.)*/
function numbersdot(evnt)
{
	var unicode=evnt.charCode? evnt.charCode : evnt.keyCode
	if (unicode<=46 || unicode>57 || unicode==47 || unicode==32)
	{
		if(( unicode == 32 || unicode == 8 || unicode == 9 || unicode == 45 || unicode == 46) && (unicode!=32) && (unicode!=116)  && (unicode!=45) && (unicode!=43))
			return true;
		else
			return false;
	}
}

function capitalalphacharacteronly(evnt)
{
	var unicode=evnt.charCode? evnt.charCode : evnt.keyCode
	
	if((unicode>=65 && unicode<=90) || unicode == 8 || unicode == 46) 
	{
		return true;
	} 
	else 
	{
		return false;
	}
}

function alphacharacteronly(evnt)
{
	var unicode=evnt.charCode? evnt.charCode : evnt.keyCode
	
	if((unicode>=65 && unicode<=90) ||(unicode>=97 && unicode<=122) || unicode == 8 || unicode == 9 || unicode == 46) 
	{
		return true;
	} 
	else 
	{
		return false;
	}
}

function alphanumericonly(evnt)
{
	var unicode=evnt.charCode? evnt.charCode : evnt.keyCode
	
	if((unicode>=65 && unicode<=90) ||(unicode>=97 && unicode<=122) || (unicode>=48 && unicode<=57) || unicode==8 || unicode==46) 
	{
		return true;
	} 
	else 
	{
		return false;
	}
}

function mobval(evnt)
{
	var unicode=evnt.charCode? evnt.charCode : evnt.keyCode
	if (unicode<47||unicode>57 || unicode==47)
	{
		if(unicode == 8 || unicode == 116 || unicode == 9)
			return true;
		else
			return false;
	}
}

function telnoNumb(evnt,obj,obj2,numb)
{
	var unicode=evnt.charCode? evnt.charCode : evnt.keyCode

	if (unicode<47||unicode>57 || unicode==47)
	{
		if(unicode == 8 || unicode == 116 || unicode == 9)
		{
			return true;
		}
		else
			return false;
	}
	else 
	{
		if(document.getElementById(obj).value.length>=numb)
		{
			document.getElementById(obj2).focus();
		}
	}
}

function checkValidNumber()
{
	val = event.keyCode;
	if(val<48)
	{
	  event.keyCode=0;
	
	}
	if(val>57)
	{
	  event.keyCode=0;
	
	}
	return true;
}
/* -------------------------------------------------------------------------------------------------------------------------*/

function Toggle_Div(toggleId) 
{
	var theToggle = document.getElementById(toggleId);
	if (theToggle) 
	{
		if (theToggle.style.display == 'none') 
		{
			Show_Div(toggleId);
		} 
		else 
		{
			Hide(toggleId);
		}
	}
}
function Toggle(toggleId) 
{
	var theToggle = document.getElementById(toggleId);
	if (theToggle) 
	{
		if (theToggle.style.display == 'none') 
		{
			Show(toggleId);
		} 
		else 
		{
			Hide(toggleId);
		}
	}
}
function Show_Div(tagId)
{
	var theTag = document.getElementById(tagId);
	if (theTag) 
	{
		if (theTag.style.display == 'none') 
		{
			theTag.style.display = 'block';
		}
	}
}
function Show(tagId)
{
	var theTag = document.getElementById(tagId);
	if (theTag) 
	{
		if (theTag.style.display == 'none') 
		{
			theTag.style.display = '';
		}
	}
}		
function Hide(tagId) 
{
	var theTag = document.getElementById(tagId);
	if (theTag) 
	{
		if (theTag.style.display != 'none') 
		{
			theTag.style.display = 'none';
		}
	}
}

/* -------------------------------------------------------------------------------------------------------------------------*/	

function MM_openBrWindow(theURL,winName,features) 
{
	var win;
	win=window.open(theURL,winName,features);
	win.focus();
}

function windowopen(url,hig,wid,rez,scrl)
{
	var win;
	win = window.open(url,""," height="+hig+", width="+wid+", resizable="+rez+", menubar=0, toolbar=0, location=0, directories=0, scrollbars="+scrl+", status=0");
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
	if(!popUpWin.closed) popUpWin.close();
  }
  
  width =width+20;
  height=height+30;
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}	

function PopupCenter(pageURL, title,w,h) 
{
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var targetWin = window.open (pageURL, title, 'width='+w+', height='+h+', top='+top+', left='+left);
} 
/* -------------------------------------------------------------------------------------------------------------------------*/	

function trim(str)
{
    str = str.replace(/^\s+|\s+$/g, '');
	if(str == '')
		return 0;
	else
		return str;
}

function makeUppercase(str,strId) {
	var new_str = str.toUpperCase();
	document.getElementById(strId).value=new_str;
}

function copyContentWindow(theURL,title,height,width,left,top) 
{ //v2.0
   var newwindow2;
   newwindow2=window.open(theURL,title,'menubar=no, toolbar=no, resize=yes, addressbar=no, scrollbars=yes, height='+height+', width='+width+', left='+left+', top='+top+', screenX='+left+', screenY='+top+'');
   var tmp = newwindow2.document;
   
   tmp.write('<html><head><title>'+title+'</title>');
   tmp.write('</head>');
   tmp.write('<body>');
   tmp.write('<img src="'+theURL+'"');
   tmp.write('</body>');
   
   return false;  
}

function window_location(file)
{
	window.location=file;
}	
  
/* -------------------------------------------------------------------------------------------------------------------------*/	

function checkEmail(email) 
{
	if (window.RegExp)
	{
		var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
		var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,6}|[0-9]{1,3})(\\]?)$";
		var reg1 = new RegExp(reg1str);
		var reg2 = new RegExp(reg2str);
		if (!reg1.test(email) && reg2.test(email)) 
		{
			return true;
		}
		return false;
	} 
	else 
	{
		if(email.indexOf("@") >= 0)
			return true;
		return false;
	}
}

function echeck(obj) 
{
	var str=obj.value;
	var strid=obj.id;
	
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	
	if (str.indexOf(at)==-1)
	{
	   alert("Invalid E-mail ID");
	   obj.value="";
	   return false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
	   alert("Invalid E-mail ID");
	   obj.value="";
	   return false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		alert("Invalid E-mail ID");
		obj.value="";
		return false;
	}
	if (str.indexOf(at,(lat+1))!=-1)
	{
		alert("Invalid E-mail ID");
		obj.value="";
		return false;
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		alert("Invalid E-mail ID");
		obj.value="";
		return false;
	}

	if (str.indexOf(dot,(lat+2))==-1)
	{
		alert("Invalid E-mail ID");
		obj.value="";
		return false;
	}
	
	if (str.indexOf(" ")!=-1)
	{
		alert("Invalid E-mail ID");
		obj.value="";
		return false;
	}

	return true;				
}

/* -------------------------------------------------------------------------------------------------------------------------*/
	
function checkMe(radio,obj)
{
	if(radio.checked==1)
	{
		obj.disabled = false;
	}
	else if(radio.checked==0)
	{
		obj.disabled = true;
		obj.focus();
	}
} 

function CheckAllCheckbox(obj,formname)
{					
	var len = document.forms[formname].elements.length;
	var obj_len = obj.name.length;
	
	for(i=0;i<len;i++) 
	{
		obj12 = document.forms[formname].elements[i].id;
		
		if((obj12.substring(0,obj_len) == obj.name) && (document.forms[formname].elements[i].type = "checkbox")) 
		{
			document.forms[formname].elements[i].checked = obj.checked;
		}
	}
}
/* -------------------------------------------------------------------------------------------------------------------------*/
	
function displayDateTime(timeId)
{
	var months=new Array(13);
	months[1]="January";
	months[2]="February";
	months[3]="March";
	months[4]="April";
	months[5]="May";
	months[6]="June";
	months[7]="July";
	months[8]="August";
	months[9]="September";
	months[10]="October";
	months[11]="November";
	months[12]="December";
	
	var time=new Date();
	var lmonth=months[time.getMonth() + 1];
	var date=time.getDate();
	var year=time.getYear();
	if (year < 2000) 
	year = year + 1900; 
	
	//--- Get Time
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds()
	var timeValue = "" + ((hours >12) ? hours -12 :hours)
	if (timeValue == "0") timeValue = 12;
	timeValue += ((minutes < 10) ? ":0" : ":") + minutes
	//timeValue +=((seconds < 10) ? "0" : ":") + seconds
	timeValue += (hours >= 12) ? " PM" : " AM"
	
	//--- Get Day
	var days=new Array(7);
	days[0]="Sunday";
	days[1]="Monday";
	days[2]="Tuesday";
	days[3]="Wednesday";
	days[4]="Thursday";
	days[5]="Friday";
	days[6]="Saturday";
	var lday=days[time.getDay()];	
	
	var clocktime = lday + ", "  +lmonth + " " + date + ", " + year + " " + timeValue;
	
	if(document.getElementById(timeId)!=null)
	{
		document.getElementById(timeId).innerHTML = clocktime;
		setTimeout("displayDateTime()",1000);
	}
}	
	
function displayTime(timeId)
{
	var time = new Date();
	var hours = time.getHours();
	var timeOfDay = ( hours < 12 ) ? "AM" : "PM";
	var minutes = time.getMinutes();
	minutes=((minutes < 10) ? "0" : "") + minutes;
	var seconds = time.getSeconds();
	seconds=((seconds < 10) ? "0" : "") + seconds;
	var clocktime = hours + ":" + minutes + ":" + seconds + " " + timeOfDay;
	
	document.getElementById(timeId).innerHTML = clocktime;
	setTimeout("displayTime()",1000);
}	

/* -------------------------------------------------------------------------------------------------------------------------*/
	
function delConfirm()
{
	ret=confirm('Are you sure you want to delete?');

	if(ret==false)
	{
		return false;
	}
	else 
	{
		return true;
	}
}	
	
function cancelConfirm()
{
	ret=confirm('Are you sure you want to Cancel?');

	if(ret==false)
	{
		return false;
	}
	else 
	{
		return true;
	}
}	

/* -------------------------------------------------------------------------------------------------------------------------*/	
	
function calendar_setup(inputid,buttonid,dateformat)
{
	Calendar.setup({
		inputField     :    inputid,      // id of the input field
		button         :    buttonid,   // trigger for the calendar (button ID)
		ifFormat       :    dateformat,       // format of the input field
		showsTime      :    false,            // will display a time selector
		singleClick    :    false,           // double-click mode
		step           :    1                // show all years in drop-down boxes (instead of every other year as default)
		
			 // show all years in drop-down boxes (instead of every other year as default)
	});
}
	
/* -------------------------------------------------------------------------------------------------------------------------*/		
function php_serialize(obj)
{
	var string = '';
	
	if (typeof(obj) == 'object') 
	{
		if (obj instanceof Array) 
		{
			string = 'a:';
			tmpstring = '';
			count = 0;
			for (var key in obj) 
			{
				tmpstring += php_serialize(key);
				tmpstring += php_serialize(obj[key]);
				count++;
			}
			string += count + ':{';
			string += tmpstring;
			string += '}';
		} 
		else if (obj instanceof Object) 
		{
			classname = obj.toString();
			
			if (classname == '[object Object]') 
			{
				classname = 'StdClass';
			}
			
			string = 'O:' + classname.length + ':"' + classname + '":';
			tmpstring = '';
			count = 0;
			for (var key in obj) 
			{
				tmpstring += php_serialize(key);
				if (obj[key]) 
				{
					tmpstring += php_serialize(obj[key]);
				} 
				else 
				{
					tmpstring += php_serialize('');
				}
				count++;
			}
			string += count + ':{' + tmpstring + '}';
		}
	} 
	else 
	{
		switch (typeof(obj)) 
		{
			case 'number':
				if (obj - Math.floor(obj) != 0) 
				{
					string += 'd:' + obj + ';';
				} 
				else 
				{
					string += 'i:' + obj + ';';
				}
				break;
			case 'string':
				string += 's:' + obj.length + ':"' + obj + '";';
				break;
			case 'boolean':
				if (obj) 
				{
					string += 'b:1;';
				} 
				else 
				{
					string += 'b:0;';
				}
			break;
		}
	}	
	return string;
}
	
	
	

	
	
	