function isDate(sDate) { 
	var re = /^\d{2}\-\d{2}\-\d{4}$/;
	if (re.test(sDate)) { 
		var dArr = sDate.split("-"); 
		var d = new Date(dArr[1] + '-' + dArr[0] + '-' + dArr[2]); 
		return d.getMonth() + 1 == dArr[1] && d.getDate() == dArr[0] && d.getFullYear() == dArr[2]; 
	} 
	else { 
		return false; 
	} 
} 

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function trimAll(frm){
	for(var i = 0; i < frm.elements.length; i++){
		if(frm.elements[i].type == 'text' || frm.elements[i].type == 'textarea'){
			frm.elements[i].value = trim(frm.elements[i].value);
		}
	}
}

function isAlplaNumeric(input){
	var re = /^[0-9A-Za-z]*$/;
	return re.test(input);
}

function isNumeric(sNumeric){
	var re = /^(-|\+)?\d+(\.\d+)?$/;
	return re.test(sNumeric);
}

function isInteger(sInteger){
	var re = /^(-)?\d+$/;
	return re.test(sInteger);
}

function openwin(url)
{
	 w = screen.width;
	 h = screen.height;
	 ah = h /3*2;
	 w = w/2+10;
	 nw=window.open(url,"",'toolbar=no,top=100,left=100,location=no,directories=no,menubar=no,scrollbars=yes,status=no,resizable=1,width='+w+',height='+ah)
}

function isLeapYear(year){
{ 
	if(!isInteger(year))
		return false;
	if((year%4==0&&year%100!=0)||(year%400==0)) 
	{ 
		return true; 
	}  

		return false; 
	} 
}

var dateOfMonth = new Array();
dateOfMonth[0] = 0;
dateOfMonth[1] = 31;
dateOfMonth[2] = 28;
dateOfMonth[3] = 31;
dateOfMonth[4] = 30;
dateOfMonth[5] = 31;
dateOfMonth[6] = 30;
dateOfMonth[7] = 31;
dateOfMonth[8] = 31;
dateOfMonth[9] = 30;
dateOfMonth[10] = 31;
dateOfMonth[11] = 30;
dateOfMonth[12] = 31;

function changeDate(day, month, year){
	var day_value = day.value;
	var month_value = month.value;
	var year_value = year.value;
	if(month_value != 'MM'){
		var noOfDay = 0;
		if(month_value != '02')
			noOfDay = dateOfMonth[parseInt(month_value, 10)];
		else {
			if(isLeapYear(year_value))
				noOfDay = 29;
			else 
				noOfDay = 28;
		}
		day.length = noOfDay + 1;
		day[0] = new Option('Date', 'DD');
		for(var i = 1; i <= noOfDay; i++){
			if(i < 10)
				day[i] = new Option("0" + i, "0" + i);
			else
				day[i] = new Option(i, i);
		}
	}
	if(month_value == '02' && day_value == '29' && !isLeapYear(year_value)){
		day.value = '28';
	} else {
		if(day_value != 'DD'){
			if(day.length - 1 >= parseInt(day_value, 10))
				day.value = day_value;
			else
				day.selectedIndex = day.length - 1;
		}
	}
}

function isDateSelected(day, month, year){
	if(day.selectedIndex > 0 && month.selectedIndex > 0 && year.selectedIndex > 0)
		return true;
	else 
		return false;
}

function hideObject(obj){
   if (window.ActiveXObject) { // IE
      obj.style.display = "none";
   } else if (window.XMLHttpRequest) { // Mozilla, Safari,...
      obj.style.display = "none";
   }
}

function showObject(obj){
   if (window.ActiveXObject) { // IE
      obj.style.display = "block";
   } else if (window.XMLHttpRequest) { // Mozilla, Safari,...
      obj.style.display = "table-row";
   }
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
	  	xmlHttp=new XMLHttpRequest();
	} catch (e) {
		try	{
		    // Internet Explorer
		    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
  	}
	return xmlHttp;
}
if (typeof jQuery != "undefined") {
$(document).ready(function() {
	$('#position').change(function() {
		if ($(this).val() == 0) {
			$('#name2,#is_video_div,#is_video_span').show();
		} else {
			$('#name2,#is_video_div,#is_video_span').hide();
		}
	});
});
}
