// JavaScript Document
// This website Fully Engineered By Michael John Mikhjian
//setInterval("scrollingDetector()", 250);

function testrun(){
	alert("This is just a test!");
}

//document.onkeypress = escaperr;
//function escaperr(){
	
function dphoto(i){
	document.getElementById('photoviewer').style.visibility='visible';
	document.getElementById('photoviewer').innerHTML = "<div style='overflow:hidden; height:100%' onclick='hphoto()'><img src='users/"+i+"' style='width:90%' onclick='hphoto()'></div><div style='position:absolute; bottom:0px; text-align:center; font-size:11px; height:20px; background-color:white; width:100%' onclick='hphoto()'>(close)</div>";
}

function hphoto(){document.getElementById('photoviewer').style.visibility='hidden';}

function showme(i){
	document.getElementById('comments').style.display='none';
	document.getElementById('aboutme').style.display='none';
	document.getElementById('blog').style.display='none';
	document.getElementById('photos').style.display='none';
	document.getElementById('blogsingle').style.display='none';
	document.getElementById('addfriend').style.display='none';
	document.getElementById('votenow').style.display='none';
	document.getElementById(i).style.display='block';
}

function remmsg(i){
	to = confirm("Are you sure you want to delete this message?");
	if(to){location.href='inbox.php?del=1&id=' + i}
}
function votenow(){document.getElementById('votenow').style.display='block'; document.getElementById('darke').style.visibility='visible'; rez(); if(window.devicePixelRatio){resSF();}}

function addfriend(){document.getElementById('addfriend').style.display='block'; document.getElementById('darke').style.visibility='visible'; rez(); if(window.devicePixelRatio){resSF();}}

function sndmsg(){document.getElementById('sndmsg').style.display='block'; document.getElementById('darke').style.visibility='visible'; rez(); if(window.devicePixelRatio){resSF();}}

function sndrep(){document.getElementById('sndmsg').style.display='block'; }

function hidepop(){document.getElementById('darke').style.visibility='hidden'; document.getElementById('votenow').style.display='none'; document.getElementById('sndmsg').style.display='none'; document.getElementById('loginpopup').style.display='none'; document.getElementById('addfriend').style.display='none'; }

function logmen(){document.getElementById('loginpopup').style.display='block'; document.getElementById('darke').style.visibility='visible'; rez(); if(window.devicePixelRatio){resSF();}}

function SendV(uid,fid,ti){
		var ajaxRequest;    
		try{
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					alert("Ajax is required for this function to work!");
					return false;
				}
			}
		}
	
		ajaxRequest.onreadystatechange = function(){
		   if(ajaxRequest.readyState == 4){
			   document.getElementById('votenow').innerHTML = ajaxRequest.responseText;
			   var t=setTimeout("hidepop()",2000);
		   }
		 }
		 
		document.getElementById('votenow').innerHTML = "<div style='margin-top:70px'><img src='images/load1.gif' alt='loading...' /><BR>Sending Vote.</div>";
		ajaxRequest.open("GET", "sendvote.php?uid=" + uid + "&fid=" + fid + "&ti=" + ti);
		ajaxRequest.send(null);
}

function SendE(uid,fid,ti,i){
		var ajaxRequest;    
		try{
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					alert("Ajax is required for this function to work!");
					return false;
				}
			}
		}
	
		ajaxRequest.onreadystatechange = function(){
		   if(ajaxRequest.readyState == 4){
			   document.getElementById('votenow' + i).innerHTML = ajaxRequest.responseText;
			   //var t=setTimeout("hidepop()",2000);
		   }
		 }
		 
		document.getElementById('votenow' + i).innerHTML = "Sending Vote...</div>";
		ajaxRequest.open("GET", "sendEvote.php?uid=" + uid + "&fid=" + fid + "&ti=" + ti);
		ajaxRequest.send(null);
}

function SendF(uid,fid){
		var ajaxRequest;    
		try{
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					alert("Ajax is required for this function to work!");
					return false;
				}
			}
		}
	
		ajaxRequest.onreadystatechange = function(){
		   if(ajaxRequest.readyState == 4){
			   document.getElementById('addfriend').innerHTML = ajaxRequest.responseText;
			   var t=setTimeout("hidepop()",2000);
		   }
		 }
		 
		document.getElementById('addfriend').innerHTML = "<div style='margin-top:70px'><img src='images/load1.gif' alt='loading...' /><BR>Adding Friend.</div>";
		ajaxRequest.open("GET", "addfriend.php?uid=" + uid + "&fid=" + fid);
		ajaxRequest.send(null);
}

function sendncomment(m,uid,fid){
//var m = escape(m);
	if(m!=""){
		var ajaxRequest;    
		try{
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					alert("Ajax is required for this function to work!");
					return false;
				}
			}
		}
	
		ajaxRequest.onreadystatechange = function(){
		   if(ajaxRequest.readyState == 4){
			  document.getElementById('nco').innerHTML = ajaxRequest.responseText;
		   }
		 }
		 
		document.getElementById('nco').innerHTML = "<div style='text-align:center'><img src='images/load1.gif' alt='loading...' /></div>";
		ajaxRequest.open("GET", "ncomment.php?m=" + m + "&uid=" + uid + "&fid=" + fid);
		ajaxRequest.send(null);
	}
	else{alert('You\'re required to fill out the text if you want to add a comment.');}
}


function SendM(s,m,uid,fid){
	if(s!="" && m!=""){
		var ajaxRequest;    
		try{
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					alert("Ajax is required for this function to work!");
					return false;
				}
			}
		}
	
		ajaxRequest.onreadystatechange = function(){
		   if(ajaxRequest.readyState == 4){
			   document.getElementById('sndmsg').innerHTML = ajaxRequest.responseText;
			   var t=setTimeout("hidepop()",2000);
		   }
		 }
		 
		document.getElementById('sndmsg').innerHTML = "<div style='margin-top:130px'><img src='images/load1.gif' alt='loading...' /><BR>Sending Message</div>";
		ajaxRequest.open("GET", "sendmsg.php?s=" + s + "&m=" + m + "&uid=" + uid + "&fid=" + fid);
		ajaxRequest.send(null);
	}
	else{alert('You\'re required to fill out the subject and message to send a message.');}
}

function readblog(i){
	
	showme('blogsingle');
	
	var ajaxRequest;    
    try{
        ajaxRequest = new XMLHttpRequest();
    } catch (e){
        try{
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try{
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e){
                alert("Ajax is required for this function to work!");
                return false;
            }
        }
    }

    ajaxRequest.onreadystatechange = function(){
       if(ajaxRequest.readyState == 4){
           document.getElementById('blogsingle').innerHTML = ajaxRequest.responseText;
       }
     }
	 
	document.getElementById('blogsingle').innerHTML = "Loading blog entry...";
    ajaxRequest.open("GET", "readblog.php?id=" + i);
    ajaxRequest.send(null);
}

function searchreq(ta){
	if(ta=="band"){
	a = document.getElementById('country').value; b = document.getElementById('state').value; c = document.getElementById('genre').value; d = document.getElementById('name').value; e = document.getElementById('mx').value;
	document.location.href="?country=" + a + "&state=" + b + "&genre=" + c + "&name=" + d + "&s=" + e;
	}
	if(ta=="models"){
	a = document.getElementById('country').value; b = document.getElementById('state').value; c = document.getElementById('gender').value; d = document.getElementById('name').value; e = document.getElementById('mx').value;
	document.location.href="?country=" + a + "&state=" + b + "&gender=" + c + "&name=" + d + "&s=" + e;
	}
	if(ta=="profile"){
	a = document.getElementById('country').value; b = document.getElementById('state').value; c = document.getElementById('email').value; d = document.getElementById('name').value; e = document.getElementById('mx').value;
	document.location.href="?country=" + a + "&state=" + b + "&email=" + c + "&name=" + d + "&s=" + e;
	}
}

function resSF(){
	if(document.getElementById('blankbody').offsetHeight >= 340){ns = 180;}
	document.getElementById('darke').style.height=document.height + 'px';
	document.getElementById('footer').style.top=document.height + 150  + 'px';
	document.getElementById('nmember').style.top=document.height - 180 +  'px';
	document.getElementById('blankfooter').style.top=document.getElementById('blankbody').offsetHeight +  220 + 'px';
}

function res(){
	ns=0;
	if(document.getElementById('blankbody').offsetHeight >= 340){ns = 180;}
	document.getElementById('darke').style.height=document.documentElement.scrollHeight + 'px';
	document.getElementById('footer').style.top=document.documentElement.scrollHeight + ns + 'px';
	document.getElementById('nmember').style.top=document.documentElement.scrollHeight - 180 +  'px';
	document.getElementById('blankfooter').style.top=document.getElementById('blankbody').offsetHeight +  220 + 'px'; 
}

function resIE(){
	ns=0;
	if(document.getElementById('blankbody').offsetHeight >= 340){ns = 180;}
	document.getElementById('darke').style.height=document.documentElement.scrollHeight + 'px';
	document.getElementById('footer').style.top=document.documentElement.scrollHeight + ns + 'px';
	document.getElementById('nmember').style.top=document.documentElement.scrollHeight - 180 +  'px';
	document.getElementById('blankfooter').style.top=document.getElementById('blankbody').offsetHeight +  220 + 'px'; 
}

function rez(){
	document.getElementById('darke').style.height=document.documentElement.scrollHeight + 'px';
	document.getElementById('darke').style.width=document.documentElement.clientWidth + 'px';
	document.getElementById('darke').style.left='50%';
	document.getElementById('darke').style.marginLeft = -2 - document.documentElement.clientWidth/2 + 'px';
}

function sign(){
	if(document.newuser.term.checked){
		if(document.newuser.newemail.value != ""
		   &&
		   document.newuser.pass.value != ""
		   &&
		   document.newuser.name.value != ""
		   &&
		   document.newuser.ve.value != ""
		   &&
		   document.newuser.country.value != "--"
		   ){
			setupnewuser();
		}
		else{alert("You are required to fill out all of the form in order to register!");}
	}else{alert("You are required to agree to the terms in order to register!");}
}

function setupnewuser(){
	newemail = document.getElementById('newemail').value; 
	pass = document.getElementById('pass').value; 
	name = document.getElementById('name').value; 
	ve = document.getElementById('ve').value; 
	typ = document.getElementById('typ').value; 
	country = document.getElementById('country').value; 
	state = document.getElementById('state').value; 
	month = document.getElementById('month').value; 
	day = document.getElementById('day').value; 
	year = document.getElementById('year').value; 
	gender = document.getElementById('gender').value; 
	var ajaxRequest;    
    try{
        ajaxRequest = new XMLHttpRequest();
    } catch (e){
        try{
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try{
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e){
                alert("Ajax is required for this function to work!");
                return false;
            }
        }
    }

    ajaxRequest.onreadystatechange = function(){
       if(ajaxRequest.readyState == 4){
            document.getElementById('contentbody').innerHTML = ajaxRequest.responseText;
       }
     }
	 
	document.getElementById('contentbody').innerHTML = "<div style='margin-top:10px; font-size:11px'><img src='images/load1.gif' /><div>Processing...<div></div>";
    ajaxRequest.open("GET", "newuser.php?key=" + ve + "&newemail=" + newemail + "&pass=" + pass + "&name=" + name + "&type=" + typ + "&country=" + country + "&state=" + state + "&month=" + month + "&day=" + day + "&year=" + year + "&gender=" + gender );
    ajaxRequest.send(null);
	
	res();
}

function rpw(){
var n = prompt("If you have forgotten your password, please type your email below. A new password will be emailed.", "");

  if(n)
  {
	var ajaxRequest;    
    try{
        ajaxRequest = new XMLHttpRequest();
    } catch (e){
        try{
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try{
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e){
                alert("Ajax is required for this function to work. Please contact admistrator!");
                return false;
            }
        }
    }

    ajaxRequest.onreadystatechange = function(){
       if(ajaxRequest.readyState == 4){
           document.getElementById('blankbody').innerHTML = ajaxRequest.responseText;
       }
     }
	 
	document.getElementById('blankbody').innerHTML = "<div style='position: relative; text-align:center; top:30%; font-family:Century Gothic;'>Checking Records...</div>";
    ajaxRequest.open("GET", "reset.php?id=" + n);
    ajaxRequest.send(null);
  }
}

function rrc(){
var n = prompt("If you have lost your confirmation email, please type your email below. A new confirmation will be emailed.", "");

  if(n)
  {
	var ajaxRequest;    
    try{
        ajaxRequest = new XMLHttpRequest();
    } catch (e){
        try{
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try{
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e){
                alert("Ajax is required for this function to work. Please contact admistrator!");
                return false;
            }
        }
    }

    ajaxRequest.onreadystatechange = function(){
       if(ajaxRequest.readyState == 4){
           document.getElementById('blankbody').innerHTML = ajaxRequest.responseText;
       }
     }
	 
	document.getElementById('blankbody').innerHTML = "<div style='position: relative; text-align:center; top:30%; font-family:Century Gothic;'>Confirming Records...</div>";
    ajaxRequest.open("GET", "cconfirm.php?id=" + n);
    ajaxRequest.send(null);
  }
}