var menulistover=false;

function menuon(item,status) {

 menutabover=true;
 if (status == 1) {
 	 	document.getElementById('menu' + item + 'bg').style.background='url(images/menu-on-bg.gif)';
 	 	document.getElementById('menu' + item + 'bg').style.color='#2C2E2F';
 }
}


function menuoff(item,status) {
 menutabover=false;

 if (status == 1) {

 	document.getElementById('menu' + item + 'bg').style.background='url(images/menu-off-bg.gif)';
 	document.getElementById('menu' + item + 'bg').style.color='#FFFFFF';
 }
}

 function menuhtml(id, url, display) {
 return '<tr onMouseOver="this.bgColor=\'#21A7E8\';' + id + '.style.color=\'#ffffff\'" onMouseOut="this.bgColor=\'#e8f8f8\';' + id + '.style.color=\'#345D84\'"><td><a id=' + id + ' href="' + url + '" class="menu">' + display + '</a></td></tr>';
}

function showPanel(){ 
   if(document.getElementById('chkSameAddress').checked == true){ 
      document.getElementById('pnlPostalAddress').style.visibility="hidden";
   } 
   else if(document.getElementById('chkSameAddress').checked == false){ 
      document.getElementById('pnlPostalAddress').style.visibility="visible";
   } 
} 

function showHourly(){ 
    var objRadHourly = document.getElementById('radHourly');
    if (objRadHourly){
        if(objRadHourly.checked == true){ 
            //var objTrPaymentRateRow = document.getElementById('trPaymentRateRow');
            var objDivFixedPriceFields = document.getElementById('divFixedPriceFields');
            var objDivHourlyRateFields = document.getElementById('divHourlyRateFields');
            
            //if (objTrPaymentRateRow){
            //    objTrPaymentRateRow.style.display="inline";
            //}        
            if (objDivFixedPriceFields){
                objDivFixedPriceFields.style.display="none";
            }        
            if (objDivHourlyRateFields){
                objDivHourlyRateFields.style.display="inline";
            }        
        } 
    }
} 

function showFixedPrice(){ 
    var objRadFixedPrice = document.getElementById('radFixedPrice');
    if (objRadFixedPrice){
        if(objRadFixedPrice.checked == true){ 
            //var objTrPaymentRateRow = document.getElementById('trPaymentRateRow');
            var objDivFixedPriceFields = document.getElementById('divFixedPriceFields');
            var objDivHourlyRateFields = document.getElementById('divHourlyRateFields');
            
            //if (objTrPaymentRateRow){
            //    objTrPaymentRateRow.style.display="inline";
            //}        
            if (objDivFixedPriceFields){
                objDivFixedPriceFields.style.display="inline";
            }        
            if (objDivHourlyRateFields){
                objDivHourlyRateFields.style.display="none";
            }        
        } 
    }
} 


var CurrentTab = 1;
function GoToTab(TabID){

    var objTab1 = document.getElementById("divTab" + CurrentTab);
    var objTab1_1 = document.getElementById("tdTab" + CurrentTab + "_1");
    var objTab1_2 = document.getElementById("tdTab" + CurrentTab + "_2");
    var objTab1_3 = document.getElementById("tdTab" + CurrentTab + "_3");
    
    var objTab2 = document.getElementById("divTab" + TabID);
    var objTab2_1 = document.getElementById("tdTab" + TabID + "_1");
    var objTab2_2 = document.getElementById("tdTab" + TabID + "_2");
    var objTab2_3 = document.getElementById("tdTab" + TabID + "_3");
    
    if (objTab1){
        objTab1.style.display = "none";
        if (objTab1_1 && objTab1_2 && objTab1_3){
            objTab1_1.className = "tdRowTab";
            objTab1_2.className = "tdRowTab";
            objTab1_3.className = "tdRowTab";
        }
    }
    if (objTab2){
        objTab2.style.display = "inline";
        if (objTab2_1 && objTab2_2 && objTab2_3){
            objTab2_1.className = "tdRowTabOn";
            objTab2_2.className = "tdRowTabOn";
            objTab2_3.className = "tdRowTabOn";
        }
    }
    CurrentTab = TabID;
    var objCurrentTab = document.Form1.CurrentTab;
    if (objCurrentTab){
        objCurrentTab.value = TabID;
    }
}

function popUp(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
	var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
	var int_windowTop = (screen.height - a_int_windowHeight) / 2;
	var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable;
	var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
	if (parseInt(navigator.appVersion) >= 4) {
		obj_window.window.focus();
	}
}


function copyMainAddress(){
    var objForm = document.Form1;
    if (objForm){
        var objAddress1 = objForm.txtAddressLn1;
        var objAddress2 = objForm.txtAddressLn2;
        var objSuburb = objForm.txtSuburb;
        var objState = objForm.ddlState;
        var objPostcode = objForm.txtPostcode;

        var objPostalAddress1 = objForm.txtPostalAddressLn1;
        var objPostalAddress2 = objForm.txtPostalAddressLn2;
        var objPostalSuburb = objForm.txtPostalSuburb;
        var objPostalState = objForm.ddlPostalState;
        var objPostalPostcode = objForm.txtPostalPostcode;
        
        if (objAddress1 && objPostalAddress1){
            objPostalAddress1.value = objAddress1.value;
        }
        
        if (objAddress2 && objPostalAddress2){
            objPostalAddress2.value = objAddress2.value;
        }
        
        if (objSuburb && objPostalSuburb){
            objPostalSuburb.value = objSuburb.value;
        }
        
        if (objState && objPostalState){
            objPostalState.selectedIndex = objState.selectedIndex;
        }
        
        if (objPostcode && objPostalPostcode){
            objPostalPostcode.value = objPostcode.value;
        }
    }
}

function counterUpdate(opt_countedTextBox, opt_countBody, opt_maxSize) {
        var countedTextBox = opt_countedTextBox ? opt_countedTextBox : "txtJobDesc";
        var countBody = opt_countBody ? opt_countBody : "txtJobDesc";
        var maxSize = opt_maxSize ? opt_maxSize : 1024;

        var field = document.getElementById(countedTextBox);

        if (field && field.value.length >= maxSize) {
                field.value = field.value.substring(0, maxSize);
        }
        var txtField = document.getElementById(countBody);
                if (txtField) {  
                txtField.innerHTML = field.value.length;
        }
}

function counterUpdate2(opt_countedTextBox, opt_countBody, opt_maxSize) {
        var countedTextBox = opt_countedTextBox ? opt_countedTextBox : "txtJobDesc";
        var countBody = opt_countBody ? opt_countBody : "countBody";
        var maxSize = opt_maxSize ? opt_maxSize : 2000;

        var field = document.getElementById(countedTextBox);

        if (field && field.value.length >= maxSize) {
                field.value = field.value.substring(0, maxSize);
        }
        
        var txtField = document.getElementById(countBody);
        if (txtField) {  
            txtField.innerHTML = maxSize - field.value.length;
        }
}

function showPostedLength(){
    var objTrPostedLengthRow = document.getElementById("trPostedLengthRow");
    if (objTrPostedLengthRow){
        objTrPostedLengthRow.style.display = "inline";
    }
}

function hidePostedLength(){
    var objTrPostedLengthRow = document.getElementById("trPostedLengthRow");
    if (objTrPostedLengthRow){
        objTrPostedLengthRow.style.display = "none";
    }
}

function clickgo(a,b) {
	var objForm = document.getElementById("Form1");
	var objSubStatus = document.getElementById("subStatus");
	var objSubName = document.getElementById("subName");
	var objSubID = document.getElementById("subID");
	
	if (objSubStatus)
	    objSubStatus.value=1;

	if (objSubName)
	    objSubName.value=a;

	if (objSubID)
    	objSubID.value=b;

	if (objForm)
	    objForm.submit();
	    
}

function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}


function showFAQ(id){
    var objAnswer = document.getElementById("faqA" + id);
    if (objAnswer){
        if (objAnswer.className == "faqAnswer"){
            objAnswer.className = "faqAnswerOn";
            //objAnswer.style.left = (findXPos(document.getElementById("faqQ" + id))) + 'px';
            //objAnswer.style.top = (findYPos(document.getElementById("faqQ" + id)) + 50) + 'px';
        }
        else
            objAnswer.className = "faqAnswer";
    }
}

function showQuestion(id){
    var objAnswer = document.getElementById("A" + id);
    if (objAnswer){
        if (objAnswer.className == "Answer"){
            objAnswer.className = "AnswerOn";
        }
        else
            objAnswer.className = "Answer";
    }
}

function findXPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return curleft;
}

function findYPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return curtop;
}

function submitSearch(field){
    var objForm1 = document.Form1;
    if (objForm1){
        var objSearchForm = document.frmSearchForm;
        if (objSearchForm){
            var objRadModeFreelancer = document.getElementById("radModeFreelancer");
            var objRadModeProject = document.getElementById("radModeProject");
            if (objRadModeFreelancer.checked){
                objSearchForm.action = "search_freelancers.aspx"
            }
            else {
                objSearchForm.action = "search_projects.aspx"
            }
            if (field == "kw"){
                var objSearchKW = document.getElementById("SearchKW");
                objSearchForm.kw.value = objSearchKW.value;
                objSearchForm.submit();
            }
            else if (field == "cat") {
                var objSearchCAT = document.getElementById("SearchCAT");
                if (objSearchCAT){
                    objSearchForm.cat.value = objSearchCAT[objSearchCAT.selectedIndex].value;
                    objSearchForm.submit();
                }
            }
        }
    }    
}

function execMemberLogin(){
    var objForm = document.Form1;
    
    if (objForm){
        var objLogin = objForm.hidLogin;
        if (objLogin){
            objLogin.value = 1;
            objForm.submit();
        }
    }
    
}

function answerQuestion(){
    var objDivAnswerQuestionButtons = document.getElementById("divAnswerQuestionButtons");
    if (objDivAnswerQuestionButtons){
        objDivAnswerQuestionButtons.style.display = "none";

        var objDivAnswerQuestion = document.getElementById("divAnswerQuestion");
        objDivAnswerQuestion.style.display = "inline";
        
        var objDivAnswerAccepted = document.getElementById("divAnswerAccepted");
        objDivAnswerAccepted.style.display = "inline";
        
        var objDivAnswerRejected = document.getElementById("divAnswerRejected");
        objDivAnswerRejected.style.display = "none";
        
        var objHidAnswerType = document.getElementById("hidAnswerType");
        objHidAnswerType.value = "accept";
        
    }
}

function rejectQuestion(){
    var objDivAnswerQuestionButtons = document.getElementById("divAnswerQuestionButtons");
    if (objDivAnswerQuestionButtons){
        objDivAnswerQuestionButtons.style.display = "none";
        
        var objDivAnswerQuestion = document.getElementById("divAnswerQuestion");
        objDivAnswerQuestion.style.display = "inline";

        var objDivAnswerAccepted = document.getElementById("divAnswerAccepted");
        objDivAnswerAccepted.style.display = "none";
        
        var objDivAnswerRejected = document.getElementById("divAnswerRejected");
        objDivAnswerRejected.style.display = "inline";
        
        var objHidAnswerType = document.getElementById("hidAnswerType");
        objHidAnswerType.value = "reject";
    }
    
}

function cancelAnswerQuestion(){
    var objDivAnswerQuestionButtons = document.getElementById("divAnswerQuestionButtons");
    if (objDivAnswerQuestionButtons){
        objDivAnswerQuestionButtons.style.display = "inline";
    
        var objDivAnswerQuestion = document.getElementById("divAnswerQuestion");
        objDivAnswerQuestion.style.display = "none";

        var objDivAnswerRejected = document.getElementById("divAnswerRejected");
        objDivAnswerRejected.style.display = "none";
    }
}
