// <?php !! This fools phpdocumentor into parsing this file
/**
* @version		$Id: joomla.javascript.js 10389 2008-06-03 11:27:38Z pasamio $
* @package		Joomla
* @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license		GNU/GPL
* Joomla! is Free Software
*/

/**
 * Overlib Styling Declarations to allow CSS class override of styles
 *
 */
var ol_fgclass			='ol-foreground';
var ol_bgclass			='ol-background';
var ol_textfontclass	='ol-textfont';
var ol_captionfontclass	='ol-captionfont';
var ol_closefontclass	='ol-closefont';

// general utility for browsing a named array or object
function xshow(o) {
	s = '';
	for(e in o) {s += e+'='+o[e]+'\n';}
	alert( s );
}

/**
* Writes a dynamically generated list
* @param string The parameters to insert into the <select> tag
* @param array A javascript array of list options in the form [key,value,text]
* @param string The key to display for the initial state of the list
* @param string The original key that was selected
* @param string The original item value that was selected
*/
function writeDynaList( selectParams, source, key, orig_key, orig_val ) {
	var html = '\n	<select ' + selectParams + '>';
	var i = 0;
	for (x in source) {
		if (source[x][0] == key) {
			var selected = '';
			if ((orig_key == key && orig_val == source[x][1]) || (i == 0 && orig_key != key)) {
				selected = 'selected="selected"';
			}
			html += '\n		<option value="'+source[x][1]+'" '+selected+'>'+source[x][2]+'</option>';
		}
		i++;
	}
	html += '\n	</select>';

	document.writeln( html );
}


/********** Utilities Functions


*****/

function stringTrim(str)
{
    if(str.length > 0)
        while(str.indexOf(' ') == 0)
            str = str.substr(1);
    if (str.length > 0)
        while(str.lastIndexOf(' ') == str.length-1)
            str = str.substr(0, str.length-1);
    return str;
}

function validDate_date(dateObj)
{
	var dateArray = dateObj.split("-");
	
	return false;
}

function validateDOB(obj)
{
	//var dtStr=obj.value;
	var dtStr = obj;
	

	var year		= "";
	var day			= "";
	var month		= "";
	var leap		= 0;
	var valid		= true;
	var oth_valid	= true;
	var feb			= false;
	var validDate	= true;
	var Ret			= true;

	if(obj != '')
	{
		if(dtStr != "" && dtStr != null)
		{
			year	= dtStr.substr(6,4);
			month	= dtStr.substr(3,2);
			day		= dtStr.substr(0,2);
			
			
			 
			if(dtStr.indexOf("-")== "2" && dtStr.lastIndexOf("-") == "5")
			{
				validDate = true;
			}
			else
			{
				validDate = false;
			}
			
			if(year=="0000" || year < 1900 || month == "00" || day == "00" ||
			dtStr.length<10)
			{
				validDate = false;
			}
			
			if(validDate == true)
			{
				
				leap = year%4;

				if(month=="02")
				{
					feb=true;
				}
				
				if(leap == 0 && month == "02")
				{
					if(day>29)
					{
						valid = false;
						feb = true;
					}
				}
				else if(month=="02" && day>28)
				{
					valid = false;
					feb = true;
				}
				if(feb == false)
				{
					

					if(month == "03" || month == "01" || month == "05" || month == "07"
					|| month == "08" || month == "10" || month == "12")
					{
						if(day > 31)
						{
							oth_valid = false;
						}
					}
				
					else if(month == "04" || month == "06" || month == "2" || month == "09" ||
					month == "11")
					{
						if(day > 30)
						{
							oth_valid=false;
						}
					}					
					else
					{
						oth_valid=false;
					}
					
				}
				
				
			}
			
			 
		}

		if(valid == false || oth_valid == false || validDate== false)
		{
			Ret=false;
		}
		return Ret;
	}
}

function isValidEmail (emailIn)
{
	var isEmailOk = false;

	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9_\-])+\.)+([a-zA-Z_]{2,4})+$/;


	if(emailIn.search(filter) != -1)
		isEmailOk = true;
	if(emailIn.indexOf("..") != -1)
		isEmailOk = false;
	if(emailIn.indexOf(".@") != -1)
		isEmailOk = false;
	if(emailIn.indexOf("'") != -1 || emailIn.indexOf("''") != -1 || emailIn.indexOf("\"") != -1 || emailIn.indexOf("\"\"") != -1 || emailIn.indexOf("(") != -1  ||  emailIn.indexOf(")") != -1 || emailIn.indexOf("[") != -1 || emailIn.indexOf("]") != -1 || emailIn.indexOf("{") != -1  || emailIn.indexOf("}") != -1 || emailIn.indexOf(",") != -1 || emailIn.indexOf(",,") != -1 || emailIn.indexOf(":") != -1 || emailIn.indexOf(";") != -1 || emailIn.indexOf("#") != -1 || emailIn.indexOf("mailto:") != -1)
		isEmailOk = false;

	return isEmailOk;
}
/*****
Function to Validate Signup Form
***/
function check_signup()
{	
	var formObj = document.signup;
	
	if(stringTrim(formObj.user_password.value) == '')
	{
		alert("Please enter password.");
		formObj.user_password.focus();
		return false;
	}
	else if (stringTrim(formObj.user_password.value).length < 6)
	{
		alert("Please enter atleast six characters for password.");
		formObj.user_password.focus();
		return false;
	}

	if(stringTrim(formObj.user_confirm_password.value) == '')
	{
		alert("Please enter confirm password.");
		formObj.user_confirm_password.focus();
		return false;
	}
	else if (stringTrim(formObj.user_confirm_password.value).length < 6)
	{
		alert("Please enter atleast six characters for confirm password.");
		formObj.user_confirm_password.focus();
		return false;
	}
	if(stringTrim(formObj.user_confirm_password.value) != stringTrim(formObj.user_password.value))
	{
		alert("Password mismatch.");
		formObj.user_confirm_password.focus();
		return false;
	}
	
	if(stringTrim(formObj.email.value) == '')
	{
		alert("Please enter email.");
		formObj.email.focus();
		return false;
	}
	else
	{
		if(!isValidEmail(stringTrim(formObj.email.value)))
		{
			alert("Please enter a valid email address.");
			formObj.email.focus();
			return false;
		}	
	}
	var actionString = "action=signup&task=emailCheck&emailID="+stringTrim(formObj.email.value)+"";
	
	if(ajaxFunc(actionString,'check_email'))
	{
		return false;
	}
	return true;
}

/**
* Changes a dynamically generated list
* @param string The name of the list to change
* @param array A javascript array of list options in the form [key,value,text]
* @param string The key to display
* @param string The original key that was selected
* @param string The original item value that was selected
*/
function changeDynaList( listname, source, key, orig_key, orig_val ) {
	var list = eval( 'document.adminForm.' + listname );

	// empty the list
	for (i in list.options.length) {
		list.options[i] = null;
	}
	i = 0;
	for (x in source) {
		if (source[x][0] == key) {
			opt = new Option();
			opt.value = source[x][1];
			opt.text = source[x][2];

			if ((orig_key == key && orig_val == opt.value) || i == 0) {
				opt.selected = true;
			}
			list.options[i++] = opt;
		}
	}
	list.length = i;
}

/**
* Adds a select item(s) from one list to another
*/
function addSelectedToList( frmName, srcListName, tgtListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );
	var tgtList = eval( 'form.' + tgtListName );

	var srcLen = srcList.length;
	var tgtLen = tgtList.length;
	var tgt = "x";

	//build array of target items
	for (var i=tgtLen-1; i > -1; i--) {
		tgt += "," + tgtList.options[i].value + ","
	}

	//Pull selected resources and add them to list
	//for (var i=srcLen-1; i > -1; i--) {
	for (var i=0; i < srcLen; i++) {
		if (srcList.options[i].selected && tgt.indexOf( "," + srcList.options[i].value + "," ) == -1) {
			opt = new Option( srcList.options[i].text, srcList.options[i].value );
			tgtList.options[tgtList.length] = opt;
		}
	}
}

function delSelectedFromList( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	var srcLen = srcList.length;

	for (var i=srcLen-1; i > -1; i--) {
		if (srcList.options[i].selected) {
			srcList.options[i] = null;
		}
	}
}

function moveInList( frmName, srcListName, index, to) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );
	var total = srcList.options.length-1;

	if (index == -1) {
		return false;
	}
	if (to == +1 && index == total) {
		return false;
	}
	if (to == -1 && index == 0) {
		return false;
	}

	var items = new Array;
	var values = new Array;

	for (i=total; i >= 0; i--) {
		items[i] = srcList.options[i].text;
		values[i] = srcList.options[i].value;
	}
	for (i = total; i >= 0; i--) {
		if (index == i) {
			srcList.options[i + to] = new Option(items[i],values[i], 0, 1);
			srcList.options[i] = new Option(items[i+to], values[i+to]);
			i--;
		} else {
			srcList.options[i] = new Option(items[i], values[i]);
	   }
	}
	srcList.focus();
	return true;
}

function getSelectedOption( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		return srcList.options[i];
	} else {
		return null;
	}
}

function setSelectedValue( frmName, srcListName, value ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	var srcLen = srcList.length;

	for (var i=0; i < srcLen; i++) {
		srcList.options[i].selected = false;
		if (srcList.options[i].value == value) {
			srcList.options[i].selected = true;
		}
	}
}

function getSelectedRadio( frmName, srcGroupName ) {
	var form = eval( 'document.' + frmName );
	var srcGroup = eval( 'form.' + srcGroupName );

	return radioGetCheckedValue( srcGroup );
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function radioGetCheckedValue(radioObj) {
	if (!radioObj) {
		return '';
	}
	var n = radioObj.length;
	if (n == undefined) {
		if (radioObj.checked) {
			return radioObj.value;
		} else {
			return '';
		}
	}
	for (var i = 0; i < n; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return '';
}

function getSelectedValue( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		return srcList.options[i].value;
	} else {
		return null;
	}
}

function getSelectedText( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		return srcList.options[i].text;
	} else {
		return null;
	}
}

function chgSelectedValue( frmName, srcListName, value ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		srcList.options[i].value = value;
		return true;
	} else {
		return false;
	}
}

/**
* Toggles the check state of a group of boxes
*
* Checkboxes must have an id attribute in the form cb0, cb1...
* @param The number of box to 'check'
* @param An alternative field name
*/
function checkAll( n, fldName ) {
  if (!fldName) {
     fldName = 'cb';
  }
	var f = document.adminForm;
	var c = f.toggle.checked;
	var n2 = 0;
	for (i=0; i < n; i++) {
		cb = eval( 'f.' + fldName + '' + i );
		if (cb) {
			cb.checked = c;
			n2++;
		}
	}
	if (c) {
		document.adminForm.boxchecked.value = n2;
	} else {
		document.adminForm.boxchecked.value = 0;
	}
}

function listItemTask( id, task ) {
    var f = document.adminForm;
    cb = eval( 'f.' + id );
    if (cb) {
        for (i = 0; true; i++) {
            cbx = eval('f.cb'+i);
            if (!cbx) break;
            cbx.checked = false;
        } // for
        cb.checked = true;
        f.boxchecked.value = 1;
        submitbutton(task);
    }
    return false;
}

function hideMainMenu() {
	if (document.adminForm.hidemainmenu) {
		document.adminForm.hidemainmenu.value=1;
	}
}

function isChecked(isitchecked){
	if (isitchecked == true){
		document.adminForm.boxchecked.value++;
	}
	else {
		document.adminForm.boxchecked.value--;
	}
}

/**
* Default function.  Usually would be overriden by the component
*/
function submitbutton(pressbutton) {
	submitform(pressbutton);
}


function stringTrim(str)
{
    if(str.length > 0)
        while(str.indexOf(' ') == 0)
            str = str.substr(1);
    if (str.length > 0)
        while(str.lastIndexOf(' ') == str.length-1)
            str = str.substr(0, str.length-1);
    return str;
}

/**
* Submit the admin form
*/
function submitform(pressbutton)
{	
	
	var iChars1		= "!~`@#$%^&*()+=-[]\\\';,./{}|\":<>?0123456789+-/_";
	var iChars2		= "!~`@$%^&*()+=[]\';{}|\":<>?+_";
	/// characters Allowed for Title and Name field as per the ASP site.
	///	()[]{}*
	var iChars3		= "~`@$%^&+=\';|\":<>?+";
	var iChars4		= "~`@$%^&+=\;|\<>?+";
	var iChars5		= "!~`@#$%^&*()+=-[]\\\';,./{}|\":<>?+-/_";

	var iCharssecd	= "!~`@#$%^&*()+=-[]\\\';,./{}|\":<>";	
	var formObj		= document.adminForm;

	if (pressbutton)
	{
		document.adminForm.task.value = pressbutton;		
		
		if(document.adminForm.form_name && pressbutton == 'save')
		{		
			if(document.adminForm.form_name.value == 'fashion')	//For validating the fashion entry form starts
			{				
				if(stringTrim(formObj.fashion_title.value) == "")
				{
					alert("Please enter fashion title.");
					formObj.fashion_title.focus();
					return false;
				}
				else 
				{
					for (var i = 0; i < formObj.fashion_title.value.length; i++) 
					{
						if (iChars4.indexOf(formObj.fashion_title.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for fashion title");
							alert("~`@$%^&+=;|\"<>?+ characters are not allowed.");
							formObj.fashion_title.focus();
							return false;
						}
					}
				}

				if(stringTrim(formObj.fashion_desc.value) == "")
				{
					alert("Please enter fashion description.");
					formObj.fashion_desc.focus();
					return false;
				}

				if(stringTrim(formObj.f_image.value) != "")
				{
					var img	= formObj.f_image.value.split("." ) ;
					var len		= img.length ; 

					//if((img[len-1] == "jpeg") || (img[len-1] == "jpg") ||  (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "bmp") || (img[len-1] == "JPG") ||  (img[len-1] == "GIF") || (img[len-1] == "PNG") || (img[len-1] == "BMP") || (img[len-1] == "JPEG"))
					
					if((img[len-1] == "jpeg") || (img[len-1] == "jpg") || (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "JPG") || (img[len-1] == "GIF") || (img[len-1] == "PNG") || (img[len-1] == "JPEG"))
					{
					}
					else 
					{
						alert("Please upload valid fashion image."); 
						formObj.f_image.focus() ;
						return false; 
					}
				}

				if(stringTrim(formObj.fashion_date.value) == "")
				{
					alert("Please select fashion date.");
					formObj.fashion_date.focus();
					return false;
				}
				else if(stringTrim(formObj.fashion_date.value) == "0000-00-00")
				{
					alert("Please select valid fashion date.");
					formObj.fashion_date.focus();
					return false;
				}
			}	//Fashion entry and edit form ends
			else if(document.adminForm.form_name.value == 'event')	//For validating the event entry form starts
			{				
				if(stringTrim(formObj.event_title.value) == "")
				{
					alert("Please enter event title.");
					formObj.event_title.focus();
					return false;
				}
				else 
				{
					for (var i = 0; i < formObj.event_title.value.length; i++) 
					{
						if (iChars4.indexOf(formObj.event_title.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for event title");
							alert("~`@$%^&+=;|\<>?+ characters are not allowed.");
							formObj.event_title.focus();
							return false;
						}
					}
				}

				if(stringTrim(formObj.event_desc.value) == "")
				{
					alert("Please enter event description.");
					formObj.event_desc.focus();
					return false;
				}
				
				/*
				
				if(formObj.personality.value == "")
				{
					alert("Please select atleast one personality.");					
					formObj.personality.focus();
					return false;
				}
				*/
				
				var select_count=0;
				var mutli_education = formObj.elements["personality[]"];

				for(i=0;i<mutli_education.length;i++)
				{ 
					if (mutli_education[i].selected == true)
					{
						select_count = 1;
					}			
				}

				if(select_count == 0)
				{
					alert("Please select Personality.");
					mutli_education[0].focus();
					return false;
				}	
			

				if(stringTrim(formObj.event_venue.value) == "")
				{
					alert("Please enter party venue.");
					formObj.event_venue.focus();
					return false;
				}
				if(stringTrim(formObj.f_image.value) != "")
				{
					var img	= formObj.f_image.value.split("." ) ;
					var len		= img.length ; 

					//if((img[len-1] == "jpg") ||  (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "bmp") )

					if((img[len-1] == "jpeg") || (img[len-1] == "jpg") || (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "JPG") || (img[len-1] == "GIF") || (img[len-1] == "PNG") || (img[len-1] == "JPEG"))
					{
					}
					else 
					{
						alert("Please upload valid event image."); 
						formObj.f_image.focus() ;
						return false; 
					}
				}

				if(stringTrim(formObj.event_date.value) == "")
				{
					alert("Please select event date.");
					formObj.event_date.focus();
					return false;
				}
				else if(stringTrim(formObj.event_date.value) == "0000-00-00")
				{
					alert("Please select valid event date.");
					formObj.event_date.focus();
					return false;
				}

			}	//Event entry and edit form ends
			else if(document.adminForm.form_name.value == 'party')	//For validating the party entry form starts
			{				
				if(stringTrim(formObj.party_title.value) == "")
				{
					alert("Please enter party title.");
					formObj.party_title.focus();
					return false;
				}
				else 
				{
					for (var i = 0; i < formObj.party_title.value.length; i++) 
					{
						if (iChars4.indexOf(formObj.party_title.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for party title");
							alert("~`@$%^&+=;|\"<>?+ characters are not allowed.");
							formObj.party_title.focus();
							return false;
						}
					}
				}

				if(stringTrim(formObj.party_desc.value) == "")
				{
					alert("Please enter party description.");
					formObj.party_desc.focus();
					return false;
				}
				
				var select_count=0;
				var mutli_education = formObj.elements["personality[]"];

				for(i=0;i<mutli_education.length;i++)
				{ 
					if (mutli_education[i].selected == true)
					{
						select_count = 1;
					}			
				}

				if(select_count == 0)
				{
					alert("Please select Personality.");
					mutli_education[0].focus();
					return false;
				}	
			
				/*
				if(formObj.personality.value == "")
				{
					alert("Please select atleast one personality.");					
					formObj.personality.focus();
					return false;
				}
				*/

				if(stringTrim(formObj.party_venue.value) == "")
				{
					alert("Please enter party venue.");
					formObj.party_venue.focus();
					return false;
				}

				if(stringTrim(formObj.f_image.value) != "")
				{
					var img	= formObj.f_image.value.split("." ) ;
					var len		= img.length ; 

					//if((img[len-1] == "jpg") ||  (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "bmp") )
					if((img[len-1] == "jpeg") || (img[len-1] == "jpg") || (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "JPG") || (img[len-1] == "GIF") || (img[len-1] == "PNG") || (img[len-1] == "JPEG"))
					{
					}
					else 
					{
						alert("Please upload valid party image."); 
						formObj.f_image.focus() ;
						return false; 
					}
				}

				if(stringTrim(formObj.party_date.value) == "")
				{
					alert("Please select party date.");
					formObj.party_date.focus();
					return false;
				}
				else if(stringTrim(formObj.party_date.value) == "0000-00-00")
				{
					alert("Please select valid party date.");
					formObj.party_date.focus();
					return false;
				}				
			}	//Party entry and edit form ends
			else if(document.adminForm.form_name.value == 'bvpoll')	//For validating the bollywood poll entry form starts
			{				
			
				if(stringTrim(formObj.poll_question.value) == "")
				{
					alert("Please enter poll question.");
					formObj.poll_question.focus();
					return false;
				}

				if(stringTrim(formObj.poll_answer1.value) == "")
				{
					alert("Please enter poll answer 1.");
					formObj.poll_answer1.focus();
					return false;
				}

				if(stringTrim(formObj.poll_answer2.value) == "")
				{
					alert("Please enter poll answer 2.");
					formObj.poll_answer2.focus();
					return false;
				}

				if(stringTrim(formObj.poll_answer3.value) == "")
				{
					alert("Please enter poll answer 3.");
					formObj.poll_answer3.focus();
					return false;
				}
				if(stringTrim(formObj.poll_answer4.value) == "")
				{
					alert("Please enter poll answer 4.");
					formObj.poll_answer4.focus();
					return false;
				}
				
			}	//Bollywood poll entry and edit form ends
			else if(document.adminForm.form_name.value == 'celebrity')	//For validating the celebrity entry form starts
			{				
				if(stringTrim(formObj.celebrity_name.value) == "")
				{
					alert("Please enter celebrity name.");
					formObj.celebrity_name.focus();
					return false;
				} 
				else
				{
					for (var i = 0; i < formObj.celebrity_name.value.length; i++) 
					{
						if (iChars3.indexOf(formObj.celebrity_name.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for celebrity name");
							alert("~`@$%^&+=';|\":<>?+ characters are not allowed.");
							formObj.celebrity_name.focus();
							return false;
						}
					}
				}

				if(stringTrim(formObj.celebrity_desc.value) == "")
				{
					alert("Please enter celebrity description.");
					formObj.celebrity_desc.focus();
					return false;
				}
				
				if(stringTrim(formObj.celebrity_type_id.value) == "")
				{
					alert("Please select celebrity status type.");
					formObj.celebrity_type_id.focus();
					return false;
				}
				
				/*
				if(stringTrim(formObj.celebrity_bdate.value) == "")
				{
					alert("Please select date of birth.");
					formObj.celebrity_bdate.focus();
					return false;
				}				
				
					else if(stringTrim(formObj.celebrity_bdate.value) == "0000-00-00" && formObj.celebrity_action.value == 'Add')
				{
					alert("Please select valid date of birth.");
					formObj.celebrity_bdate.focus();
					return false;
				}//celebrity_action
				
				else */
				
				//if((stringTrim(formObj.celebrity_bdate.value) != "0000-00-00") && formObj.celebrity_action.value == 'Add')
				if((stringTrim(formObj.celebrity_bdate.value) != "") && formObj.celebrity_action.value == 'Add')
				{
					var newDate = formObj.celebrity_bdate.value.split("-");
					var dateValue = newDate[2] + "-" + newDate[1] + "-" + newDate[0];	


					if(!validateDOB(dateValue))
					{
						alert("Please select valid date of birth.") ;
						formObj.celebrity_bdate.focus();
						return false ;
					}

					var today = new Date();
					var month, year, day;
					year	= today.getFullYear() ;
					month	=  today.getMonth() + 1 ;
					day		=  today.getDate();
					var y, m, d ;
					
					d = newDate[2];
					m = newDate[1] ;
					y = newDate[0];

					if (y == year &&  m == month && day == d)
					{
						alert("DOB should not as current or future date.");
						//formObj.celebrity_bdate.focus();
						return false ;
					}
					if (y == year &&  m == month && day < d)
					{
						alert("DOB should not as current or future date.");
						//formObj.celebrity_bdate.focus();
						return false ;
					}
					
					if (y == year &&  m  > month)
					{
						alert("DOB should not as current or future date.");
						//formObj.celebrity_bdate.focus();
						return false ;
					}

					if (y > year)
					{
						alert("DOB should not as current or future date.");
						//formObj.celebrity_bdate.focus();
						return false ;
					}
				}

				if(stringTrim(formObj.celebrity_zodiacsign.value) != "")
				{
					for (var i = 0; i < formObj.celebrity_zodiacsign.value.length; i++) 
					{
						if (iChars3.indexOf(formObj.celebrity_zodiacsign.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for zodiac sign");
							alert("~`@$%^&+=';|\":<>?+ characters are not allowed.");
							formObj.celebrity_zodiacsign.focus();
							return false;
						}
					}
				}

				if(stringTrim(formObj.celebrity_address.value) == "")
				{
					alert("Please enter address.");
					formObj.celebrity_address.focus();
					return false;
				}

				if(stringTrim(formObj.celebrity_parent.value) != "")
				{
					for (var i = 0; i < formObj.celebrity_parent.value.length; i++) 
					{
						if (iChars4.indexOf(formObj.celebrity_parent.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for celebrity parent name");
							alert("~`@$%^&+=;|\"<>?+ characters are not allowed.");
							formObj.celebrity_parent.focus();
							return false;
						}
					}
				}

				if(stringTrim(formObj.celebrity_sister.value) != "")
				{
					for (var i = 0; i < formObj.celebrity_sister.value.length; i++) 
					{
						if (iChars4.indexOf(formObj.celebrity_sister.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for celebrity sister name ");
							alert("~`@$%^&+=;|\"<>?+ characters are not allowed.");
							formObj.celebrity_sister.focus();
							return false;
						}
					}
				}

				if(stringTrim(formObj.celebrity_brother.value) != "")
				{
					for (var i = 0; i < formObj.celebrity_brother.value.length; i++) 
					{
						if (iChars4.indexOf(formObj.celebrity_brother.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for celebrity brother name");
							alert("~`@$%^&+=;|\"<>?+ characters are not allowed.");
							formObj.celebrity_brother.focus();
							return false;
						}
					}
				}

				if(stringTrim(formObj.celebrity_first_film.value) != "")
				{
					for (var i = 0; i < formObj.celebrity_first_film.value.length; i++) 
					{
						if (iChars4.indexOf(formObj.celebrity_first_film.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for celebrity first film");
							alert("~`@$%^&+=;|\"<>?+ characters are not allowed.");
							formObj.celebrity_first_film.focus();
							return false;
						}
					}
				}

				if(stringTrim(formObj.celebrity_plus_point.value) != "")
				{
					for (var i = 0; i < formObj.celebrity_plus_point.value.length; i++) 
					{
						if (iChars4.indexOf(formObj.celebrity_plus_point.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for celebrity plus point");					
							alert("~`@$%^&+=;|\"<>?+ characters are not allowed.");
							formObj.celebrity_plus_point.focus();
							return false;
						}
					}
				}

				if(stringTrim(formObj.c_image1.value) != "")
				{
					var img	= formObj.c_image1.value.split("." ) ;
					var len = img.length ; 
					//if((img[len-1] == "jpeg") ||  (img[len-1] == "jpg") ||  (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "bmp") ) 

					if((img[len-1] == "jpeg") || (img[len-1] == "jpg") || (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "JPG") || (img[len-1] == "GIF") || (img[len-1] == "PNG") || (img[len-1] == "JPEG"))
					{
								
					}
					else
					{
						alert("Please upload valid celebrity image 1."); 
						formObj.c_image1.focus() ;
						return false; 
					}
				}

				if(stringTrim(formObj.c_image2.value) != "")
				{
					var img = formObj.c_image2.value.split("." ) ;
					var len = img.length ; 
					//if((img[len-1] == "jpeg") ||  (img[len-1] == "jpg") ||  (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "bmp") ) 

					if((img[len-1] == "jpeg") || (img[len-1] == "jpg") || (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "JPG") || (img[len-1] == "GIF") || (img[len-1] == "PNG") || (img[len-1] == "JPEG"))
					{
						
					} 
					else
					{
						alert("Please upload valid celebrity image 2."); 
						formObj.c_image2.focus() ;
						return false; 
					}
				}

			}	//Celebrity entry and edit form ends
			else if(document.adminForm.form_name.value == 'movie')/// Movie Component Form validation
			{				
				if(stringTrim(formObj.movie_title.value) == "")
				{
					alert("Please enter movie title.");
					formObj.movie_title.focus();
					return false;
				}
				else 
				{
					for (var i = 0; i < formObj.movie_title.value.length; i++) 
					{
						if (iChars4.indexOf(formObj.movie_title.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for movie title");
							alert("~`@$%^&+=;|\"<>?+ characters are not allowed.");
							formObj.movie_title.focus();
							return false;
						}
					}
				}

				if(stringTrim(formObj.movie_description.value) == "")
				{
					alert("Please enter movie description.");
					formObj.movie_description.focus();
					return false;
				}				

				if(stringTrim(formObj.MovieType.value) == "")
				{
					alert("Please select movie type.");
					formObj.MovieType.focus();
					return false;
				}
				
				var select_count=0;
				var mutli_education = formObj.elements["personality[]"];

				for(i=0;i<mutli_education.length;i++)
				{ 
					if (mutli_education[i].selected == true)
					{
						select_count = 1;
					}			
				}

				if(select_count == 0)
				{
					alert("Please select Personality.");
					mutli_education[0].focus();
					return false;
				}	
				
				if(stringTrim(formObj.movie_releasedate.value) == "")
				{
					alert("Please select Theatrical Release Date.");
					formObj.movie_releasedate.focus();
					return false;
				}
				else if(stringTrim(formObj.movie_releasedate.value) == "0000-00-00")
				{
					alert("Please select Valid Theatrical Release Date.");
					formObj.movie_releasedate.focus();
					return false;
				}
				
				if(stringTrim(formObj.movie_sutdio.value) != "")
				{					
					for (var i = 0; i < formObj.movie_sutdio.value.length; i++) 
					{
						if (iChars4.indexOf(formObj.movie_sutdio.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for studio");
							alert("~`@$%^&+=;|\"<>?+ characters are not allowed.");
							formObj.movie_sutdio.focus();
							return false;
						}
					}
				}
				
				if(stringTrim(formObj.movie_revenue.value) != "")
				{
					if(isNaN(formObj.movie_revenue.value))
					{
						alert("Please enter only digit for revenue.");
						formObj.movie_revenue.focus();
						return false;
					}
				}	

				if(stringTrim(formObj.f_image1.value) != "")
				{
					var img	= formObj.f_image1.value.split("." ) ;
					var len		= img.length ; 

					//if((img[len-1] == "jpg") ||  (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "bmp") )

					if((img[len-1] == "jpeg") || (img[len-1] == "jpg") || (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "JPG") || (img[len-1] == "GIF") || (img[len-1] == "PNG") || (img[len-1] == "JPEG"))
					{
					}
					else 
					{
						alert("Please upload valid movie image 1."); 
						formObj.f_image1.focus() ;
						return false; 
					}
				}
				
				if(stringTrim(formObj.f_image2.value) != "")
				{
					var img	= formObj.f_image2.value.split("." ) ;
					var len		= img.length ; 

					//if((img[len-1] == "jpg") ||  (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "bmp") )

					if((img[len-1] == "jpeg") || (img[len-1] == "jpg") || (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "JPG") || (img[len-1] == "GIF") || (img[len-1] == "PNG") || (img[len-1] == "JPEG"))
					{
					}
					else 
					{
						alert("Please upload valid movie image 2."); 
						formObj.f_image2.focus() ;
						return false; 
					}
				}								
			}/// End of Movie Component Form validation
			else if(document.adminForm.form_name.value == 'song')/// Song Component Form validation
			{				
				if(stringTrim(formObj.song_title.value) == "")
				{
					alert("Please enter song title.");
					formObj.song_title.focus();
					return false;
				}
				else 
				{
					for (var i = 0; i < formObj.song_title.value.length; i++) 
					{
						if (iChars4.indexOf(formObj.song_title.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for song title");
							alert("~`@$%^&+=;|\"<>?+ characters are not allowed.");
							formObj.song_title.focus();
							return false;
						}
					}
				}

				if(stringTrim(formObj.song_lyrics.value) == "")
				{
					alert("Please enter song lyrics.");
					formObj.song_lyrics.focus();
					return false;
				}				

				if(stringTrim(formObj.scelebrity.value) == "" && stringTrim(formObj.smovie.value) == "0" && stringTrim(formObj.sevent.value) == "0")
				{
					alert("Please select any one from movie, celebrity or event.");
					formObj.scelebrity.focus();
					return false;
				}

				if(stringTrim(formObj.song_date.value) == "")
				{
					alert("Please select song date.");
					formObj.song_date.focus();
					return false;
				}								
				else if(stringTrim(formObj.song_date.value) == "0000-00-00")
				{
					alert("Please select valid song date.");
					formObj.song_date.focus();
					return false;
				}
			}/// End of Song Component Form validation
			else if(document.adminForm.form_name.value == 'wallpaper')/// Wallpaper Component Form validation
			{	
				
				if(stringTrim(formObj.wallpaper_title.value) == "")
				{
					alert("Please enter wallpaper title.");
					formObj.wallpaper_title.focus();
					return false;
				}
				else 
				{
					for (var i = 0; i < formObj.wallpaper_title.value.length; i++) 
					{
						if (iChars3.indexOf(formObj.wallpaper_title.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for wallpaper title");
							alert("~`@$%^&+=';|\":<>?+ characters are not allowed.");
							formObj.wallpaper_title.focus();
							return false;
						}
					}
				}

				if(stringTrim(formObj.wallpaper_thumb.value) == "" && stringTrim(formObj.image1.value) == "")
				{
					alert("Please upload wallpaper thumbnail image.");
					formObj.wallpaper_thumb.focus();
					return false;
				}

				if(stringTrim(formObj.wallpaper_thumb.value) != "")
				{
					var img	= formObj.wallpaper_thumb.value.split("." );
					var len		= img.length ; 

					//if((img[len-1] == "jpeg") || (img[len-1] == "jpg") ||  (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "bmp") )

					if((img[len-1] == "jpeg") || (img[len-1] == "jpg") || (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "JPG") || (img[len-1] == "GIF") || (img[len-1] == "PNG") || (img[len-1] == "JPEG"))
					{
					}
					else 
					{
						alert("Please upload valid thumbnail image."); 
						formObj.wallpaper_thumb.focus() ;
						return false; 
					}
				}

				if(stringTrim(formObj.wallpaper_img1.value) == "" && stringTrim(formObj.wallpaper_img2.value) == "" && stringTrim(formObj.image2.value) == "" && stringTrim(formObj.image3.value) == "")
				{
					alert("Please select any one big image.");
					formObj.wallpaper_img1.focus();
					return false;
				}
				
				
				if(stringTrim(formObj.wallpaper_img1.value) != "")
				{
					var img	= formObj.wallpaper_img1.value.split("." );
					var len		= img.length ; 

					//if((img[len-1] == "jpeg") || (img[len-1] == "jpg") ||  (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "bmp") )

					if((img[len-1] == "jpeg") || (img[len-1] == "jpg") || (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "JPG") || (img[len-1] == "GIF") || (img[len-1] == "PNG") || (img[len-1] == "JPEG"))
					{
					}
					else 
					{
						alert("Please upload valid image 1."); 
						formObj.wallpaper_img1.focus() ;
						return false; 
					}
				}
				
				if(stringTrim(formObj.wallpaper_img2.value) != "")
				{
					var img	= formObj.wallpaper_img2.value.split("." );
					var len		= img.length ; 

					//if((img[len-1] == "jpeg") || (img[len-1] == "jpg") ||  (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "bmp") )
					
					if((img[len-1] == "jpeg") || (img[len-1] == "jpg") || (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "JPG") || (img[len-1] == "GIF") || (img[len-1] == "PNG") || (img[len-1] == "JPEG"))
					{
					}
					else 
					{
						alert("Please upload valid image 2."); 
						formObj.wallpaper_img2.focus() ;
						return false; 
					}
				}

				if(stringTrim(formObj.wcelebrity.value) == "" && stringTrim(formObj.wmovie.value) == "0" && stringTrim(formObj.wevent.value) == "0")
				{
					alert("Please select any one from movie, celebrity or event.");
					formObj.wcelebrity.focus();
					return false;
				}
				
			}/// End of Wallpaper Component Form validation
			else if(document.adminForm.form_name.value == 'news')/// News Component Form validation
			{					
				if(stringTrim(formObj.news_title.value) == "")
				{
					alert("Please enter news title.");
					formObj.news_title.focus();
					return false;
				}
				else 
				{
					for (var i = 0; i < formObj.news_title.value.length; i++) 
					{
						if (iChars4.indexOf(formObj.news_title.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphabets for news title");
							alert("~`@$%^&+=;|\"<>?+ characters are not allowed.");
							formObj.news_title.focus();
							return false;
						}
					}
				}
				
				
				if(stringTrim(formObj.news_description.value) == "")
				{
					alert("Please enter news description.");
					formObj.news_description.focus();
					return false;
				}				
				
				//								f_image
					

					if(formObj.movie.value == "" && formObj.personality.value == "" && formObj.event.value == "")
					{
						alert("Please select atleast on modular relation.");
						return false;
					}
					
				
				if(stringTrim(formObj.news_date.value) == "")
				{
					alert("Please select news date.");
					formObj.news_date.focus();
					return false;
				}								
				else if(stringTrim(formObj.news_date.value) == "0000-00-00")
				{
					alert("Please select valid news date.");
					formObj.news_date.focus();
					return false;
				}
				
				
				if(stringTrim(formObj.f_image.value) != "")
				{
					var img	= formObj.f_image.value.split("." ) ;
					var len	= img.length ; 

					//if((img[len-1] == "jpg") ||  (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "bmp") )

					if((img[len-1] == "jpeg") || (img[len-1] == "jpg") || (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "JPG") || (img[len-1] == "GIF") || (img[len-1] == "PNG") || (img[len-1] == "JPEG"))
					{
					}
					else 
					{
						alert("Please upload valid news image."); 
						formObj.f_image.focus() ;
						return false; 
					}
				}											
			}/// End of News Component Form validation
			else if(document.adminForm.form_name.value == 'video')/// Video Component Form validation
			{				
				if(stringTrim(formObj.video_title.value) == "")
				{
					alert("Please enter video title.");
					formObj.video_title.focus();
					return false;
				}
				else 
				{
					for (var i = 0; i < formObj.video_title.value.length; i++) 
					{
						if (iChars2.indexOf(formObj.video_title.value.charAt(i)) != -1)
						{
							//alert ("Please enter only alphanumeric for video title");
							alert("!~`@$%^&*()+=[]\';{}|\":<>?+_ characters are not allowed.");
							formObj.video_title.focus();
							return false;
						}
					}
				}

				if(stringTrim(formObj.video_description.value) == "")
				{
					alert("Please enter video description.");
					formObj.video_description.focus();
					return false;
				}	 
				
				
				//alert("Movie = " + document.getElementById('video_movie').value + " , Celebrity = " + document.getElementById('video_celebrity').value + " , Event = " + document.getElementById('video_event').value);

				if(stringTrim(formObj.video_movie.value) == "" && stringTrim(formObj.video_celebrity.value) == "" && stringTrim(formObj.video_event.value) == "")
				{ 
					alert("Please select atleast on modular relation.");
					formObj.video_movie.focus();
					return false;
				}
				 
				var video_host = formObj.video_host.value;
				
				if(video_host == '')
				{
					alert("Please select video host.");
					formObj.video_host.focus();
					return false;
				}

				if(video_host == 'eros')
				{
					if(stringTrim(formObj.mid_code.value) == "")
					{
						alert("Please enter Eros MID Code.");
						formObj.mid_code.focus();
						return false;
					}
					else 
					{
						for (var i = 0; i < formObj.mid_code.value.length; i++) 
						{
							if (iChars5.indexOf(formObj.mid_code.value.charAt(i)) != -1)
							{
								//alert ("Please enter only alphanumeric for Eros MID Code");
								alert("!~`@#$%^&*()+=-[]\\\';,./{}|\":<>?+-/_ characters are not allowed.");
								formObj.mid_code.focus();
								return false;
							}
						}
					}

					if(stringTrim(formObj.sid_code.value) == "")
					{
						alert("Please enter Eros SID Code.");
						formObj.sid_code.focus();
						return false;
					}
					else 
					{
						for (var i = 0; i < formObj.sid_code.value.length; i++) 
						{
							if (iChars5.indexOf(formObj.sid_code.value.charAt(i)) != -1)
							{
								//alert ("Please enter only alphanumeric for Eros SID Code");
								alert("!~`@#$%^&*()+=-[]\\\';,./{}|\":<>?+-/_ characters are not allowed.");
								formObj.sid_code.focus();
								return false;
							}
						}
					}
				}

				if(formObj.FileAction.value == 'Add')
				{
					if(video_host == 'netlinkblue')
					{
						if(stringTrim(formObj.video_file.value) != "")
						{
							var img	= formObj.video_file.value.split("." ) ;
							var len	= img.length ; 

							if((img[len-1] == "mpg") ||  (img[len-1] == "mpeg") || (img[len-1] == "avi") || (img[len-1] == "wmv") || (img[len-1] == "3gp") || (img[len-1] == "mov") || (img[len-1] == "fla") || (img[len-1] == "flv"))
							{
							}
							else 
							{
								alert("Please upload file with valid format for video file."); 
								formObj.video_file.focus() ;
								return false; 
							}
						}
						else
						{
							alert("Please upload video file."); 
							formObj.video_file.focus() ;
							return false; 
						}
					}
					
					if(stringTrim(formObj.f_image.value) != "")
					{
						var img	= formObj.f_image.value.split("." ) ;
						var len	= img.length ; 

						//if((img[len-1] == "jpg") ||  (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "bmp") )

						if((img[len-1] == "jpeg") || (img[len-1] == "jpg") || (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "JPG") || (img[len-1] == "GIF") || (img[len-1] == "PNG") || (img[len-1] == "JPEG"))
						{
						}
						else 
						{
							alert("Please upload valid video image."); 
							formObj.f_image.focus() ;
							return false; 
						}
					}
					else
					{
						alert("Please upload video image."); 
						formObj.f_image.focus() ;
						return false; 
					}
				}
				else
				{		
					if(video_host == 'netlinkblue')
					{
						if(stringTrim(formObj.video_file.value) != "")
						{
							var img	= formObj.video_file.value.split("." ) ;
							var len	= img.length ; 

							if((img[len-1] == "mpg") ||  (img[len-1] == "mpeg") || (img[len-1] == "avi") || (img[len-1] == "wmv") || (img[len-1] == "3gp") || (img[len-1] == "mov") || (img[len-1] == "fla") || (img[len-1] == "flv"))
							{
							}
							else 
							{
								alert("Please upload file with valid format for video file."); 
								formObj.video_file.focus() ;
								return false; 
							}
						}	
					}
					
					if(stringTrim(formObj.f_image.value) != "")
					{
						var img	= formObj.f_image.value.split("." ) ;
						var len	= img.length ; 

						//if((img[len-1] == "jpg") ||  (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "bmp") )

						if((img[len-1] == "jpeg") || (img[len-1] == "jpg") || (img[len-1] == "gif") || (img[len-1] == "png") || (img[len-1] == "JPG") || (img[len-1] == "GIF") || (img[len-1] == "PNG") || (img[len-1] == "JPEG"))
						{
						}
						else 
						{
							alert("Please upload valid video image."); 
							formObj.f_image.focus() ;
							return false; 
						}
					}

				}

				if(stringTrim(formObj.video_date.value) == "")
				{
					alert("Please select video date.");
					formObj.video_date.focus();
					return false;
				}			

			}/// End of Video Component Form validation

		}
	}	
	
	
	if (typeof document.adminForm.onsubmit == "function") 
	{
		document.adminForm.onsubmit();
		
	}

	document.adminForm.submit();
}

/**
* Submit the control panel admin form
*/
function submitcpform(sectionid, id){
	document.adminForm.sectionid.value=sectionid;
	document.adminForm.id.value=id;
	submitbutton("edit");
}

/**
* Getting radio button that is selected.
*/
function getSelected(allbuttons){
	for (i=0;i<allbuttons.length;i++) {
		if (allbuttons[i].checked) {
			return allbuttons[i].value
		}
	}
	return null;
}

// JS Calendar
var calendar = null; // remember the calendar object so that we reuse
// it and avoid creating another

// This function gets called when an end-user clicks on some date
function selected(cal, date) {
	cal.sel.value = date; // just update the value of the input field
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks the "Close" (X) button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
	cal.hide();			// hide the calendar

	// don't check mousedown on document anymore (used to be able to hide the
	// calendar when someone clicks outside it, see the showCalendar function).
	Calendar.removeEvent(document, "mousedown", checkCalendar);
}

// This gets called when the user presses a mouse button anywhere in the
// document, if the calendar is shown.  If the click was outside the open
// calendar this function closes it.
function checkCalendar(ev) {
	var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
	for (; el != null; el = el.parentNode)
	// FIXME: allow end-user to click some link without closing the
	// calendar.  Good to see real-time stylesheet change :)
	if (el == calendar.element || el.tagName == "A") break;
	if (el == null) {
		// calls closeHandler which should hide the calendar.
		calendar.callCloseHandler(); Calendar.stopEvent(ev);
	}
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(id, dateFormat) {
	var el = document.getElementById(id);
	if (calendar != null) {
		// we already have one created, so just update it.
		calendar.hide();		// hide the existing calendar
		calendar.parseDate(el.value); // set it to a new date
	} else {
		// first-time call, create the calendar
		var cal = new Calendar(true, null, selected, closeHandler);
		calendar = cal;		// remember the calendar in the global
		cal.setRange(1900, 2070);	// min/max year allowed

		if ( dateFormat )	// optional date format
		{
			cal.setDateFormat(dateFormat);
		}

		calendar.create();		// create a popup calendar
		calendar.parseDate(el.value); // set it to a new date
	}
	calendar.sel = el;		// inform it about the input field in use
	calendar.showAtElement(el);	// show the calendar next to the input field

	// catch mousedown on the document
	Calendar.addEvent(document, "mousedown", checkCalendar);
	return false;
}

/**
* Pops up a new window in the middle of the screen
*/
function popupWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

// LTrim(string) : Returns a copy of a string without leading spaces.
function ltrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}

//RTrim(string) : Returns a copy of a string without trailing spaces.
function rtrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;       // Get length of string
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}

// Trim(string) : Returns a copy of a string without leading or trailing spaces
function trim(str) {
   return rtrim(ltrim(str));
}

function mosDHTML(){
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")<-1
	this.ie5=(this.ver.indexOf("MSIE 5")<-1 && this.dom && !this.opera5)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")<-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")<-1
	this.ns6=(this.dom && parseInt(this.ver) <= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);

	this.activeTab = '';
	this.onTabStyle = 'ontab';
	this.offTabStyle = 'offtab';

	this.setElemStyle = function(elem,style) {
		document.getElementById(elem).className = style;
	}
	this.showElem = function(id) {
		if ((elem = document.getElementById(id))) {
			elem.style.visibility = 'visible';
			elem.style.display = 'block';
		}
	}
	this.hideElem = function(id) {
		if ((elem = document.getElementById(id))) {
			elem.style.visibility = 'hidden';
			elem.style.display = 'none';
		}
	}
	this.cycleTab = function(name) {
		if (this.activeTab) {
			this.setElemStyle( this.activeTab, this.offTabStyle );
			page = this.activeTab.replace( 'tab', 'page' );
			this.hideElem(page);
		}
		this.setElemStyle( name, this.onTabStyle );
		this.activeTab = name;
		page = this.activeTab.replace( 'tab', 'page' );
		this.showElem(page);
	}
	return this;
}
var dhtml = new mosDHTML();

// needed for Table Column ordering
function tableOrdering( order, dir, task ) {
	var form = document.adminForm;

	form.filter_order.value 	= order;
	form.filter_order_Dir.value	= dir;
	submitform( task );
}

function saveorder( n,  task ) {
	checkAll_button( n, task );
}

//needed by saveorder function
function checkAll_button( n, task ) {

    if (!task ) {
		task = 'saveorder';
	}

	for ( var j = 0; j <= n; j++ ) {
		box = eval( "document.adminForm.cb" + j );
		if ( box ) {
			if ( box.checked == false ) {
				box.checked = true;
			}
		} else {
			alert("You cannot change the order of items, as an item in the list is `Checked Out`.");
			return;
		}
	}
	submitform(task);
}
/**
* @param object A form element
* @param string The name of the element to find
*/
function getElementByName( f, name ) {
	if (f.elements) {
		for (i=0, n=f.elements.length; i < n; i++) {
			if (f.elements[i].name == name) {
				return f.elements[i];
			}
		}
	}
	return null;
}

function go2( pressbutton, menu, id ) {
	var form = document.adminForm;

	if (form.imagelist && form.images) {
		// assemble the images back into one field
		var temp = new Array;
		for (var i=0, n=form.imagelist.options.length; i < n; i++) {
			temp[i] = form.imagelist.options[i].value;
		}
		form.images.value = temp.join( '\n' );
	}

	if (pressbutton == 'go2menu') {
		form.menu.value = menu;
		submitform( pressbutton );
		return;
	}

	if (pressbutton == 'go2menuitem') {
		form.menu.value 	= menu;
		form.menuid.value 	= id;
		submitform( pressbutton );
		return;
	}
}
/**
 * Verifies if the string is in a valid email format
 * @param	string
 * @return	boolean
 */
function isEmail( text )
{
	var pattern = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	var regex = new RegExp( pattern );
	return regex.test( text );
}

/**
*  For Dynamic content change on the HomePage for Celebrities
*/
function changeCelebDesc(cond,eid)
{
	ajaxFunc(cond,eid);
	return false;
}

/**
*  For Dynamic change the content on the HomePage for Event Calendar
*/
function changeEventDetail(cond,eid)
{
	ajaxFunc(cond,eid);
}

/**
* For checking existing email of newsletter
*/
function checkExistingEmail(cond,eid)
{	
	ajaxFunc(cond,eid);
}

function newsletterEntry(cond,eid)
{ 
	ajaxFunc(cond,eid);
}

function checkSignupEmail(cond,eid)
{
	return ajaxFunc(cond,eid);
}

/**
* For AJAX Request
*/
var xmlHttp;

function ajaxFunc(cond, elemid)
{
	xmlHttp = browserCheck();
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{		
			if(elemid == 'check_email')
			{
				if(xmlHttp.responseText == 'No')
				{
					document.getElementById(elemid).innerHTML = 'This Email id is already in use.';
					return true;
				}
				else
				{
					//alert("Yes");
					return false;
				}
			}
			else
			{
				if(elemid == 'none')
				{
					var returnMsg = xmlHttp.responseText;
					if(returnMsg == "You have already rated it.")
					{
					}
					else
					{
						alert(xmlHttp.responseText);
					}
				}
				else
				{		
					//alert(xmlHttp.responseText);
					document.getElementById(elemid).innerHTML = xmlHttp.responseText;
				}
			}
		}
	}
	var url = "ajaxrequest.php?"+cond;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

/**
* Browser Check
* For AJAX Request
*/
function browserCheck()
{
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}

function setStatus(id)
{	
	var totalEvents = document.getElementById('totalEvents').value;
	for(var i=1; i<=totalEvents;i++)
	{
		document.getElementById("li_event_"+i).className = "blues";
	}
	document.getElementById("li_event_"+id).className = "whites";
}

/**
* Form Submission by Javascript
*/
var myWind = "";

function formSubByJS(frm)
{
	var interests='';
	var cnt = 0;
	
	for(var i=0; i<document.getElementsByName('interest[]').length; i++)
	{
		if(document.getElementsByName('interest[]')[i].checked){
			interests += document.getElementsByName('interest[]')[i].value+',';
			cnt++;
		}
	}
	
	if(cnt == 0)
	{
		alert("Please select atleast one interest.");
		return false;
	}
	
	if(stringTrim(frm.email.value) == '')
	{
		alert("Please enter your email address.");
		frm.email.focus();
		return false;
	}
	else
	{
		if(!isValidEmail(stringTrim(frm.email.value)))
		{
			alert("Please enter a valid email address.");
			frm.email.focus();
			return false;
		}	
	}	
	
		///////// code for Anti Spam	\\\\\\\\\
	/*
	if(document.enewsletter.windowCheck.value=='Open')
	{
		alert("Please enter anti spam security code.");
		if(!myWind.closed)
		{
			myWind.focus();
			myWind.document.frmVal.txtActivation.focus();
		}
		else
		{
			document.enewsletter.windowCheck.value='Open';
			myWind = window.open('spam_validator.php','_blank','height=210, width=550, left=350, top=300, menubar=no');
		}
		return false;
	}
	
	if (document.getElementById('captchaValidate').value == '')
	{
		document.enewsletter.windowCheck.value='Open';
		myWind = window.open('spam_validator.php','_blank','height=210, width=550, left=350, top=300, menubar=no');
		return false;
	}
	else
	{		
		alert("Please enter anti spam security code.");
		myWind.focus();
		return false;
	}
	
	alert("U r here");
	//////////// End of Antispam check	///////////////////
*/


	var email = frm.email.value;
	newsletterEntry('action=newsletter&task=entry&interest='+interests+'&email='+email,'entry_success');
	return false;
}

function makeVote(id, type)
{
	url = 'action=review&task='+type+'&id='+id;
	eid = type+id;
	ajaxFunc(url,eid);
}

function setStarRating(id, num, type)
{
	var str = '';

	for(var i=1; i<=num; i++)
		str += '<img src="images/star.jpg" onclick="setStarRating('+id+','+i+',\''+type+'\')">';

	for(var i=num+1; i<=5; i++)
		str += '<img src="images/star-blank.jpg" onclick="setStarRating('+id+','+i+',\''+type+'\')">';
	
	document.getElementById(type+'_rating'+id).innerHTML = str;

	saveRating(id, num, type);
}

function saveRating(id, review, type)
{
	//alert(type+' - '+id+': '+review);
	url = "action=review&task=rate&id="+id+"&act="+type+"&rating="+review;
	eid = "none";
	ajaxFunc(url,eid);
}

//For hilighting the tab
function selectTab(id1, id2)
{
	
	document.getElementById(id1).className = 'tab1';
	document.getElementById(id2).className = 'tab2';

	if(id1 == 'recently')
	{
		document.getElementById('recent').style.display = '';
		document.getElementById('previous').style.display = 'none';
		document.getElementById('recent_movie_image').style.display = '';
		document.getElementById('previous_movie_image').style.display = 'none';
	}
	else
	{
		document.getElementById('recent').style.display = 'none';
		document.getElementById('previous').style.display = '';
		document.getElementById('previous_movie_image').style.display = '';
		document.getElementById('recent_movie_image').style.display = 'none';
	}
}


function highlight_div(id, mid, type, divid)
{	
	//alert(type);
	
	// totalRecentMovie		totalPreviousMovie
	var totalRecentMovie	= document.getElementById("totalRecentMovie").value;
	var totalPreviousMovie	= document.getElementById("totalPreviousMovie").value;
	
	//alert(type+"\n"+totalRecentMovie+"\n"+totalPreviousMovie);
	
	/*
	var totalRecentMovie	= 1;
	var totalPreviousMovie	= 1;

	*/
	if(type == "recent")
	{
		for(var i=1; i<=totalRecentMovie;i++)
		{
			document.getElementById("mov"+i).className = "aa";
		}
		document.getElementById("mov"+divid).className = "b-sel";
	}
	else if(type == "previous")
	{
		for(var i=1; i<=totalPreviousMovie;i++)
		{
			document.getElementById("movp"+i).className = "aa";
		}
		document.getElementById("movp"+divid).className = "b-sel";
	}
	
	var cond = "action=movie&task=setimg&id="+mid;
	
	if(type == "recent")
	{
		eid = 'recent_movie_image';
	}
	else
	{
		eid = 'previous_movie_image';
	}
	
	//alert(cond+" \n "+eid)
	ajaxFunc(cond,eid);
}

var timeVariable;

function ContentScroll(id,dis,pos)
{
	var obj = document.getElementById(id)
	obj.scrollTop = obj.scrollTop + dis;
	if (pos)
	{
		obj.scrollTop = pos; 
	}
	else 
	{
		timeVariable = setTimeout(function() { ContentScroll(id, dis); }, 10); 
	}
}
var inputValue='';
function checkInput(inputValue)
{
	//alert(inputValue);
	if(inputValue == 'Please enter name to search celebrity')
	{
		document.getElementById('celebs').value = '';
	}
	
}

function checkOutBlur()
{	
	document.getElementById('celeb_list').style.display='none';	
}
var counter = 0;

function filterCelebrity(e, elem)
{
	var selectedDiv = '';
	var button = e.keyCode;
	
	if(button != 38 && button != 40 && button != 13)			//For Up Arrow Key
	{
		var cond = "action=celebrity&task=filter&key=" + elem.value;
		document.getElementById('celeb_list').style.display = '';
		ajaxFunc(cond,'celeb_list');
	}

	//var totdiv = parseInt(document.getElementsByClassName('dynlist').length);

	var totdiv = 0;

	if(document.getElementById('total_celebrity') != undefined)
	{
		var totdiv = document.getElementById('total_celebrity').value;
	}
	else
	{
		//var totdiv = parseInt(document.getElementsByClassName('dynlist').length);
	}
	
	//alert("Total Div = "+totdiv);

	
	if(button == 38)			//For Up Arrow Key
	{
		if(counter > 1)
		{
			tmpcnt = counter;
			counter--;

			if(document.getElementById('div_'+tmpcnt))
			{
				document.getElementById('div_'+tmpcnt).style.backgroundColor = "#ffffff";	
			}

			if(document.getElementById('div_'+counter))
			{
				document.getElementById('div_'+counter).style.backgroundColor = "#e6e6e6";	
			}
			
			//alert("1="+document.getElementById("hid_"+counter).value);
			if(document.getElementById("hid_"+counter).value != '' && document.getElementById("hid_"+counter).value != 0)
			{
				changeCelebDesc('id='+document.getElementById("hid_"+counter).value+'&action=celebrity&task=descView','content');		
			}

			//changeCelebDesc('id='+document.getElementById("hid_"+counter).value+'&action=celebrity&task=descView','content');
		}
	}
	else if(button == 40)
	{		//For Down Arrow Key
		if(counter <= totdiv)
		{
			tmpcnt = counter;
			counter++;
			if(document.getElementById('div_'+tmpcnt))
			{
				document.getElementById('div_'+tmpcnt).style.backgroundColor = "#ffffff";	
			}
			
			if(document.getElementById('div_'+counter))
			{
				document.getElementById('div_'+counter).style.backgroundColor = "#e6e6e6";	
			}
			
			//alert("2="+document.getElementById("hid_"+counter).value);

			if(document.getElementById("hid_"+counter).value != '' && document.getElementById("hid_"+counter).value != 0)
			{
				changeCelebDesc('id='+document.getElementById("hid_"+counter).value+'&action=celebrity&task=descView','content');			
			}
		}
	}
	else if(button == 13)
	{		//For Enter Key
		document.getElementById('celeb_list').style.display='none';
	}

}
var counter1=0;
function filterCelebrity1(e, elem)
{
	//alert(e.keyCode);
	var selectedDiv = '';
	var button = e.keyCode;
	
	if(button != 38 && button != 40 && button != 13)			//For Up Arrow Key
	{
		var cond = "action=celebrity&task=filter1&key="+elem.value;
		document.getElementById('celeb_list').style.display='';
		ajaxFunc(cond,'celeb_list');
	}

	//var totdiv = parseInt(document.getElementsByClassName('dynlist').length);
	var totdiv = parseInt(document.getElementById('total_celebrity').value);

	if(button == 38)			//For Up Arrow Key
	{
		if(counter1 > 1){
			tmpcnt = counter1;
			counter1--;
			if(document.getElementById('div_'+tmpcnt)){
				document.getElementById('div_'+tmpcnt).style.backgroundColor = "#ffffff";	
			}
			if(document.getElementById('div_'+counter1)){
				document.getElementById('div_'+counter1).style.backgroundColor = "#e6e6e6";	
			}
			changeCelebDesc('id='+document.getElementById("hid_"+counter1).value+'&action=celebrity&task=descView','content');
		}
	}else if(button == 40){		//For Down Arrow Key
		if(counter1 < totdiv){
			tmpcnt = counter1;
			counter1++;
			if(document.getElementById('div_'+tmpcnt)){
				document.getElementById('div_'+tmpcnt).style.backgroundColor = "#ffffff";	
			}
			if(document.getElementById('div_'+counter1)){
				document.getElementById('div_'+counter1).style.backgroundColor = "#e6e6e6";	
			}
			changeCelebDesc('id='+document.getElementById("hid_"+counter1).value+'&action=celebrity&task=descView','content');			
		}
	}else if(button == 13){		//For Enter Key
		document.getElementById('celeb_list').style.display='none';
	}
	return false;
}
function checkSearch()
{

	if(stringTrim(document.searchFrm.keyword.value) == '' || stringTrim(document.searchFrm.keyword.value) == "Enter Seach Keyword")
	{
		alert("Please enter your searching word.");
		document.searchFrm.keyword.focus();
		return false;
	}
}
