/*
function deleteRecord()
{
	if(confirm("Are You Sure Want To Delete This Record!"))
	{
		alert("Record is deleted..");
	}
	else
	{
		alert("Record is not deleted..");
	}
}

function activateRecord()
{
	if(confirm("Are You Sure Want To Activate This Record!"))
	{
		alert("Record is activated..");
	}
	else
	{
		alert("Record is not activated..");
	}
}

function unassignRecord()
{
	if(confirm("Are You Sure Want To Unassign This Record!"))
	{
		alert("Record is unassigned..");
	}
	else
	{
		alert("Record is not unassigned..");
	}
}




function redirectDetailPage()
{
	window.location = "userProfile.php";
}

function redirectScorerDetailPage()
{
	window.location = "scorerProfile.php";
}

function redirectShopperDetailPage()
{
	window.location = "shopperProfile.php";
}

function redirectVideoDetailPage()
{
	window.location = "videoDetail.php";
}

function redirectTrainerDetailPage()
{
	window.location = "trainerDetail.php";
}

function redirectSalesCoachDetailPage()
{
	window.location = "salesCoachDetail.php";
}

function redirectSalesManagerDetailPage()
{
	window.location = "salesManagerDetail.php";
}

function redirectTargetDetailPage()
{
	window.location = "targetDetail.php";
}

function assignVideo()
{
	
	if(confirm("Are You Sure Want To Assign This Record!"))
	{
		window.location = "assignVideo.php";
	}
	else
	{
		alert("Record is not assigned..");
	}
}

function redirectToSchemaStep1()
{
	window.location = "addSchemaStep1.php";
}
function redirectToSchemaHeaderStep2()
{
	window.location = "addSchemaHeaderStep2.php";
}*/



function redirectSchemaPreview(schema_id)
{
 mywindow = window.open("SchemaPreview.php?schema_id="+schema_id,"Schema","location=1,status=1,scrollbars=1,width=800,height=800,resizable=1")

mywindow.moveTo(0,0);
 //	window.location.href = "SchemaPreview.php?schema_id="+schema_id;
}


function redirectToSectionStep3(schema_id)
{
	window.location.href = "managesection.php?schema_id="+schema_id;
}

function redirectToAddSection(schema_id)
{
	window.location.href = "addsection.php?schema_id="+schema_id;
}
function redirectToEditSection(schema_id, section_id)
{
	window.location.href = "addsection.php?schema_id="+schema_id + "&section_id="+section_id;
}

function redirectToaddSectionsChangeOrder(schema_id)
{
	window.location.href = "changesectionorder.php?schema_id="+schema_id;
}

function redirectToaddColumnSection(section_id,schema_id)
{
	window.location.href = "managesectioncolumn.php?section_id="+section_id+"&schema_id="+schema_id;
}

function redirectToaddSectionRows(schema_id, section_id)
{
		window.location.href	=	"addsection_cell.php?schema_id="+ schema_id + "&section_id="+section_id;
}

function redirectToSummaryLocation(schema_id)
{
		window.location.href	=	"manageSummaryLocation.php?schema_id="+ schema_id 
}

/*function redirectToQuestionStep4()
{
	window.location = "addQuestionStep4.php";
}
function redirectToSummaryStep5()
{
	window.location = "addSummaryStep5.php";
}
*/

function redirectToPreviewFinal(schema_id)
{
	window.location.href = "SchemaPreview.php?schema_id="+schema_id;
}

function SelectSort(SelList)
{
    var ID='';
    var Text='';
    for (x=0; x < SelList.length - 1; x++)
    {
        for (y=x + 1; y < SelList.length; y++)
        {
            if (SelList[x].text > SelList[y].text)
            {
                // Swap rows
                ID=SelList[x].value;
                Text=SelList[x].text;
                SelList[x].value=SelList[y].value;
                SelList[x].text=SelList[y].text;
                SelList[y].value=ID;
                SelList[y].text=Text;
            }
        }
    }
}
function moveAllLeftToRight(leftBox, rightBox, strToStore)
{
    //alert(leftBox+" , "+rightBox);
	var SelID='';
    var SelText='';
	var toStore = "";
	//alert(strToStore.value);
    // Move rows from leftBox to rightBox from bottom to top
    //for (i=leftBox.options.length - 1; i>=0; i--)
	for (i=0; i < leftBox.options.length; i++)
    {
        //if (leftBox.options[i].selected == true)
        //{
		if (leftBox.options[i].value != "" && leftBox.options[i].value != " ")
		{
            SelID=leftBox.options[i].value;
            SelText=leftBox.options[i].text;
			var flag = true;
			for (j=1; j < rightBox.options.length; j++)
			{
				if(leftBox.options[i].value == rightBox.options[j].value)
				{
					flag = false;
				}
			}
			if(flag)
			{
				var newRow = new Option(SelText,SelID);
				if(toStore.length == 0)
					toStore = SelID;
				else
					toStore = toStore + "," + SelID;
				rightBox.options[rightBox.length]=newRow;
			}
			//leftBox.options[i]=null;
		}
        //}
    }
	
	var toStore = "";
	for (j=1; j < rightBox.options.length; j++)
	{
		SelID=rightBox.options[j].value;
		if(toStore.length == 0)
			toStore = SelID;
		else
			toStore = toStore + "," + SelID;
	}

	strToStore.value = toStore;
	//alert(strToStore.value);
    //SelectSort(rightBox);
}
function moveSelectedLeftToRight(leftBox, rightBox, strToStore)
{
    //alert(leftBox+" , "+rightBox);
	var SelID='';
    var SelText='';
	var toStore = strToStore.value;
	//alert(strToStore.value);
    // Move rows from leftBox to rightBox from bottom to top
    //for (i=leftBox.options.length - 1; i>=0; i--)
    for (var i=0; i < leftBox.options.length; i++)
	{
        if (leftBox.options[i].selected == true && leftBox.options[i].value != "" && leftBox.options[i].value != " ")
        {
            SelID=leftBox.options[i].value;
            SelText=leftBox.options[i].text;

			var flag = true;
			for (j=1; j < rightBox.options.length; j++)
			{
				if(leftBox.options[i].value == rightBox.options[j].value)
				{
					flag = false;
				}
			}
			if(flag)
			{
				var newRow = new Option(SelText,SelID);
				if(toStore.length == 0)
					toStore = SelID;
				else
					toStore = toStore + "," + SelID;				
				rightBox.options[rightBox.length]=newRow;
			}

				//var newRow = new Option(SelText,SelID);
				//rightBox.options[rightBox.length]=newRow;
			//leftBox.options[i]=null;
        }
    }
	var toStore = "";
	for (j=1; j < rightBox.options.length; j++)
	{
		SelID=rightBox.options[j].value;
		if(toStore.length == 0)
			toStore = SelID;
		else
			toStore = toStore + "," + SelID;
	}

	strToStore.value = toStore;
	//alert(strToStore.value);
    //SelectSort(rightBox);
}
function moveSelectedRightToLeft(rightBox, leftBox, strToStore)
{
    //alert(leftBox+" , "+rightBox);
	//var SelID='';
    //var SelText='';
	var toStore = "";
	//alert(strToStore.value);
	//var strToStore = strToStore.split(',');
    // Move rows from leftBox to rightBox from bottom to top
    //for (i=rightBox.options.length - 1; i>=0; i--)
	for (var i=0; i < rightBox.options.length; i++)
    {
        if (rightBox.options[i].selected == true && rightBox.options[i].value != "" && rightBox.options[i].value != " ")
        {
            /*
			SelID=rightBox.options[i].value;
            SelText=rightBox.options[i].text;

			var flag = true;
			for (j=1; j < rightBox.options.length; j++)
			{
				if(leftBox.options[i].value == rightBox.options[j].value)
				{
					flag = false;
				}
			}
			if(flag)
			{
				var newRow = new Option(SelText,SelID);
				rightBox.options[rightBox.length]=newRow;
			}
			*/
            rightBox.options[i]=null;
			i--;			
				//var newRow = new Option(SelText,SelID);
				//rightBox.options[rightBox.length]=newRow;
			//leftBox.options[i]=null;
        }
		else if (rightBox.options[i].value != "" && rightBox.options[i].value != " ")
		{
			if(toStore.length == 0)
				toStore = rightBox.options[i].value;
			else
				toStore = toStore + "," + rightBox.options[i].value;
		}
    }
	
	var toStore = "";
	for (j=1; j < rightBox.options.length; j++)
	{
		SelID=rightBox.options[j].value;
		if(toStore.length == 0)
			toStore = SelID;
		else
			toStore = toStore + "," + SelID;
	}

	strToStore.value = toStore;
	//alert(strToStore.value);
    //SelectSort(rightBox);
}
function moveAllRightToLeft(rightBox, leftBox, strToStore)
{
    //alert(leftBox+" ,mahesh "+rightBox.options.length+"  "+rightBox);
	//var SelID='';
    //var SelText='';
    // Move rows from leftBox to rightBox from bottom to top
    //for (i=leftBox.options.length - 1; i>=0; i--)
	//alert(i);
	//var rightBoxlength =rightBox.options.length;
	//alert(strToStore.value);
	for (var i=0; i < rightBox.options.length; i++)
    {
        //if (rightBox.options[i].selected == true)
        //{
		if (leftBox.options[i].value != "" && leftBox.options[i].value != " ")
		{		
            //alert(i);
			//SelID=leftBox.options[i].value;
            //SelText=leftBox.options[i].text;
            //var newRow = new Option(SelText,SelID);
            //rightBox.options[rightBox.length]=newRow;
            rightBox.options[i]=null;
			i--;
        //}
		}
    }
	strToStore.value = "";
	//alert(strToStore.value);
	//alert(i);
    //SelectSort(rightBox);
}
function selectMultipleList(frmName, fildName, strSelectList)
{
	var strSelectList = strSelectList.split(",");
	var form = eval("document."+frmName+".elements");
	for (i = 0; i < form.length; i++)
	{
		if( form[i].name == fildName && form[i].type == "select-multiple")
		{
			for (p = 0; p < form[i].length; p++)
			{
				for (k = 0; k < strSelectList.length; k++)
				{			
					if(form[i][p].value == strSelectList[k])
					{
						form[i][p].selected = true;
					}
				}
			}
			break;
		}
	}
}
function addAssignedDivisions(leftBox, rightBox, divisions)
{
    //alert(leftBox+" , "+rightBox);
	var SelID='';
    var SelText='';
	//var toStore = strToStore.value;
	//alert(strToStore.value);
	//var divisions = divisions.split(',');
	var divisionArray = divisions.split(',');
	//alert(divisionArray +  "   >>>>>>>>>>>>  " +divisionArray.length);
/*
var array = [2, 5, 9];
var index = array.indexOf(2);
// index is 0
index = array.indexOf(7);
// index is -1
*/
    // Move rows from leftBox to rightBox from bottom to top
    //for (i=leftBox.options.length - 1; i>=0; i--)
	var	flag	=	false;
	for (var i=0; i < leftBox.options.length; i++)
    {
        
		var	flag	=	false;
		var k = leftBox.options[i].value;
		//alert(k + " >> " +divisions);
		//alert(divisions.indexOf(k));
		if(k != "" && k != " ")
		{
			//var p = divisions.indexOf(k);
			//alert(divisions.indexOf(k));
			//alert("sdjfklas");
			//alert(p);
			for(var	pn=0;pn<divisionArray.length;pn++)
			{
				if(divisionArray[pn]==k)
				{
					var	flag	=	true;
					break;
				}
			}
			if( flag ) // if( divisions.indexOf(k) != -1)
			{
				//alert(divisions.indexOf(k));
				SelID=leftBox.options[i].value;
				SelText=leftBox.options[i].text;
				var newRow = new Option(SelText,SelID);
				rightBox.options[rightBox.length]=newRow;
			}
		}
		/*
		if (leftBox.options[i].value != "" && leftBox.options[i].value != " ") // leftBox.options[i].selected == true && 
        {
            SelID=leftBox.options[i].value;
            SelText=leftBox.options[i].text;

			var flag = true;
			for (j=1; j < rightBox.options.length; j++)
			{
				if(leftBox.options[i].value == rightBox.options[j].value)
				{
					flag = false;
				}
			}
			if(flag)
			{
				
				var newRow = new Option(SelText,SelID);
				//
				if(toStore.length == 0)
					toStore = SelID;
				else
					toStore = toStore + "," + SelID;
				//
				rightBox.options[rightBox.length]=newRow;
			}

				//var newRow = new Option(SelText,SelID);
				//rightBox.options[rightBox.length]=newRow;
			//leftBox.options[i]=null;
        }
		*/
    }
	//strToStore.value = toStore;
	//alert(strToStore.value);
    //SelectSort(rightBox);
}

function addAssignedLocations(leftBox, rightBox, locations)
{
    //alert(leftBox+" , "+rightBox);
	var SelID='';
    var SelText='';
	var locationArray = locations.split(',');
    
	var	flag	=	false;
	for (var i=0; i < leftBox.options.length; i++)
    {
        
		var	flag	=	false;
		var k = leftBox.options[i].value;
		//alert(k + " >> " +divisions);
		//alert(divisions.indexOf(k));
		if(k != "" && k != " ")
		{
			for(var	pn=0;pn<locationArray.length;pn++)
			{//alert(locationArray[pn]+"==="+k);
				if(locationArray[pn]==k)
				{
					var	flag	=	true;
					break;
				}
			}
			if( flag ) // if( divisions.indexOf(k) != -1)
			{
				//alert(divisions.indexOf(k));
				SelID=leftBox.options[i].value;
				SelText=leftBox.options[i].text;
				var newRow = new Option(SelText,SelID);
				rightBox.options[rightBox.length]=newRow;
			}
		}
    }
}

function deselectMultipleList(frmName, fildName, strSelectList)
{
	var strSelectList = strSelectList.split(",");
	var form = eval("document."+frmName+".elements");
	for (i = 0; i < form.length; i++)
	{
		if( form[i].name == fildName && form[i].type == "select-multiple")
		{
			for (p = 0; p < form[i].length; p++)
			{
				for (k = 0; k < strSelectList.length; k++)
				{			
					if(form[i][p].value == strSelectList[k])
					{
						form[i][p].selected = false;
					}
				}
			}
			break;
		}
	}
}

// tovalidate date
/*
function validateDate(actualDate)
{
	var adate = actualDate.value;
	var adates = adate.split('/');
	var adateV = new Date(adates[2],adates[0],adates[1]);
	var adif = adateV.getTime();
	//alert("mahesh    >> " + adateV + " >>> " + adif  ) ;
	
	
	var cdate = new Date();
	
	var cdateY = eval ( cdate.getYear() + 1900 );
	var cdateM = eval ( cdate.getMonth() + 1 );
	var cdateD = cdate.getDate();
	
	//alert("mahesh    >> " + cdate + " >>> " + cdateY + " >> " + cdateM + " > " +  cdateD) ;
	
	var cdateV = new Date(cdateY,cdateM,cdateD);
	
	var cdif = cdateV.getTime();
	
	//alert("mahesh    >> " + cdateV + " >>> " + cdif  ) ;
	
	//return false; 
	
	var dif = eval ( cdateV.getTime() - adateV.getTime() );
	

	//alert("mahesh     diff == " + dif) ;
	
	if( adif > cdif )
	{
		alert("Date entered should not be greater then current date");
		actualDate.focus();
		return false; 
	}
}

*/