﻿//Global Variables
var img1,img2,img3,img4;
var img1_h,img2_h,img3_h,img4_h;
var over_search;
var out_search;
var hideme,hideme_hover;
var showme,showme_hover;

// JScript File
function $(Id)
{
    return document.getElementById(Id);
}
function $C(Id)
{
    return document.createElement(Id);
}
//try to stop key pressing "'" character
function keyStop(e)
{
  var keyHit = e ? e.which : window.event.keyCode;
  if (keyHit == 39)
    {
     return keyHit != 39;
    }
}
function alwaysCapital(e)
{
keyStop(e);
var keyHit = e ? e.which : window.event.keyCode;
if (keyHit >= 97 && keyHit<=122)
    {
     return keyHit -=32;
    }
 }
function RemoveAllChild(cell)
{
    //var cell = $("cell");
    if (cell.hasChildNodes())
    {
        while ( cell.childNodes.length >= 1 )
        {
            cell.removeChild( cell.firstChild );       
        } 
    }
 }
function SetSelected(combo,preSelect)
{
    for (var i=0; i < combo.options.length; i++) 
    {
        if (combo.options[i].text == preSelect) 
        {
           combo.options[i].selected = true;
        }
    }
}
function ShowSelVal(combo)
{
    var selVal='';
    for (var i=0; i < combo.options.length; i++) 
    {
        if (combo.options[i].selected == true) 
        {
           selVal+="\n-" + combo.options[i].text;
        }
    }
   return 'Selected Areas (Use ctrl or shift for multiple selection_:' + selVal + '';
}
function GetAllValuesFromList(combo)
{
    var selVal='';
    
    for (var i=0; i<combo.options.length; i++) 
    {
           if (selVal!="") selVal+= ",";
           selVal += combo.options[i].value;
    }
   return selVal;
}
function get_cookie(Name) 
{ 
    var search = Name + "="
    var returnvalue = "";
    if (document.cookie.length > 0) 
    {
        offset = document.cookie.indexOf(search)
        if (offset != -1) 
        { 
            offset += search.length
            end = document.cookie.indexOf(";", offset);
            if (end == -1) end = document.cookie.length;
            returnvalue=unescape(document.cookie.substring(offset, end))
        }
     }
    return returnvalue;
}
function set_cookie(Name,Value)
{
    document.cookie=Name+"="+Value;
}

function fillDay(cmb)
{ 
    cmb.options.length=0;
    var opt=$C('OPTION');
    cmb.options.add(opt);
    opt.text='DD';
    opt.value=0;
    for(var i=1; i<=31; i++)
    {
        var opt=$C('OPTION');
        cmb.options.add(opt);
        opt.text=i;
        opt.value=i;
    }   
}
function fillMonth(cmb)
{ 
    var mth=new Array("MMM","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
    cmb.options.length=0;
    for(var i=0; i<=12; i++)
    {
        var opt=$C('OPTION');
        cmb.options.add(opt);
        opt.text=mth[i];
        opt.value=i;
    }   
}
function fillYear(cmb)
{ 
    cmb.options.length=0;
    var opt=$C('OPTION');
    cmb.options.add(opt);
    opt.text='YYYY';
    opt.value=0;
    for(var i=2008; i<=2020; i++)
    {
        var opt=$C('OPTION');
        cmb.options.add(opt);
        opt.text=i;
        opt.value=i;
    }   
}
function fillHr(cmb)
{ 
    cmb.options.length=0;
    var opt=$C('OPTION');
    cmb.options.add(opt);
    opt.text='HH';
    opt.value=0;
    for(var i=1; i<=12; i++)
    {
        var opt=$C('OPTION');
        cmb.options.add(opt);
        opt.text=i;
        opt.value=i;
    }   
}

function fillMin(cmb)
{ 
    cmb.options.length=0;
    var opt=$C('OPTION');
    cmb.options.add(opt);
    opt.text='MM';
    opt.value=0;
    for(var i=5; i<=60; i+=5)
    {
        var opt=$C('OPTION');
        cmb.options.add(opt);
        opt.text=i;
        opt.value=i;
    }   
}
function fillAP(cmb)
{ 
    cmb.options.length=0;
    var opt=$C('OPTION');
    cmb.options.add(opt);
    opt.text='AM';
    opt.value=0;
    var opt=$C('OPTION');
    cmb.options.add(opt);
    opt.text='PM';
    opt.value=0;
}
//check for date
function isDate(obj){
	var dteDate;
	obj1 = obj.split("/"); 
	obj1[0] = parseInt(obj1[0], 10)-1; //for javascript 0=>January!
	obj1[1] = parseInt(obj1[1], 10);
	obj1[2] = parseInt(obj1[2], 10);
	dteDate=new Date(obj1[2], obj1[0], obj1[1]);
	return ((obj1[1]==dteDate.getDate()) && (obj1[0]==dteDate.getMonth()) && (obj1[2]==dteDate.getFullYear()));
}

function isFutureDate(obj){
	var dteDate;
	var now = new Date();
	obj1 = obj.split("/"); 
	obj1[0] = parseInt(obj1[0], 10)-1;
	obj1[1] = parseInt(obj1[1], 10);
	obj1[2] = parseInt(obj1[2], 10);
	dteDate=new Date(obj1[2], obj1[0], obj1[1]);
	return now > dteDate;
}

function CheckFutureDate(obj){
    var isDt=isDate(obj);
    if(isDt)
    {
        var isfDt=isFutureDate(obj);
        if(!isfDt){
            alert("You have to use a future date");
            return false;
        }
    }
    else
    {
        alert("Date format is not correct");
        return false;
    }
    return true;
}

function extractNumber(obj, decimalPlaces, allowNegative)
{
	var temp = obj.value;
	
	// avoid changing things if already formatted correctly
	var reg0Str = '[0-9]*';
	if (decimalPlaces > 0) {
		reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
	} else if (decimalPlaces < 0) {
		reg0Str += '\\.?[0-9]*';
	}
	reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
	reg0Str = reg0Str + '$';
	var reg0 = new RegExp(reg0Str);
	if (reg0.test(temp)) return true;

	// first replace all non numbers
	var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
	var reg1 = new RegExp(reg1Str, 'g');
	temp = temp.replace(reg1, '');

	if (allowNegative) {
		// replace extra negative
		var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
		var reg2 = /-/g;
		temp = temp.replace(reg2, '');
		if (hasNegative) temp = '-' + temp;
	}
	
	if (decimalPlaces != 0) {
		var reg3 = /\./g;
		var reg3Array = reg3.exec(temp);
		if (reg3Array != null) {
			// keep only first occurrence of .
			//  and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
			var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
			reg3Right = reg3Right.replace(reg3, '');
			reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
			temp = temp.substring(0,reg3Array.index) + '.' + reg3Right;
		}
	}
	
	obj.value = temp;
}
function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
		
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	if (isNaN(key)) return true;
	
	keychar = String.fromCharCode(key);
	
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl)
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	
	return isFirstN || isFirstD || reg.test(keychar);
} 

/*
Form field Limiter script- By Dynamic Drive
For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
This credit MUST stay intact for use
*/

var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}


function displaylimit(theform, thelimit)
{
    var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> characters left'
        if (document.all||ns6)
        document.write(limit_text)
        if (document.all){
        eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
        eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
    }
    else if (ns6){
        document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
        document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
    }
}

function mailcheck(str) 
{
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		var strval = lstr-1;
	
	    	                   
		if (str.indexOf(at)==-1)
		{
		   alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
		    alert("Invalid E-mail ID");
		    return false;
		}

		 if (str.indexOf(at,(lat+2))!=-1)
		 {
		    alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		 {
		    alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1)
		 {
		    alert("Invalid E-mail ID");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1)
		 {
		    alert("Invalid E-mail ID");
		    return false;
		 }
		
		 if (strval == ldot)
		 {
			
			alert("Invalid E-mail ID");
			return false;
		 }	
 		 return true;					
}
function rm_trim(inputString)
{
        if (typeof inputString != "string") { return inputString; }

        var temp_str = '';
        temp_str = inputString.replace(/[\s]+/g,"");
        if(temp_str == '')
                return "";

        var retValue = inputString;
        var ch = retValue.substring(0, 1);
        while (ch == " ")
        {
                retValue = retValue.substring(1, retValue.length);
                ch = retValue.substring(0, 1);
        }
        ch = retValue.substring(retValue.length-1, retValue.length);
        while (ch == " ")
        {
                retValue = retValue.substring(0, retValue.length-1);
                ch = retValue.substring(retValue.length-1, retValue.length);
        }
        while (retValue.indexOf("  ") != -1)
        {
          retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
        }
        return retValue;
}

//related to hint box
function showhint(menucontents, objId, tipwidth){
    
	var obj = document.getElementById(objId);
	
	if ( obj.tagName.toString().toLowerCase().indexOf('input') > -1 || obj.toString().indexOf('HTMLInputElement') > -1 ) {
		if( rm_trim(obj.value).toString().length > 0 ) {
			return;
		}
	} else if ( obj.tagName.toString().toLowerCase().indexOf('select') > -1  || obj.toString().indexOf('HTMLSelectElement') > -1 ) {
		if ( obj.selectedIndex > 0 ) {
			return
		}
	} else if( obj.tagName.toString().toLowerCase().indexOf('textarea') > -1 || obj.toString().indexOf('HTMLTextAreaElement') > -1) {
		if ( rm_trim(obj.value).toString().length > 0 ) {
			return ;
		}
	} else { alert('no match found'); }

	if ((ie||ns6) && document.getElementById("hintbox")){
		dropmenuobj=document.getElementById("hintbox")
		menucontents="<div id=new_>"+ menucontents +"<div style='position:absolute; left:-9px; bottom:5px;'><img src='images/arrow2.gif' /></div></div>"
		dropmenuobj.innerHTML=menucontents
		dropmenuobj.style.left=dropmenuobj.style.top=-500
		if (tipwidth!=""){
			dropmenuobj.widthobj=dropmenuobj.style
			dropmenuobj.widthobj.width=tipwidth
		}
		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
		dropmenuobj.style.visibility="visible"
		obj.onblur="hidetip()"
	}
}

function hidetip(){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}
                 
var horizontal_offset="6px" //horizontal offset of hint box from anchor link

var vertical_offset="-10px"                 
var ie=document.all
    var ns6=document.getElementById && !document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;}
return totaloffset;
}
function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y > dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function moveOptions(theSelFrom, theSelTo)
{	
//alert("JSU");
	var selLength = theSelFrom.length;
	var selectedText = new Array();
	var selectedValues = new Array();
	var selectedCount = 0;
	var cou1=1;
	var adflag=0;
	
	var i;
	for(i=selLength-1; i>=0; i--)
	{
	    
		if(theSelFrom.options[i].selected){
		    
			for(j=0;j<theSelTo.length;j++){
				cou1=1;
				
				if(theSelTo.options[j].text==theSelFrom.options[i].text)
				{cou1=0;}
			}			
			if (cou1==1) {
				selectedText[selectedCount] = theSelFrom.options[i].text;
				selectedValues[selectedCount] = theSelFrom.options[i].value;
				selectedCount++;
			}
			
	
		}			
	}	
	
	if (theSelTo.length>0){
			for(i=selectedCount-1; i>=0; i--){	
				adflag=0;
				for (j=0;j<theSelTo.length;j++ ){
					if(selectedText[i]==theSelTo.options[j].text && adflag==0)
					{adflag=1;}
				}
				if(adflag==0){addOption(theSelTo, selectedText[i], selectedValues[i]);}
			}
	}else{
		for(i=selectedCount-1; i>=0; i--){ 
			addOption(theSelTo, selectedText[i], selectedValues[i]);
		}	
	}
//	if(NS4) history.go(0);
//	stateSelection(theSelTo);
}

function RemoveSelected(theSelFrm)
{
   var selLength = theSelFrom.length;
   
}

function hideSearch()
{ 
    var d=document.getElementById('searchTab');
    var h=document.getElementById('hideme_');
    if ((d.style.display=='block') || (d.style.display==''))
        { d.style.display='none'; 
          h.src=showme;  
          //h.alt="Show Search Options";
          h.onmouseover='HoverImage("hideme_",showme_hover)';
          h.onmouseout='HoverImage("hideme_",showme)';
          //h.style.position='absolute';
          
          set_cookie('SearchOpt','hide');
        } 
    else 
        { 
          d.style.display='block'; 
          h.src=hideme;  
          //h.alt="Hide Search Options";
          h.onmouseover="HoverImage('hideme_',hideme_hover)";
          h.onmouseout="HoverImage('hideme_',hideme)";
          //h.style.position='';                    
          set_cookie('SearchOpt','unhide');
        } 
}
function HoverImage(id,imgTo)
{
    document.getElementById(id).src=imgTo;
}
//function callMe(idName,noteId){	
//	var divObj = null;
//	var noteDivObj = null;
//	imgName = idName;
//	noteName = noteId;
//	try{
//		divObj = eval('document.'+idName);//document.getElementByName(idName);
//		if(divObj!=null){
//			divObj.src = "http://static.m4marry.com/m4marry/images/add_animation.gif";
//		}
//		noteDivObj = document.getElementById(noteId);
//		if(noteDivObj!=null){
//			noteDivObj.style.visibility = "visible";
//		}
//		//alert("JSU"+noteId);
//	}catch(error){
//		//alert("JSU"+error.description);
//	}
function addOption(cmb,addText,addVal)
{
    var opt=$C('OPTION');
        cmb.options.add(opt);
        opt.text=addText;
        opt.value=addVal;
        }
        
function removeOptionSelected(elSel)
{
  var i;
  for (i = elSel.length - 1; i>=0; i--) {
    if (elSel.options[i].selected) {
      elSel.remove(i);
    }
  }
 }
 function ListBoxChanged(elSel,HidenFld)
{
    HidenFld.value='';
    var i;
      for (i = elSel.length - 1; i>=0; i--) {
        if (HidenFld.value!='') HidenFld.value = HidenFld.value + ",";
        HidenFld.value = HidenFld.value + elSel.options[i].value;
        }
}


function SetToggle(obj1,obj2,whichObj){
    
  if (whichObj==obj1){
    if (obj1.checked) obj2.checked=false; else obj2.checked=true;
  }
  
  if (whichObj==obj2){
    if (obj2.checked) obj1.checked=false; else obj1.checked=true;
  }
}
//function CheckSearch(agefr,ageto,htfrm,htto)
//        {
//            
//            if ((agefr.selectedIndex>ageto.selectedIndex)) 
//            {
//                alert("Age From cannot be greater than Age to");
//                agefr.focus()
//                return false;
//            }
//            
//            if ((agefr.selectedIndex>0) && (ageto.selectedIndex==0)) 
//            {
//                alert("Select Age To also");
//                ageto.focus()
//                return false;
//            }
//            
//            if ((agefr.selectedIndex==0) && (ageto.selectedIndex>0)) 
//            {
//                alert("Select Age From also");
//                agefr.focus()
//                return false;
//            }
//            
//            
//            if ((htfrm.selectedIndex>htto.selectedIndex)) 
//            {
//                alert("Height from cannot be greater the Height to");
//                htfrm.focus();
//                return false;
//            }
//            
//            if ((htfrm.selectedIndex>0) && (htto.selectedIndex==0))  
//            {
//                alert("Please Select Height To also");
//                htto.focus();
//                return false;
//            }
//            if ((htfrm.selectedIndex==0) && (htto.selectedIndex>0)) 
//            {
//                alert("Please Select Height From also");
//                htfrm.focus();
//                return false;
//            }
//            
//            return true;
//        }
        
        
        <!--

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Right click Disabled!";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

// --> 

 function ChatAlertPopup()
           {
                var c=document.getElementsByName("Chatter");
                if (c==null) return;
                if (c.length==0) return;
                var ch=document.getElementById("Chat_drop");
                if (ch.style.visibility=="visible") return;
                document.getElementById('fadeinbox').innerHTML= '<b> '  + c.length + ' ' + ((c.length==1)?'user</b> is':'users</b> are')  + '  waiting to chat with you..<br/><br/>Please click on Chatters Online and reply...<div align="right"> <a href="#" onClick="hidefadebox();return false">Hide Box</a></div>';
                displayfadeinbox();
                document.all.beep.src='beep.wav';
            }
            
 function PreLoad()
        {
                   
            img1="images/Home_Mnu.gif";img1_h="images/Home_Mnu_hover.gif";
            img2="images/Search_Mnu.gif";img2_h="images/Search_Mnu_hover.gif";
            img3="images/Contact_Mnu.gif";img3_h="images/Contact_Mnu_hover.gif";
            img4="images/Add_profile_Mnu.gif";img4_h="images/Add_profile_Mnu_hover.gif";            
            over_search='images/search_but.gif';
            out_search='images/search_but1.gif';
            hideme='images/hide.gif';
            hideme_hover='images/hide_hover.gif';
            showme='images/show.gif';
            showme_hover='images/show_hover.gif';            
        }
   function LoadMessage(msg)
        {
            document.getElementById('spanLoad').innerHTML=msg;
        }
        
   function include(file) { 
        var script = document.createElement('script'); 
        script.src = file; 
        script.type = 'text/javascript'; 
        script.defer = true; 
        document.getElementsByTagName('head').item(0).appendChild(script); 
    }
    
