﻿function ShowHidePanel(id){
    var obj=document.getElementById(id);
    if(obj!=null)
        obj.style.display=(obj.style.display=='none'?'':'none');
}

function getElementPosition(elemId){

    var elem = elemId;
	
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
	
    var l = 0;
    var t = 0;
	
    while (elem){
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
}

function showPopupMenu(id){
    coor_el = getElementPosition(document.getElementById('my_account_link'));
    document.getElementById(id).style.top = coor_el.top+36+'px'; 
    document.getElementById('my_account_link').className = 'top_right_menu_3_cur';
    document.getElementById(id).style.left = coor_el.left-80+'px';
    document.getElementById(id).style.display = (document.getElementById(id).style.display ==  'none' ? '' : 'none');    
}

function hidePopupMenu(){
    if(document.getElementById('popup_menu').style.display != 'none'){
        document.getElementById('popup_menu').style.display = 'none';
        document.getElementById('my_account_link').className = ''; 
    }
}

function getSrcImage(el)
{
 cur_src = el.src;
 ind_f = cur_src.lastIndexOf('/');
 return cur_src.substring(ind_f+1);
}

/* Over */
function inpOver(cur_img)
{
 switch(getSrcImage(cur_img))
 {
  case 'inp_checkb_emp.jpg' : cur_img.src = 'images/inp_checkb_emp_h.jpg' ; break;
  case 'inp_checkb_check.jpg' : cur_img.src = 'images/inp_checkb_check_h.jpg' ; break;  
  case 'inp_radio_emp.jpg' : cur_img.src = 'images/inp_radio_emp_h.jpg' ; break;
  case 'inp_radio_check.jpg' : cur_img.src = 'images/inp_radio_check_h.jpg' ; break;      
 }
}

/* Out */
function inpOut(cur_img)
{
 switch(getSrcImage(cur_img))
 {
  case 'inp_checkb_emp_h.jpg' : cur_img.src = 'images/inp_checkb_emp.jpg' ; break;
  case 'inp_checkb_check_h.jpg' : cur_img.src = 'images/inp_checkb_check.jpg' ; break;  
  case 'inp_radio_check_h.jpg' : cur_img.src = 'images/inp_radio_check.jpg' ; break;    
  case 'inp_radio_emp_h.jpg' : cur_img.src = 'images/inp_radio_emp.jpg' ; break;      
 }
}

/* Click */
function inpClick(cur_img)
{
 switch(getSrcImage(cur_img))
 {
  case 'inp_checkb_emp_h.jpg' : cur_img.src = 'images/inp_checkb_check_h.jpg' ; break;
  case 'inp_checkb_check_h.jpg' : cur_img.src = 'images/inp_checkb_emp_h.jpg' ; break;  
  case 'inp_checkb_emp.jpg' : cur_img.src = 'images/inp_checkb_check.jpg' ; break;
  case 'inp_checkb_check.jpg' : cur_img.src = 'images/inp_checkb_emp.jpg' ; break;  
  case 'inp_radio_emp_h.jpg' : cur_img.src = 'images/inp_radio_check_h.jpg' ; break;
  case 'inp_radio_check_h.jpg' : cur_img.src = 'images/inp_radio_emp_h.jpg' ; break;  
 }
}

function prepareCheckBox(image,cb){
    var img =document.getElementById(image); 
    var cb  =document.getElementById(cb);
    
    cb.value=(img.src.indexOf('emp')>=1 ? '0' : '1');     
}

function checkReferrer(ddl){        
    var p1=document.getElementById('propertyID');
    var p2=document.getElementById('affCode');
    var p3=document.getElementById('discount');
    
    p3.style.display=p1.style.display=p2.style.display='none';
    
    var vl=ddl.value;
    if(vl.value=="0") return;
    var port = document.getElementById('portal'+vl)
    if(port){
        if(port.value=='0'){
            p2.style.display='';
        }else if(port.value=='1'){
            p1.style.display='';
        }
    }
    var disc=document.getElementById('discount'+vl);
    if(disc){
        document.getElementById('discount_val').innerHTML='$'+disc.value;
        if(disc.value!='0') p3.style.display='';
    }
}

function checkTextBoxValidator(id1,id2){
    if(document.getElementById(id2).style.display!='none'){
        document.getElementById(id1).className='box_error';
        document.getElementById(id1).onmouseover=null;
        document.getElementById(id1).onmouseout=null;
    }
}

var im1,im2,im3,im4
im1=new Image; im1.src="images/top_left_menu_a_h.jpg";
im2=new Image; im2.src="images/top_left_menu_li_h.jpg";
im3=new Image; im3.src="images/top_right_menu_a_h.jpg";
im4=new Image; im4.src="images/top_right_menu_li_h.jpg";