function showhideDivs(obj)
  {

  if(obj.id == 'closediv')
  {
     displayDiv(obj);
    document.getElementById('opendiv').style.display = 'inline';
  }
  else if(obj.id == 'opendiv')
  {

  document.getElementById('closediv').style.display = 'inline';
  }
  
  if(obj.id == 'closediv2')
  {
     displayDiv(obj);
  document.getElementById('opendiv2').style.display = 'inline';
  }
  else if(obj.id == 'opendiv2')
  {

   document.getElementById('closediv2').style.display = 'inline';
  }
  
 if(obj.id == 'opendiv3')
 {

  document.getElementById('closediv3').style.display = 'inline';
 }
 else if(obj.id == 'closediv3')
 {
    displayDiv(obj);
  document.getElementById('opendiv3').style.display = 'inline';
 }
 if(obj.id == 'opendiv4')
 {

  document.getElementById('closediv4').style.display = 'inline';
 }
 else if(obj.id == 'closediv4')
 {
    displayDiv(obj);
  document.getElementById('opendiv4').style.display = 'inline';
 }

 if(obj.id == 'opendiv5')
 {

  document.getElementById('closediv5').style.display = 'inline';
 }
 else if(obj.id == 'closediv5')
 {
    displayDiv(obj);
  document.getElementById('opendiv5').style.display = 'inline';
 }
 
  if(obj.id == 'opendiv6')
 {

  document.getElementById('closediv6').style.display = 'inline';
 }
 else if(obj.id == 'closediv6')
 {
    displayDiv(obj);
  document.getElementById('opendiv6').style.display = 'inline';
 }
 
  if(obj.id == 'opendiv7')
 {

  document.getElementById('closediv7').style.display = 'inline';
 }
 else if(obj.id == 'closediv7')
 {
    displayDiv(obj);
  document.getElementById('opendiv7').style.display = 'inline';
 }
 
  if(obj.id == 'opendiv10')
 {

  document.getElementById('closediv10').style.display = 'inline';
 }
 else if(obj.id == 'closediv10')
 {
    displayDiv(obj);
  document.getElementById('opendiv10').style.display = 'inline';
 }

 
  obj.style.display = 'none'; 
  
}
  
  function displayDiv(showDiv)
{ 

var myDivs  = new Array("hd02","hd03","hd04","hd05","hd06","hd07","hd08");
var CloseDivs = new Array("closediv","closediv2","closediv3","closediv4","closediv5","closediv6","closediv7");
var OpenDivs = new Array("opendiv","opendiv2","opendiv3","opendiv4","opendiv5","opendiv6","opendiv7");
for (myDiv in myDivs)
{
//alert(document.getElementById(myDivs[myDiv]));
//hide all
if(document.getElementById(myDivs[myDiv])!=null)
{

$(myDivs[myDiv]).slideToggle('medium');

document.getElementById(myDivs[myDiv]).style.display = 'none';
document.getElementById(CloseDivs[myDiv]).style.display='inline';
document.getElementById(OpenDivs[myDiv]).style.display='none';

}
}
//show desired
//document.getElementById(showDiv).display = 'block';
}

function WordCalculation(obj)
{
 //   alert(obj * 225);
    document.getElementById('lblTotalWord').innerHTML =obj * 225;
}
function trimSpaces(str)
{
if (str != null)
{
var i;


for (i=0; i < str.length; i++)
{
if (str.charAt(i)!=" ")
{
str=str.substring(i,str.length);
break;
}
}

for (i = str.length-1; i >= 0; i--)
{
if (str.charAt(i)!=" ")
{
str = str.substring(0,i+1);
break;
}
}

if (str.charAt(0)==" ")
{
return "";
}
else
{
return str;
}
}
}
//*********************************** Check Null ******************************

function chknull(txtbox, txtname)

{
       
        if (trimSpaces(txtbox.value) == '')
        {
            alert(txtname);
            txtbox.focus();
            return false; 
        }

        return true;

}

//********************* Check for Max length reached **************************

function chkmax(txtbox, txtlen, txtname)
{
        if (txtbox.value.length > txtlen)
        {
                alert('Please limit ' + txtname + ' to only ' + txtlen + ' characters.')
                txtbox.focus();
                return false;
        }
        return true;

}
function Validate()
{

    var strDate=new Date();
 strDate= strDate.getMonth() + "/" +  (strDate.getDay() + 1) + "/" + strDate.getFullYear();
    //alert(strDate);


    if (!chknull(document.form1.txtTopic, "Please enter your topic’s actual title. (Example: Human Resource Management)."))
    {
             return false;
    }
    if (!chkmax(document.form1.txtTopic,1000,"your topic")) 
    {
             return false;
    } 
    if (!chknull(document.form1.txtDetail, "Please provide the description of your topic."))
    {
             return false;
    }
    if (!chkmax(document.form1.txtDetail,5000,"your topic's description")) 
    {
              return false;
    } 
     
    if (!chkDeadLine())
	{
		return false;
	}
    
	 if(document.form1.txtName.value == "")
    {
            alert('Please enter your name');
            document.form1.txtName.focus();
            return(false);
    }
	else if(emailCheck(document.getElementById('txtEmail').value) == false)
	{
        alert('Email address should be proper. (e.g. john@yahoo.com)');
        document.form1.txtEmail.focus();
        return(false);
	}
 	else  if(trimSpaces(document.form1.txtPhone.value)=="")
		{
		    alert("Please enter your phone no");
		    document.form1.txtPhone.focus();
		    return false;
		}

	else if(document.form1.txtPhone.value.length < 10)
		{
		    alert("Please Provide Valid Phone Number");
		    document.form1.txtPhone.focus();
		    return false;
		}


  else if(document.getElementById('txtNewPassword').value == "")
    {
            alert('Password field is required');
            document.form1.txtNewPassword.focus();
            return(false);
    }
    
   else   if(document.form1.txtNewPassword.value == "")
    {
        alert('Password field is required');
        document.form1.txtNewPassword.focus();
        return(false);
    }
   else   if(document.form1.txtNewPassword2.value == "")
    {
        alert('Password field is required');
        document.form1.txtNewPassword2.focus();
        return(false);
    }
   else   if(document.form1.txtNewPassword2.value.toLowerCase() != document.form1.txtNewPassword.value.toLowerCase())
    {
        alert('Password fields should be same');
        document.form1.txtNewPassword2.focus();
        return(false);
    }
	
	

     return true;
}

function emailCheck(str) {

var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)

// Check If the @ sign is present in Email, invalid if not present ...
if (str.indexOf(at)==-1){
return false
}

// Check If the @ sign is first or last character of Email, invalid if it is first or last ...
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr-1){
return false
}

// Check If the Dot '.' is present in the Email and is first or last character
// invalid if not present and Invalid if first or last character ...
if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot,lstr-1)==lstr-1){
return false
}

// Check If the @ sign is used more than once in Email ...
// Invalid if used more than once .
if (str.indexOf(at,(lat+1))!=-1){
return false
}

// Check If the '.' appears just before or after '@' sign, than that is Invalid ...
if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
return false
}

// Check If the '.' exists after '@' sign (with 1 char gap), Invalid if it does not ...
if (str.indexOf(dot,(lat+2))==-1){
return false
}

// Check If there is any space in the Email, than that is Invalid ....
if (str.indexOf(" ")!=-1){
return false
}

return true     
}

//***** ORDER FOR DEADLINE CHECKS ************************************************************************
function setDeadLineDate(){

var max_days;

mm	= parseInt(document.form1.ddlMonth.options[document.form1.ddlMonth.selectedIndex].value);
dd	= parseInt(document.form1.ddlDay.options[document.form1.ddlDay.selectedIndex].value);
yy	= parseInt(document.form1.ddlYear.options[document.form1.ddlYear.selectedIndex].value);

min_mm = parseInt(document.form1.min_mm.value);
min_dd = parseInt(document.form1.min_dd.value);
min_yy = parseInt(document.form1.min_yy.value);		
//min_yy = parseInt(yrVal);		

min_days = 1;
l = (max_days -  min_days) + 1		
//filling the data combo

for(i=0;i<l;i++ ){
document.form1.ddlDay.options[i] = new Option(i+min_days,i+min_days);
}


}
//***** ORDER FOR DEADLINE CHECKS ************************************************************************
function chkDeadLine(){

var sel_date,min_date;
var str_sel_date,str_min_date;
var fi;

//fi	=	document.form1.fi.value;
//if (fi == '' )
{ 
mm	= parseInt(document.form1.ddlMonth.options[document.form1.ddlMonth.selectedIndex].value);
dd	= parseInt(document.form1.ddlDay.options[document.form1.ddlDay.selectedIndex].value);
yy	= parseInt(document.form1.ddlYear.options[document.form1.ddlYear.selectedIndex].value);
str_sel_date = mm+"/"+dd+"/"+yy;

min_mm = parseInt(document.form1.min_mm.value);
min_dd = parseInt(document.form1.min_dd.value);
min_yy = parseInt(document.form1.min_yy.value);

min_text = document.form1.ddlMonth.options[min_mm-1].text; 	
str_min_date = min_mm+"/"+min_dd+"/"+min_yy;
str_min_date_to_display = min_text+" "+min_dd+", "+min_yy;

sel_date = new Date(str_sel_date)
min_date = new Date(str_min_date)		

if(sel_date < min_date){
//alert("The deadline cannot be for the date, before "+str_min_date_to_display+".")
alert("Please select a valid deadline of at least 24 hours from today. (Example: "+str_min_date_to_display+" or any date after that).");

var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();
document.form1.ddlYear.value = curr_year;
setDeadLineDate();
document.form1.ddlDay.options[min_dd-1].selected = true;
document.form1.ddlMonth.options[min_mm-1].selected = true;
document.form1.ddlMonth.focus();
RushOrderVisibility();
return false;
}else{

if(mm == 4 || mm == 6 || mm == 9 || mm == 11){
max_days = 30;	
}else if(mm == 2){		// February			
if(yy % 4 == 0){	// Leap Year
max_days = 29;
}else{				// Not a Leap Year
max_days = 28;	
}			
}else{
max_days = 31;
}

if ( parseInt(dd) > parseInt(max_days) ) {
alert("Please select a valid Day of the Month for your deadline.")
document.form1.ddlDay.focus();

return false;
} else {

return true;
}

}
}	
//else	{
//	return true;
//}		
}

function RushOrderVisibility()
{
	var currdate = new Date();
	var curday, curmonth, curyear;
	var currfulldate;
	var seldate
	
	min_mm = parseInt(document.form1.min_mm.value);
	min_dd = parseInt(document.form1.min_dd.value);
	min_yy = parseInt(document.form1.min_yy.value);

	
	mm	= parseInt(document.form1.ddlMonth.options[document.form1.ddlMonth.selectedIndex].value);
	dd	= parseInt(document.form1.ddlDay.options[document.form1.ddlDay.selectedIndex].value);
	yy	= parseInt(document.form1.ddlYear.options[document.form1.ddlYear.selectedIndex].value);

			
	currfulldate = min_mm  + "/" + min_dd + "/" + min_yy;
	seldate = mm + "/" + dd + "/" + yy;
	
	
	if (currfulldate == seldate)
	{
		document.getElementById('tdRushOption').style.display = "block"
	
	}
	else
	{
		document.getElementById('tdRushOption').style.display = "none"
	
	}
	
		
	
}