//-----------------tooltip-----------------

/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint=15//Customize x offset of tooltip
var offsetypoint=10 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

// JScript File
function enable_disable(control)
{
eval(document.getElementById("wiz_rbYearbook").disabled= ! control);
eval(document.getElementById("wiz_rbYearbook").parentNode.disabled = ! control);
eval(document.getElementById("wiz_rbYearbook_0").disabled= ! control);
eval(document.getElementById("wiz_rbYearbook_0").parentNode.disabled = ! control);
eval(document.getElementById("wiz_rbYearbook_1").disabled= ! control);
eval(document.getElementById("wiz_rbYearbook_1").parentNode.disabled = ! control);
ValidatorEnable(document.getElementById("wiz_RequiredFieldValidator_rbYearbook"), control);
}
//}

function changeCase(frmObj) 
{
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;
tmpStr = frmObj.value.toLowerCase();
strLen = tmpStr.length;
if (strLen > 0)  {
for (index = 0; index < strLen; index++)  {
if (index == 0)  {
tmpChar = tmpStr.substring(0,1).toUpperCase();
postString = tmpStr.substring(1,strLen);
tmpStr = tmpChar + postString;
}
else {
tmpChar = tmpStr.substring(index, index+1);
if (tmpChar == " " && index < (strLen-1))  {
tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+2,strLen);
tmpStr = preString + tmpChar + postString;
         }
      }
   }
}
frmObj.value = tmpStr;
}

function cbSms(checked, what)
{
    if (what == 'sms')
    {
        ValidatorEnable(document.getElementById("wiz_RequiredFieldValidator_Mob"), checked);
    }
    else
    {
        ValidatorEnable(document.getElementById("wiz_RequiredFieldValidator_Email"), checked);
    }
}

function ddlTypechange(control)
{   
    
    if (control == 101)
    {   
        eval(document.getElementById("wiz_tbLinked").disabled= true );
        eval(document.getElementById("wiz_tbLinked").parentNode.disabled = true);
        eval(document.getElementById("wiz_tbLinked").value = "");
        //ValidatorEnable(document.getElementById("RequiredFieldValidator_Linked"), false);
    }
/*    else if (control == 107)
    {
        eval(document.getElementById("tbLinked").disabled= false );
        eval(document.getElementById("tbLinked").parentNode.disabled = false);
        ValidatorEnable(document.getElementById("CustomValidator_Linked"), true);
    }
  */  else
    {
        eval(document.getElementById("wiz_tbLinked").disabled= false );
        eval(document.getElementById("wiz_tbLinked").parentNode.disabled = false);
        //ValidatorEnable(document.getElementById("RequiredFieldValidator_Linked"), false);
    }
    //alert(window.location.href.indexOf('lang=en_us'))    
    if ((control == "" || control == 105 || control == 106 || control == 107 ) && (window.location.href.indexOf('lang=en_us') <= 0 ))
    { 
        enable_disable(false)
    }
    else if (window.location.href.indexOf('lang=en_us') <= 0)
    {
        enable_disable(true)
    }
    if ((control == "" || control == 105 || control == 106 || control == 107 ) && (window.location.href.indexOf('lang=en_us') > 0 ))
    { 
        eval(document.getElementById("wiz_cbReceivebook").disabled= true);
    }
    else if ((control == 100 || control == 101 || control == 102 || control == 103 || control == 104 ) && (window.location.href.indexOf('lang=en_us') > 0 ))
    { 
        eval(document.getElementById("wiz_cbReceivebook").disabled= false);
    }

}
function load()
{
    //document.forms[0].ctl00_PageBody_Work1_ddl_Work.options[document.forms[0].ctl00_PageBody_Work1_ddl_Work.selectedIndex].text
    if (document.getElementById("wiz_ddlType"))
    {
        var cont = document.getElementById("wiz_ddlType").options[document.getElementById("wiz_ddlType").selectedIndex].value
        if (cont.length)
        {
            if (cont.length > 0 )
            {
                ddlTypechange(cont)
            }
            if (window.location.href.indexOf('lang=en_us') > 0)
            {
                if (document.getElementById("wiz_cbReceivebook").checked)
                {   
                    enable_disable(true)
                }
            }
        }  
    }
 /*   
    if (document.getElementById("wiz_cbReceiveSms")) 
    {
        if (document.getElementById("wiz_cbReceiveSms").checked == true)
        {
            cbSms(true, 'sms')
        }
    }
    if (document.getElementById("wiz_cbReceiveEmail")) 
    {
        if (document.getElementById("wiz_cbReceiveEmail").checked == true)
        {
            cbSms(true, 'email')
        }
    
    }
*/
}
function openwin(url)
{
window.open(url,'','toolbar=no,status=no,menubar=no,screenX=-10000, screenY=-10000, resizable=no,scrollbars=yes,width=800,height=600')
}
function isAcceptChecked(sender, args)
    {
        var returnBoolean = false;
        if (document.getElementById("wiz_cbAccept").checked)
        
        {    
            returnBoolean = true;
        }
        args.IsValid = returnBoolean;
        
    }




// JScript File By Team Data System AS (c)
  
function clearDateField(objName){
	var strOutputDate = getDateInstance(objName.value);
	objName.value = strOutputDate;
}
function dateIntellisense(objName){
	var strOutputDate = getDateInstance(objName.value);
	if(strOutputDate.length > 0)
	{
	    strOutputDate.length
		objName.value = strOutputDate;
		ValidatorEnable(document.getElementById("wiz_RegularExpressionValidator_Birthdate"), false);
}
		
	else if(objName.value.length>0){
	    objName.value = '#';
            ValidatorEnable(document.getElementById("wiz_RegularExpressionValidator_Birthdate"), true);
	    }
 }
function getDateInstance(strDate){
	if(strDate == null) return '';
	var nStringLength = strDate.length;
	if(nStringLength == 0) return '';
	var arrDate;

	if ((strDate.indexOf('-') > -1) && (strDate.indexOf('.') > -1) && (strDate.indexOf(',') > -1) && (strDate.indexOf('/') > -1))
		return '';
	
	if (strDate.indexOf('-') > -1)
		arrDate = strDate.split("-");
	else if (strDate.indexOf(',') > -1)
		arrDate = strDate.split(",");
    else if (strDate.indexOf('/') > -1)
		arrDate = strDate.split("/");
	else 
		arrDate = strDate.split(".");
	
	var nArrLength = arrDate.length;
	if(nArrLength > 3) return '';
	var nDay = -1;
	var nMonth = -1;
	var nYear = -1;
	
	var d=new Date();
	var nCurrentDay = d.getDate();
	var nCurrentMonth = d.getMonth() + 1;
	var nCurrentYear = d.getFullYear();
	var nAutoMinYear = 11; //1911
	
	//if (strDate.indexOf("/") > -1) return '';
	
	if(nArrLength == 1) {
		if(nStringLength > 2 && nStringLength % 2 != 0) return '';
		nDay = parseInt(nStringLength <= 2 ? strDate : (parseInt(strDate.substr(0,1)) == 0) ? strDate.substr(1, 1) : strDate.substr(0, 2));
		if(nStringLength > 2) nMonth = parseInt((parseInt(strDate.substr(2,1)) == 0) ? strDate.substr(3,1) :strDate.substr(2,2));
		if(nStringLength > 4) nYear = parseInt(strDate.substr(4));
	}
	else {
		var strD = arrDate[0];
		nDay = parseInt(strD.length == 1 ? strD : (parseInt(strD) == 0 ? strD.substr(1,1) : strD));
		
		var strM = arrDate[1];
		nMonth = parseInt(strM.length == 0 ? -1 : (strM.length == 1 ? strM : (parseInt(strM) == 0 ? strM.substr(1,1) : strM)));
		
		if(nArrLength == 3){
			var strY = arrDate[2];
			nYear = parseInt(strY.length == 0 ? -1 : (strY.length == 1 ? strY : (parseInt(strY.substr(0,1)) == 0 ? strY.substr(1) : strY)));
		}
	}
	if(nDay == 0 || nDay > 31) return '';
	if(nMonth == -1) {
		//nMonth = nDay >= nCurrentDay ? nCurrentMonth : (nCurrentMonth + 0) % 13;
	    nMonth = nCurrentMonth
	}
	else if(nMonth == 0 || nMonth > 12) return '';
	
	var bSet = false;
	if (nYear > 0){
	if (nYear < 100){
	    if (nYear > nAutoMinYear){
		   	nYear += 1900;
	    }
	    if (nYear < nAutoMinYear){
			nYear += 2000;
	    }
    }
    }

	//if(nYear == -1) nYear = nMonth > nCurrentMonth || nMonth == nCurrentMonth && nDay >= nCurrentDay ? nCurrentYear : nCurrentYear ;
    if(nYear == -1) nYear = nCurrentYear;
	
	if(!isValidDate(nDay, nMonth, nYear)) return '';
	
	return dateToString(nDay, nMonth, nYear);
}
function dateToString(nDay, nMonth, nYear){
	var strDay;
	var strMonth;
		
	if(nDay < 10)
		strDay = "0" + nDay;
	else
		strDay = "" + nDay;
		
	if(nMonth < 10)
		strMonth = "0" + nMonth;
	else
		strMonth = "" + nMonth;
	
	return strDay + "." + strMonth + "." + nYear;
}
function isValidDate(nDay, nMonth, nYear) {
	if(nDay < 1 || nDay > 31 || nMonth < 1 || nMonth > 12 || (nYear < 1000)) return false;
	return nDay <= (nMonth == 2 ? nYear % 400 == 0 ? 29 : nYear % 100 == 0 ? 28 : nYear % 4 == 0 ? 29 : 28 : (nMonth == 4 || nMonth == 6 || nMonth == 9 || nMonth == 11) ? 30 : 31);
}

