﻿// JScript File
function getXmlHttpRequestObject() 
{

    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    } else if(window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        alert('Please update your browser to the latest verson of IE or Firefox');
    }
}

function show(obj)
{
   document.getElementById(obj.id);
   obj.style.visibility = "visible";
   obj.style.position = 'relative';
     
}

function hide(obj)
{
    obj.style.visibility = 'hidden';
    obj.style.position = 'absolute';
}

function hideOrShow(obj)
{
    if (obj.style.visibility == 'visible') {
    hide(obj);
}
    else {
    show(obj);
    }
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}  

function change(id, newClass) {

    identity=document.getElementById(id);

    identity.className=newClass;

}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

    function removeDefaultText(ctl,defaultText){
    
    for(i=0; i<document.aspnetForm.elements.length; i++) {
					
					var o = document.aspnetForm.elements[i];
					
					if(o.type == "text" || o.type == "textarea" ) {
						if(o.id.indexOf(ctl) > 0) {
						
							if(o.value == defaultText){
							
                                o.value = '';
                                o.style = '';
                               }
                            }
						}
					}
				}
    
    
function spellCheck(ctlName){

    var oSpell= new JavaScriptSpellCheck(); 
    oSpell.spellCheckWindow(ctlName);


}

    function tickAll() {
				
		
				
				var bSelected = document.aspnetForm.chkHead.checked;
				
				//select all checkboxes that have the name "cbkDelete" in the ID element
				for(i=0; i<document.aspnetForm.elements.length; i++) {
					
					var o = document.aspnetForm.elements[i];
					if(o.type == "checkbox") {
						if(o.id.indexOf("cbxDelete") > 0) {
						
							o.checked = bSelected;
						}
					}
				}
			}
			

			
function ShowHelp(theURL,features) { //v2.0
  window.open(theURL,'help',features);
}

function WriteComment_photo()
{

    var intfk_id;
    var intprofileid;
    var strcommenttext;
    var commenttype;
    var strReturn;
    var returnedXml;
    var http = new getXmlHttpRequestObject();
    var url = "web20.aspx";
    var params;
    
    intfk_id = document.getElementById('_ctl0_CPH_Main_BigImage_Comments_hCommentId').value;
    intprofileid = document.getElementById('_ctl0_CPH_Main_BigImage_Comments_PID').value
    strcommenttext = document.getElementById('_ctl0_CPH_Main_BigImage_Comments_txtComment').value
    commenttype = document.getElementById('_ctl0_CPH_Main_BigImage_Comments_hCommentType').value
  
    params = "fk_id=" + intfk_id + "&profileId=" + intprofileid + "&commentType=" + commenttype + "&CommentText=" + strcommenttext;
     
    http.open("POST", url, true);

    //Send the proper header information along with the request
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", params.length);
    http.setRequestHeader("Connection", "close");
    
    http.onreadystatechange = function() 
    {//Call a function when the state changes.
	    if(http.readyState == 4 && http.status == 200) 
	    {
	        //returnedXml = http.responseXML;
		    strReturn = http.responseTEXT //returnedXml.getElementsByTagName('boolean')[0].firstChild.data;
		    
		    if (strReturn == "true") 
	            {
	                hideOrShow(Good);
                } 
                else
                {
                    hideOrShow(Bad);
                }
		    
	    }
	    else
	    {
	    //error
	    
	    }
	}
  http.send(params);
     
}


function WriteComment_profile()
{
    var intfk_id;
    var intprofileid;
    var strcommenttext;
    var commenttype;
    var strReturn;
    
   
    intfk_id = document.aspnetForm._ctl0_CPH_Main_Comments_hCommentId.value
    intprofileid = document.aspnetForm._ctl0_CPH_Main_Comments_PID.value
    strcommenttext = document.aspnetForm._ctl0_CPH_Main_Comments_txtComment.value
    commenttype = document.aspnetForm._ctl0_CPH_Main_Comments_hCommentType.value
    
    /* Setup call to Web Service */
	objCall = DOMService.createCallOptions();
	objCall.async = false;
	objCall.funcName = "WriteComment"
	
	/* Pass category */	
	objCall.params = new Array();
	objCall.params.fk_id = intfk_id;
	objCall.params.profileId = intprofileid;
	objCall.params.CommentText = strcommenttext;
	objCall.params.commentType = commenttype;
	
	/* Call Web Service */
	strReturn = DOMService.Services.callService(objCall);
	
	document.aspnetForm._ctl0_CPH_Main_Comments_txtComment.value =''
	
	if (strReturn.value == false) {
	   hideOrShow(Bad);
    } 
	else 
	{
	     hideOrShow(Good);
	}
	
}



function RegisterAction(viewer, profile, Type, id)
{

    var method;
    var strReturn;
    var returnedXml;
    var http = new getXmlHttpRequestObject();
    var url = "web20.aspx";
    var params = "viewerId=" + viewer + "&profileId=" + profile + "&MatchType=" + Type;
   
    http.open("POST", url, true);

    //Send the proper header information along with the request
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", params.length);
    http.setRequestHeader("Connection", "close");

    switch(Type)
	{
	    case 1 : method = 'Date request sent on ' ;break
	    case 2 : method = 'Mate request sent on ' ;break
	    case 3 : method = 'Shortlisted on ' ;break
	    case 4 : method = 'Interest Sent on ' ;break
	}          

    http.onreadystatechange = function() 
    {//Call a function when the state changes.
	    if(http.readyState == 4 && http.status == 200) 
	    {
		  
		    //returnedXml = http.responseXML;
		    strReturn = http.responseTEXT //returnedXml.getElementsByTagName('boolean')[0].firstChild.data;
		  
		        if (strReturn == "true") 
	            {
	                if (document.all) 
	                { // IE;
	                    document.getElementById(id).innerText = method + GetDate();
	                }
	                else
	                {
	                    if (obj.textContent) 
                        {
	                    document.getElementById(id).textContent = method + GetDate();
	                    }
	                    else
	                    {
	                    alert("Error: This application does not support your browser. Try again using IE or Firefox."); 
	                    }
	                }
                } 
	            else 
	            {
	                if (document.all) 
	                { // IE;
	                    document.getElementById(id).innerText = 'Could not add';
	                 }
	                else
	                {
	                    if (obj.textContent) 
                        {
	                    document.getElementById(id).textContent = 'Request could not be added';
	                    }
	                    else
	                    {
	                    alert("Error: This application does not support your browser. Try again using IE or Firefox."); 
	                    }
	                }
	            }
                	
	    }
	    else
	    {
	        document.getElementById(id).innerText = document.getElementById(id).innerText + ' Could not add';
	    }
    }

   http.send(params);

}

function RegisterSendInterest(viewer, profile)
{
  
    var strScreenName = document.getElementById('_ctl0_CPH_Main_txtScreenName').value;
    var strReturn;
    var returnedXml;
    var http = getXmlHttpRequestObject();
    var url = "web20.aspx?method=";
    var params = "viewerId=" + viewer + "&profileId=" + profile;
    
    http.open("POST", url, true);

    //Send the proper header information along with the request
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", params.length);
    http.setRequestHeader("Connection", "close");

    http.onreadystatechange = function() {//Call a function when the state changes.
	    if(http.readyState == 4 && http.status == 200) {
		   
		    returnedXml = http.responseXML;
		    strReturn = returnedXml.getElementsByTagName('boolean')[0].firstChild.data;
		    
		      if (strReturn.value == "true") 
		      {
	                document.all.LinkInterest.innerText = 'Interest Sent on ' + GetDate();
                    document.all.LinkInterest.stule = 'GoodToGoScreenText';
              } 
	          else 
	          {
	                document.all.LinkInterest.innerText = document.all.LinkInterest.innerText + ' Could not add';
	          }
                	
	    }
    }

   http.send(params);
  
   
}

function GetDate()
{
    var dt = new Date();
    var d = dt.getDate(); 
    var m = dt.getMonth();
    var y  = dt.getYear();

    // Y2K compliant
    if (y < 1000) y +=1900;

    return d + "/" + m  + "/" + y 
}

function CheckScreenName2()
{

    var strScreenName = document.getElementById('_ctl0_CPH_Main_txtScreenName').value;
    var strReturn;
    //var returnedXml;
    var http = getXmlHttpRequestObject();
    var url = "web20.aspx"
    var params = "ScreenName=" + strScreenName;
    http.open("POST", url, true);

    //Send the proper header information along with the request
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", params.length);
    http.setRequestHeader("Connection", "close");

    http.onreadystatechange = function() {//Call a function when the state changes.
    
	    if(http.readyState == 4 && http.status == 200) {
		   
		    strReturn = http.responseText
		   
		       if (strReturn == "false") 
		       {
	                
	                hideOrShow(SNGood);
               } 
	                else 
	           {
	                
	                hideOrShow(SNBad);
	           }
	    }
    }

   http.send(params);

}
    function hideHistory(URL){
      window.location.replace(URL);
    }
    
    function WindowSize(){
      var winW = 630, winH = 460;

        if (parseInt(navigator.appVersion)>3) {
         if (navigator.appName=="Netscape") {
          winW = window.innerWidth;
          winH = window.innerHeight;
         }
         if (navigator.appName.indexOf("Microsoft")!=-1) {
          winW = document.body.offsetWidth;
          winH = document.body.offsetHeight;
         }
        }

        document.all.OnlineUsersDiv.style.left = winW - 223;
        document.all.OnlineUsersDiv.style.top = 5;

    }
   
    
    function GetBanner(Size)
    {
    var bnum = new Number(Math.floor(99999999 * Math.random())+1);
    var http = getXmlHttpRequestObject();
    var url = "GeoBanners.aspx?Size=" + Size + "&dummy=" + bnum;
    var params = "size=" + Size;
    
    http.open("GET", url, true);

    document.getElementById("468X60Banner").innerHTML = '';

    //Send the proper header information along with the request
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", params.length);
    http.setRequestHeader("Connection", "close");

    http.onreadystatechange = function() 
        {//Call a function when the state changes.
	        if(http.readyState == 4 && http.status == 200) 
	        {
		        //document.write(http.responseTEXT)
		        
		        if (http.responseTEXT == '')
		        {
		            
		        }
		        else
		        {
		            document.getElementById("468X60Banner").innerHTML  = http.responseTEXT
		            setTimeout('GetBanner(' + 1 + ');',30000);   
		        } 
		        
		    }
        }
        
        http.send();
    
         
      }