var path = ''

function hideLayer(id){
	document.getElementById(id).style.visibility = "hidden"
}

function showlayer(id){
	document.getElementById(id).style.visibility = "visible"
}


function ietruebody(){ //Dynamicdrive added function
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function checkFrm(){
    var subject = document.getElementById("tx_subject").value
    var msg = document.getElementById("yourMsg").value
    var e = ""
    if (subject=="")e = e + "Please enter a subject\n"
    if (msg=="")e = e + "Please enter a message"
    if (e!=""){
        alert(e)
        return false
    }
    return true
}

function showtip(id,offSet){
  var x, y;
	document.getElementById(id).style.left=(currentX-offSet) + "px"
	document.getElementById(id).style.top=(currentY+20) + "px"
	showlayer(id)
}


function hidetip(layerid){
	    hideLayer(layerid)
}


var isEdit
var mType
function checkModelForm(frm){

    var msg = ""

    if (!isEdit){
        
        if (document.modelForm.tx_username.value=="")
            msg = msg + "Please enter a username\n"
            
        if (!document.getElementById("cb_over18").checked)
            msg = msg + "Please tick the box to confirm you are 18 or over\n"
            
        if (document.getElementById("tx_pwd1").value=="")
            msg = msg + "Please enter a password\n"
        
        if (document.getElementById("tx_pwd2").value=="")
            msg = msg + "Please confirm your password\n"    
            
        if (document.getElementById("source").value=="")
            msg = msg + "Please tell us where you heard about us\n"            
                   
            
        if (mType=="model"){
            var dd_day = document.getElementById("Day_frm").selectedIndex
            var dd_month = document.getElementById("Mon_frm").selectedIndex
            var dd_Year = document.getElementById("Year_frm").selectedIndex
            var dd_sex = document.getElementById("gender_frm").selectedIndex
            
            if (dd_day == 0 || dd_month == 0 || dd_Year == 0)
                msg = msg + "Please enter your date of birth\n"
            
            if (dd_sex == 0)
                msg = msg + "Please enter your sex\n"
        }
            
            
    }
           
        
        if (document.getElementById("firstname_frm").value=="")
                msg = msg + "Please enter your firstname\n"
        
        if (document.getElementById("lastname_frm").value=="")
                msg = msg + "Please enter your lastname\n"
        
        
        if (document.getElementById("email_frm").value=="")
                msg = msg + "Please enter your email address\n"
        
        if (document.getElementById("tx_email2").value=="")
                msg = msg + "Please confirm your email address\n"



        if (document.getElementById("comments_frm").value == "")
                msg = msg + "Please add something in the general comments section\n"
            
            
            
       
        if (msg != ""){
            alert(msg)
            return false
        }
 

	return true

}
	
	
function checkStudioForm(frm){

    var msg = ""

    if (!isEdit){
        
        if (document.modelForm.tx_username.value=="")
            msg = msg + "Please enter a username\n"
            
        if (!document.getElementById("cb_over18").checked)
            msg = msg + "Please tick the box to confirm you are 18 or over\n"
            
        if (document.getElementById("tx_pwd1").value=="")
            msg = msg + "Please enter a password\n"
        
        if (document.getElementById("tx_pwd2").value=="")
            msg = msg + "Please confirm your password\n"  
            
        if (document.getElementById("source").value=="")
            msg = msg + "Please tell us where you heard about us\n"            
                     
    }
           
        
        if (document.getElementById("tx_business").value=="")
                msg = msg + "Please enter your business name\n"
        
        if (document.getElementById("firstname_frm").value=="")
                msg = msg + "Please enter your firstname\n"
        
        if (document.getElementById("lastname_frm").value=="")
                msg = msg + "Please enter your lastname\n"
        
        
        if (document.getElementById("email_frm").value=="")
                msg = msg + "Please enter your email address\n"
        
        if (document.getElementById("tx_email2").value=="")
                msg = msg + "Please confirm your email address\n"


        if (document.getElementById("tx_add1").value=="")
                msg = msg + "Please enter address line 1\n"

        if (document.getElementById("tx_city").value=="")
                msg = msg + "Please enter your city or town\n"

        if (document.getElementById("tx_phoneLand").value=="")
                msg = msg + "Please enter a land line phone number\n"


       
        if (msg != ""){
            alert(msg)
            return false
        }
 

	return true

}	
	
	
	
	
var currentX = 0;
var currentY = 0;

if (document.captureEvent){
  document.captureEvent(Event.MOUSEMOVE);
}

function getMousePosition(evt){

  if (window.event){
    try{
        currentX = window.event.clientX + document.body.scrollLeft;
        currentY = window.event.clientY + document.body.scrollTop;
    }catch(exception){
        currentX = 0
        currentY = 0
    }
  }
  else if (evt){
    try{
    currentX = evt.pageX;
    currentY = evt.pageY;
    }catch(exception){
    currentX = 0
    currentY = 0
    }
  }
}

// register getMousePosition() as an event handler for the onmousemove event.
document.onmousemove = getMousePosition;


var lid
var t = 0
var mytime	

function showme(layerID,pos){
    lid = layerID
    currentX=currentX-150-pos
    document.getElementById(layerID).style.visibility="visible"
	document.getElementById(lid).style.opacity = 0
    document.getElementById(lid).style.filter = 'alpha(opacity=' + 0 + ')'
    if(currentX>400)currentX=400
    document.getElementById(layerID).style.left=currentX + "px"
    mytimer=setInterval("fadeIn()",10)
}

function hideme(layerID){
    document.getElementById(layerID).style.visibility="hidden"
    clearInterval(mytimer)
    t=0
}

function fadeIn(){
	document.getElementById(lid).style.opacity = t
    document.getElementById(lid).style.filter = 'alpha(opacity=' + t + ')'
    t=t+10
    if(t==110){
        t=0;
        clearInterval(mytimer)
        document.getElementById(lid).style.filter = 'shadow(color:gray, strength:3, direction:135)'
    }
  
  
}


function subSimpleForm(){
	if (document.simpleForm.tx_search.value=="" || document.simpleForm.tx_search.value=="Username"){
		alert("You didn\'t enter anything")
		document.simpleForm.tx_search.focus()
	}else{
        document.simpleForm.submit()
   }
}


function checkSimpleForm(frm){
	if (frm.logon_tx_search.value=="" || frm.logon_tx_search.value=="Username"){
		alert("You didn\'t enter anything")
		frm.logon_tx_search.focus()
		return false
	}
	return true
}

function checkText(obj){
	if (obj.value=="Username")obj.value=""		
}

function checkTextBlur(obj){
	if (obj.value=="")obj.value="Username"		
}




function searchProfile(path){
    var frm = document.getElementById('simpleForm')
    if (checkSimpleForm(frm)){
        frm.action=path + "profile.aspx?id=" + frm.logon_tx_search.value
        frm.target="_blank"
        frm.submit()
    }
}

function deleteImage(idx){
    if (confirm("Are you sure you want to delete this picture " + document.getElementById("hd_name").value + "?")){
        document.getElementById("hd_im").value = idx
        document.getElementById("frm_images").submit()
    }
}

function detectReturn(path,e){
    var frm = document.getElementById('simpleForm')
	var evtobj=window.event? event : e
    var node = (evtobj.target) ? evtobj.target : ((evtobj.srcElement) ? evtobj.srcElement : null);
    var unicode=evtobj.charCode? evtobj.charCode : evtobj.keyCode
    var nName = node.id
    if (nName=="logon_tx_search" && unicode ==13){
        if (checkSimpleForm(frm)){
            frm.action=path + "profile.aspx?id=" + frm.logon_tx_search.value
            frm.target="_blank"
            frm.submit()
            return false
        }
    }
    return true
}

function setForm(){
        var frm = document.getElementById('simpleForm')
        frm.action=""
        frm.target="_self"
}

function f_message(f_alert){
    if (f_alert != "")alert(f_alert)
}


function u_logout(){
    var frm = document.getElementById('simpleForm')
    document.getElementById('mode').value="V"
    frm.action=""
    frm.target="_self"
    frm.submit()
}

function deleteAll(obj){
    var tab = document.getElementById("tbl_msgs")
    var c = tab.rows.length
    var n
    var iden
    for(n=1;n<c;n++){
           iden = tab.rows[n].cells[0].childNodes[0].id
           document.getElementById(iden).checked=obj.checked
    }		
}

function usnClick(obj){
	if (obj.value=="username")obj.value=""
	if (obj.value == "Username") obj.value = ""
	
	obj.className = "dv_txBox"
	

	
}

function usnClickBlur(obj){
	//if (obj.value=="")obj.value="username.."
    if (obj.value == "") {
        obj.value = "Username"
        obj.className = "dv_txBox2"
    }
	
}



function voteMsg(){
	alert("Thankyou, your vote has been cast for this page")
}

function send(start){
	document.modelForm.mode.value = "C"
	document.modelForm.spoint.value = start
	document.modelForm.submit()
}

function oChange(){
	document.modelForm.mode.value = "C"
	document.modelForm.spoint.value = 0
	document.modelForm.submit()
}

function openWin(URL,windowname,theWidth,theHeight,t){
	if (theWidth == "") {theWidth = 600 }
	if (theHeight == "") {theHeight = 600 }
	var details
	var max = screen.height-90

	if (theHeight > max)theHeight = max


	details = "titlebar=no,left=0,top=0,toolbar=no, address=no, status=yes, scrollbars=yes, resizable=yes, height=" + theHeight + ",width=" + theWidth;
	var win2 = window.open(URL,windowname,details);
	win2.focus()

}

function deleteSaved(id){
    document.getElementById("hd_idx").value = id
    document.getElementById("form1").submit()
}

var alertTimerId = 0;

function openFacilities() {
    clearTimeout(alertTimerId)
    hideMailLayer()
    hideForumLayer()
    hideCastings()
    document.getElementById("logon_dv_facilities").style.visibility = "visible"
}

function openMail() {
    clearTimeout(alertTimerId)
    hideFacilitiesLayer()
    hideForumLayer()
    hideCastingsLayer()
    document.getElementById("logon_dv_mailbox").style.visibility="visible"
}

function openForum() {
    clearTimeout(alertTimerId)
    hideMailLayer()
    hideFacilitiesLayer()
    hideCastingsLayer()
    document.getElementById("logon_dv_forum").style.visibility = "visible"
}

function openCastings() {
    clearTimeout(alertTimerId)
    hideFacilitiesLayer()
    hideForumLayer()
    hideMailLayer()
    document.getElementById("logon_dv_casting").style.visibility = "visible"
}


function hideMail(){
    clearTimeout (alertTimerId)
    alertTimerId = setTimeout ("hideMailLayer()", 1000 );
}

function hideMailLayer(){
    document.getElementById("logon_dv_mailbox").style.visibility="hidden"
}


function hideCastings() {
    clearTimeout(alertTimerId)
    alertTimerId = setTimeout("hideCastingsLayer()", 1000);
}

function hideCastingsLayer() {
    document.getElementById("logon_dv_casting").style.visibility = "hidden"
}

function hideFacilities() {
    clearTimeout(alertTimerId)
    alertTimerId = setTimeout("hideFacilitiesLayer()", 1000);
}

function hideFacilitiesLayer() {
    document.getElementById("logon_dv_facilities").style.visibility = "hidden"
}


function hideForum() {
    clearTimeout(alertTimerId)
    alertTimerId = setTimeout("hideForumLayer()", 1000);
}

function hideForumLayer() {
    document.getElementById("logon_dv_forum").style.visibility = "hidden"
}



function lockThread(){
    document.getElementById("hd_lk").value="Y"
    document.getElementById("Form1").submit()
}

function unLockThread(){
    document.getElementById("hd_lk").value="N"
    document.getElementById("Form1").submit()
}



function mv_fm(v){
    document.getElementById("hd_validate").value = v
	document.getElementById('frm_move').submit()	
}

function c_alert(){
    alert("You need to be logged on to do this")
}



function reorder(tab){
    var col1 = "#EEEEEE"
    for (c=1;c<tab.rows.length;c++){
       if (col1=="#EEEEEE"){
            tab.rows(c).style.backgroundColor = col1
            col1="white"
       }else{
            tab.rows(c).style.backgroundColor = col1
            col1 = "#EEEEEE"
       }
    }    
}



function dismissReminder() {
    requestURL = path + "ajilon/dismiss.aspx"
    callBack = "dismissReminderOK()"
    runCommand()
}

function dismissReminderOK() {
    document.getElementById("logon_dv_appointment").style.display="none"
}


function dMemberL(m, obj){
    var tab = document.getElementById("tbl_otherMembers")
     var rv
     rv = generalCheck.dMemberL(n)
     if(rv.value==1){
         tab.deleteRow(obj.parentNode.parentNode.parentNode.rowIndex)
         reorder(tab)
    }
}


function delTh(idx){
    if (confirm("Are you sure?")){
        document.getElementById('hd_mode').value=idx
        document.Form1.submit()
    }
}

function deImg(idx){
    if (confirm("Are you sure?")){
        document.getElementById('hd_idx').value=idx
        document.profileForm.submit()
    }
}



function searchFC(obj){
    if (obj.value == "userid...") obj.value = ""
    obj.style.fontStyle="normal"
}

function searchBL(obj){
    if (obj.value == ""){
        obj.value = "userid..."
        obj.style.fontStyle="italic"
    }
}


function expand(){
    var obj = document.getElementById("tbl_otherMembers")
    if (obj.style.display=="block"){
        obj.style.display="none"
        document.getElementById("img_expand").src = img1.src
        document.getElementById("img_expand").alt="Expand this section"
    }else{
        obj.style.display="block"
        document.getElementById("img_expand").src = img2.src
        document.getElementById("img_expand").alt="Hide this section"
    }
}
