// Default JavaScript Document

function textFocus(inputElement,val){
	var ele = document.getElementById(inputElement);
	if (ele.value == val) {
		ele.value = '';
	}	
}

function textBlur(inputElement,val){
	var ele = document.getElementById(inputElement);
	if (ele.value == '') {
		ele.value = val;
	}	
}

function OpenWindow(URLStr, left, top, width, height){
    var popUpWin=0;
    if(popUpWin){
        if(!popUpWin.closed) popUpWin.close();
    }
    popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
} 

function CloseCheckoutWindow(){
    //window.opener.location.href = URLStr;
    window.opener.location.reload();
    self.close();
} 

function thickboxDone(querystring) {
    var currentURL = window.location;
    var newURL = currentURL.protocol + '//' + currentURL.hostname + currentURL.pathname;
    
    tb_remove();
    
    if (querystring == true) {
        window.location.reload(true);
    }
    else {
        window.location.href = newURL;
    } 
}

function thickboxDoneCheckout(petId, petName, itemId) {
    $('li.jitem_' + itemId + ' p.selectpet').html('<a href="/My-Account/View-Pet.html?pet_id=' + petId + '&amp;keepThis=true&amp;TB_iframe=true&amp;height=200&amp;width=500" title="Pet Detail: ' + petName + '" class="thickbox">' + petName + '</a> (<a href="/My-Account/Select-Pet.html?item_id=' + itemId + '&amp;keepThis=true&amp;TB_iframe=true&amp;height=600&amp;width=600" class="thickbox" title="Change selected pet">Change</a>)');  
    tb_remove();  
}

function filter_product(refSelect, filterName){
    //get the value of selected item of select box
    var filterValue = refSelect.options[refSelect.selectedIndex].value;
    var queryString;
    
    //if the value of option is -1 then remove the selected filter from condition else add it.
    if (filterValue == '-1')
        queryString = '?filter_action=1&filter_name=' + encodeURI(filterName) + '&filter_value=' + filterValue + '&filter_type=1';
    else
        queryString = '?filter_action=0&filter_name=' + encodeURI(filterName) + '&filter_value=' + filterValue + '&filter_type=1';
    window.location = queryString;
}

